public void ForceAdd(object obj, Cell cell, string id = null) { if (!dict.TryGetValue(id, out TwoWayDict twd)) { twd = new TwoWayDict(); dict.Add(id, twd); } if (!twd.cellToObj.ContainsKey(cell)) { twd.cellToObj.Add(cell, obj); } else { twd.cellToObj[cell] = obj; } if (!twd.objToCell.ContainsKey(obj)) { twd.objToCell.Add(obj, cell); } else { twd.objToCell[obj] = cell; } }
private void SteamLoop(Irc irc){ string userName = "******"; string passWord = "******"; steamClient.Connect(); // connect to the steam network bool finished = false; while (!finished) { CallbackMsg msg = steamClient.WaitForCallback(true); // block and wait until a callback is posted msg.Handle<SteamClient.ConnectedCallback>(callback => { // the Handle function will call this lambda method for this callback if (callback.Result != EResult.OK) { // break; // the connect result wasn't OK, so something failed sprint("STEAM_CONNECT_FAILED"); return; } sprint("STEAM_CONNECT_SUCCESS"); // we've successfully connected to steam3, so lets logon with our details steamUser.LogOn(new SteamUser.LogOnDetails { Username = userName, Password = passWord, }); }); // Handle logging in msg.Handle<SteamUser.LoggedOnCallback>(callback => { if (callback.Result != EResult.OK) { // logon failed! sprint("LOGIN_FAILED_REASON " + callback.Result); if (callback.Result == EResult.AccountLogonDenied) { sprint("steamguard is s***e: Disable it"); } return; } sprint("LOGIN_SUCCEEDED"); // we've now logged onto Steam3 }); // Print incoming pms, messages with newlines will be treated as multiple messages msg.Handle<SteamFriends.FriendMsgCallback>(callback => { if (callback.EntryType == EChatEntryType.ChatMsg) { String[] lines = callback.Message.Split(new string[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries); foreach (string s in lines) { pmprint(callback.Sender, s); //relayPmToIrc(callback.Sender, s); irc.SendPM(nicks[callback.Sender], s); } } }); // Print incoming group chat messages, messages with newlines will be treated as multiple messages msg.Handle<SteamFriends.ChatMsgCallback>(callback => { if (callback.ChatMsgType == EChatEntryType.ChatMsg) { String[] lines = callback.Message.Split(new string[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries); foreach (string s in lines) { grpprint(callback.ChatRoomID, callback.ChatterID, s); /* Turn the chat id into the clan id */ callback.ChatRoomID.AccountType = EAccountType.Clan; callback.ChatRoomID.AccountInstance = 0; irc.SendChannelMsg(nicks[callback.ChatterID], clans[callback.ChatRoomID], s); } } else { Console.WriteLine("AJHGJHGDJ"); } }); // Handle disconnection // Only happens when you've been disconnected for a while msg.Handle<SteamClient.DisconnectedCallback>(callback => { Console.WriteLine("DISCONNECTED"); finished = true; }); msg.Handle<SteamFriends.ChatEnterCallback>(callback => { Console.WriteLine(callback.EnterResponse); //Console.WriteLine(clanchatters[callback.ClanID]); chanstates[callback.ClanID] = chanstate.joined; }); // Alerts name changes msg.Handle<SteamFriends.PersonaStateCallback>(callback => { SteamID id = callback.FriendID; String name = steamFriends.GetFriendPersonaName(id); /* Add users to channel list */ if (callback.SourceSteamID.AccountType == EAccountType.Chat) { SteamID asclan = callback.SourceSteamID; asclan.AccountType = EAccountType.Clan; asclan.AccountInstance = 0; //Console.WriteLine(steamFriends.GetClanName(asclan) + " " + name); if (!clanchatters.ContainsKey(asclan)) { clanchatters.Add(asclan, new List<SteamID>()); } clanchatters[asclan].Add(id); Console.WriteLine(name + " in " + clans[asclan]); } EPersonaState state = steamFriends.GetFriendPersonaState(id); //Console.WriteLine(name + " " + state); if (id.AccountType == EAccountType.Individual && name.Length > 0) { if (!namecache.ContainsKey(id)) { namecache[id] = new idcache(name, state); nicks.Add(Util.fixName(name, nicks, Irc.NICKLEN), id); } else { if (namecache[id].name != name) { //namecache[id] = new idcache(name, state); namecache[id].name = name; //Console.WriteLine("name change " + id + " " + name + " " + id.AccountType); } if (namecache[id].state != state) { namecache[id].state = state; //Console.WriteLine("state change " + name + " " + state); } } } }); msg.Handle<SteamFriends.ChatMemberInfoCallback>(callback => { Console.WriteLine("asdhg " + callback.StateChangeInfo.ChatterActedOn); }); // Start doing stuff once ready msg.Handle<SteamUser.LoginKeyCallback>(callback => { sprint("READY"); ready = true; // Allows other parts to start doing stuff steamFriends.SetPersonaState(SteamKit2.EPersonaState.Online); sprint("ONLINE"); // Initialise steamid cache /*SteamID friend; String name; EPersonaState state; for (int i = 0; i != steamFriends.GetFriendCount(); i++) { friend = steamFriends.GetFriendByIndex(i); name = steamFriends.GetFriendPersonaName(friend); state = steamFriends.GetFriendPersonaState(friend); namecache[friend] = new idcache(name, state); Console.WriteLine("FRIEND " + friend + " " + namecache[friend].name); Thread.Sleep(1000); Console.WriteLine("a----------------" + steamFriends.GetClanName(steamFriends.GetClanByIndex(0))); }*/ friends = getFriends(); clans = getClans(); //Thread.Sleep(1000); //steamFriends.JoinChat(steamFriends.GetClanByIndex(0)); }); } }
public TwoWayDict<String, SteamID> getClans() { TwoWayDict<String, SteamID> clans = new TwoWayDict<String, SteamID>(); for (int i = 0; i < steamFriends.GetClanCount(); i++) { clans.Add("#" + Util.fixName(steamFriends.GetClanName(steamFriends.GetClanByIndex(i)), clans, Irc.CHANLEN), steamFriends.GetClanByIndex(i)); } return clans; }