public static void AddFriend(object obj = null) { int serial = obj != null ? AliasCommands.ResolveSerial(obj) : UOC.GetTargeSerialAsync(Strings.Target_new_friend___).Result; if (serial == 0) { UOC.SystemMessage(Strings.Invalid_or_unknown_object_id); return; } Mobile m = Engine.Mobiles.GetMobile(serial); if (m == null) { UOC.SystemMessage(Strings.Invalid_or_unknown_object_id); return; } FriendEntry fe = new FriendEntry { Name = m.Name.Trim(), Serial = m.Serial }; if (!Options.CurrentOptions.Friends.Contains(fe)) { Engine.Dispatcher?.Invoke(() => Options.CurrentOptions.Friends.Add(fe)); } }
public static void RemoveFriend(object obj = null) { int serial = obj != null ? AliasCommands.ResolveSerial(obj) : UOC.GetTargetSerialAsync(Strings.Target_friend_to_remove___).Result; if (serial == 0) { UOC.SystemMessage(Strings.Invalid_or_unknown_object_id); return; } FriendEntry entry = Options.CurrentOptions.Friends.FirstOrDefault(i => i.Serial == serial); if (entry == null) { return; } Engine.Dispatcher?.Invoke(() => { bool result = Options.CurrentOptions.Friends.Remove(entry); if (!Options.CurrentOptions.RehueFriends) { return(result); } Engine.RehueList.Remove(serial); MainCommands.Resync(); return(result); }); }
public static void HandleFriendsListRequest(Packet _packet) { int _length = _packet.ReadInt(); FriendEntry[] friendsArray = new FriendEntry[_length]; int[] _ids = new int[_length]; string[] _usernames = new string[_length]; for (int i = 0; i < friendsArray.Length; i++) { string _username = _packet.ReadString(); _usernames[i] = _username; } for (int i = 0; i < friendsArray.Length; i++) { int _id = _packet.ReadInt(); _ids[i] = _id; } FriendManager.instance.SetFriendsList(_length); for (int i = 0; i < friendsArray.Length; i++) { FriendManager.instance.PopulateFriendsList(_ids[i], _usernames[i], i); } }
protected override IEnumerator SetUp() { GameObject go = Object.Instantiate((GameObject)Resources.Load(FRIEND_ENTRY_RESOURCE_NAME)); entry = go.GetComponent <FriendEntry>(); yield break; }
public async Task <IActionResult> Edit(long id, [Bind("Id,FirstPersonId,SecondPersonId")] FriendEntry friendEntry) { if (id != friendEntry.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(friendEntry); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FriendEntryExists(friendEntry.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(friendEntry)); }
/// <summary> /// Update friend list. /// </summary> void UpdateFriendList() { if (inviteCooldown > 0.0f) { inviteCooldown -= Time.deltaTime; } else { // Reset invited friend steam id. invitedFriendSteamId.Clear(); } timeToUpdateFriendList -= Time.deltaTime; if (timeToUpdateFriendList > 0.0f) { return; } onlineFriends.Clear(); Steamworks.EFriendFlags friendFlags = Steamworks.EFriendFlags.k_EFriendFlagImmediate; int friendsCount = Steamworks.SteamFriends.GetFriendCount(friendFlags); for (int i = 0; i < friendsCount; ++i) { Steamworks.CSteamID friendSteamId = Steamworks.SteamFriends.GetFriendByIndex(i, friendFlags); if (Steamworks.SteamFriends.GetFriendPersonaState(friendSteamId) == Steamworks.EPersonaState.k_EPersonaStateOffline) { continue; } FriendEntry friend = new FriendEntry(); friend.steamId = friendSteamId; friend.name = Steamworks.SteamFriends.GetFriendPersonaName(friendSteamId); Steamworks.FriendGameInfo_t gameInfo; Steamworks.SteamFriends.GetFriendGamePlayed(friendSteamId, out gameInfo); friend.playingMSC = (gameInfo.m_gameID.AppID() == Client.GAME_APP_ID); if (friend.playingMSC) { onlineFriends.Insert(0, friend); } else { onlineFriends.Add(friend); } } timeToUpdateFriendList = FRIENDLIST_UPDATE_INTERVAL; }
public async Task <IActionResult> Create([Bind("Id,FirstPersonId,SecondPersonId")] FriendEntry friendEntry) { if (ModelState.IsValid) { _context.Add(friendEntry); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(friendEntry)); }
public int HandlePacket(BaseClient client, PacketIn packet) { WorldClient cclient = (WorldClient)client; string charName = packet.GetParsedString(); PacketOut Out = new PacketOut((uint)Opcodes.ANS_FRIENDLIST_ADD); int count = Databases.CharacterTable.Count(c => c.Name == charName); CharacterEntry chr = Databases.CharacterTable.SingleOrDefault(c => c.Name == charName); if (cclient.Character.Name == charName) { Out.WriteUInt32Reverse((uint)ResponseCodes.RC_FRIENDLIST_ADD_SELF); } else { if (cclient.Character.AccountIndex == chr.AccountIndex) { Out.WriteUInt32Reverse((uint)ResponseCodes.RC_FRIENDLIST_ADD_SAME_ACCOUNT); } else { if (count < 1) { Out.WriteUInt32Reverse((uint)ResponseCodes.RC_FRIENDLIST_ADD_INVALID_NAME); } else if (count >= 1) { Out.WriteUInt32((uint)ResponseCodes.RC_SUCCESS); Out.WriteParsedString(charName); Out.WriteByte(chr.Faction); Out.WriteByte(chr.IsOnline); Out.WriteUInt32Reverse((uint)chr.Index); Out.WriteByte(chr.LFG); Out.WriteByte(chr.GroupStatus); Out.WriteByte(chr.IsGroupPublic); Out.WriteByte(chr.GroupInvite); uint code = (uint)(chr.DistrictType << 24); code += chr.DistrictID; Districts.District d; Program.districtsListener.Districts.TryGetValue(code, out d); Out.WriteUInt32(code); Out.WriteByte(d.isFull()); FriendEntry frnd = new FriendEntry(); frnd.Index = Databases.FriendTable.GenerateIndex(); frnd.CharacterOwnerIndex = cclient.Character.Index; frnd.CharacterFriendIndex = chr.Index; Databases.FriendTable.Add(frnd); } } } cclient.Send(Out); return(0); }
public int HandlePacket(BaseClient client, PacketIn packet) { WorldClient cclient = (WorldClient)client; uint charUID = packet.GetUint32Reversed(); FriendEntry frnd = Databases.FriendTable.SingleOrDefault(f => f.CharacterFriendIndex == charUID); Databases.FriendTable.Remove(frnd); PacketOut Out = new PacketOut((uint)Opcodes.ANS_FRIENDLIST_REMOVE); Out.WriteUInt32((uint)ResponseCodes.RC_SUCCESS); Out.WriteUInt32Reverse(charUID); cclient.Send(Out); return(0); }
public void WillAutoAcceptPartyInviteIfFriend() { Options.CurrentOptions.AutoAcceptPartyInvite = true; Options.CurrentOptions.AutoAcceptPartyOnlyFromFriends = true; AutoResetEvent are = new AutoResetEvent(false); FriendEntry fe = new FriendEntry { Name = "Test", Serial = 0xaabbcc }; Options.CurrentOptions.Friends.Add(fe); void OnPacketSentEvent(byte[] data, int length) { if (data[0] == 0xBF && data[5] == 0x08) { are.Set(); } } Engine.InternalPacketSentEvent += OnPacketSentEvent; IncomingPacketHandlers.Initialize(); PacketHandler handler = IncomingPacketHandlers.GetHandler(0xBF); byte[] packet = { 0xBF, 0x00, 0x0A, 0x00, 0x06, 0x07, 0x00, 0xaa, 0xbb, 0xcc }; handler.OnReceive(new PacketReader(packet, packet.Length, false)); bool result = are.WaitOne(5000); Assert.IsTrue(result); Options.CurrentOptions.Friends.Remove(fe); Engine.InternalPacketSentEvent -= OnPacketSentEvent; }
protected bool Equals(FriendEntry other) { return(Serial == other.Serial); }
private void Entry_OnWhisper(FriendEntry entry) { OnPressWhisper?.Invoke(entry.userId); }
/// <summary> /// Updates invite panel IMGUI. /// </summary> private void UpdateInvitePanel() { if (!IsInvitePanelVisible()) { GUI.color = Color.white; GUI.Label(new Rect(0, Screen.height - 100, 200.0f, 20.0f), "[ESCAPE] - Invite friend"); return; } const float invitePanelHeight = 400.0f; const float invitePanelWidth = 300.0f; const float rowHeight = 20.0f; Rect invitePanelRect = new Rect(Screen.width - invitePanelWidth - 10.0f, Screen.height / 2 - invitePanelHeight / 2, invitePanelWidth, 20.0f); // Draw header GUI.color = new Color(1.0f, 0.5f, 0.0f, 0.8f); IMGUIUtils.DrawPlainColorRect(invitePanelRect); GUI.color = Color.white; invitePanelRect.x += 2.0f; GUI.Label(invitePanelRect, "Invite friend"); invitePanelRect.x -= 2.0f; // Draw contents invitePanelRect.y += 21.0f; invitePanelRect.height = invitePanelHeight; GUI.color = new Color(0.0f, 0.0f, 0.0f, 0.8f); IMGUIUtils.DrawPlainColorRect(invitePanelRect); GUI.color = new Color(1.0f, 0.5f, 0.0f, 0.8f); int onlineFriendsCount = onlineFriends.Count; invitePanelRect.height -= 2.0f; if (onlineFriendsCount == 0) { GUI.color = Color.white; var previousAlignment = GUI.skin.label.alignment; GUI.skin.label.alignment = TextAnchor.MiddleCenter; bool playerIsOffline = Steamworks.SteamFriends.GetPersonaState() == Steamworks.EPersonaState.k_EPersonaStateOffline; if (playerIsOffline) { GUI.Label(invitePanelRect, "You cannot invite friends while in steam offline mode.\n\nSwitch back your steam status to online to be able to invite players."); } else { GUI.Label(invitePanelRect, "You don't have any friends online."); } GUI.skin.label.alignment = previousAlignment; return; } friendsScrollViewPos = GUI.BeginScrollView(invitePanelRect, friendsScrollViewPos, new Rect(0, 0, invitePanelWidth - 20.0f, 20.0f * onlineFriendsCount)); int firstVisibleFriendId = (int)(friendsScrollViewPos.y / rowHeight); int maxVisibleFriends = (int)(invitePanelHeight / rowHeight); int lastIndex = firstVisibleFriendId + maxVisibleFriends + 1; if (lastIndex > onlineFriendsCount) { lastIndex = onlineFriendsCount; } for (int i = firstVisibleFriendId; i < lastIndex; ++i) { FriendEntry friend = onlineFriends[i]; if (friend.playingMSC) { GUI.color = Color.green; } else { GUI.color = Color.white; } Rect friendRect = new Rect(2, 1 + rowHeight * i, 200.0f, rowHeight); GUI.Label(friendRect, friend.name); friendRect.x += 180.0f; friendRect.width = 100.0f; Steamworks.CSteamID friendSteamId = friend.steamId; if (invitedFriendSteamId == friendSteamId) { GUI.Label(friendRect, String.Format("INVITED! ({0:F1}s)", inviteCooldown)); continue; } if (inviteCooldown > 0.0f) { continue; } if (GUI.Button(friendRect, "Invite")) { if (netManager.InviteToMyLobby(friendSteamId)) { invitedFriendSteamId = friendSteamId; inviteCooldown = INVITE_COOLDOWN; } else { UI.MPGUI.Instance.ShowMessageBox("Failed to invite friend due to steam error."); } } } GUI.EndScrollView(); }
/// <summary> /// Updates invite panel IMGUI. /// </summary> private void UpdateInvitePanel() { if (!IsInvitePanelVisible()) { GUI.color = Color.white; GUI.Label(new Rect(0, Screen.height - 100, 200.0f, 20.0f), "[ESCAPE] - Invite friend"); return; } const float invitePanelHeight = 400.0f; const float invitePanelWidth = 300.0f; const float rowHeight = 20.0f; Rect invitePanelRect = new Rect(10, Screen.height / 2 - invitePanelHeight / 2, invitePanelWidth, 20.0f); // Draw header GUI.color = new Color(1.0f, 0.5f, 0.0f, 0.8f); GUI.DrawTexture(invitePanelRect, fillText); GUI.color = Color.white; invitePanelRect.x += 2.0f; GUI.Label(invitePanelRect, "Invite friend"); invitePanelRect.x -= 2.0f; // Draw contents invitePanelRect.y += 21.0f; invitePanelRect.height = invitePanelHeight; GUI.color = new Color(0.0f, 0.0f, 0.0f, 0.8f); GUI.DrawTexture(invitePanelRect, fillText); GUI.color = new Color(1.0f, 0.5f, 0.0f, 0.8f); int onlineFriendsCount = onlineFriends.Count; invitePanelRect.height -= 2.0f; friendsScrollViewPos = GUI.BeginScrollView(invitePanelRect, friendsScrollViewPos, new Rect(0, 0, invitePanelWidth - 20.0f, 20.0f * onlineFriendsCount)); int firstVisibleFriendId = (int)(friendsScrollViewPos.y / rowHeight); int maxVisibleFriends = (int)(invitePanelHeight / rowHeight); int lastIndex = firstVisibleFriendId + maxVisibleFriends + 1; if (lastIndex > onlineFriendsCount) { lastIndex = onlineFriendsCount; } for (int i = firstVisibleFriendId; i < lastIndex; ++i) { FriendEntry friend = onlineFriends[i]; if (friend.playingMSC) { GUI.color = Color.green; } else { GUI.color = Color.white; } Rect friendRect = new Rect(2, 1 + rowHeight * i, 200.0f, rowHeight); GUI.Label(friendRect, friend.name); friendRect.x += 180.0f; friendRect.width = 100.0f; Steamworks.CSteamID friendSteamId = friend.steamId; if (invitedFriendSteamId == friendSteamId) { GUI.Label(friendRect, String.Format("INVITED! ({0:F1}s)", inviteCooldown)); continue; } if (inviteCooldown > 0.0f) { continue; } if (GUI.Button(friendRect, "Invite")) { if (netManager.InviteToMyLobby(friendSteamId)) { invitedFriendSteamId = friendSteamId; inviteCooldown = INVITE_COOLDOWN; } else { UI.MPGUI.Instance.ShowMessageBox("Failed to invite friend due to steam error."); } } } GUI.EndScrollView(); }
static int SortByState(FriendEntry f1, FriendEntry f2) { return(f1.state.CompareTo(f2.state)); }