private void MapRenderer_OnUserInfoUpdated(MinimapMetadata.MinimapUserInfo userInfo) { if (usersInfo.TryGetValue(userInfo.userId, out MinimapMetadata.MinimapUserInfo existingUserInfo)) { existingUserInfo = userInfo; if (usersInfoMarkers.TryGetValue(userInfo.userId, out PoolableObject go)) { ConfigureUserIcon(go.gameObject, userInfo.worldPosition, userInfo.userName); } } else { usersInfo.Add(userInfo.userId, userInfo); if (!PoolManager.i.ContainsPool(MINIMAP_USER_ICONS_POOL_NAME)) { usersInfoPool = PoolManager.i.AddPool(MINIMAP_USER_ICONS_POOL_NAME, Instantiate(userIconPrefab.gameObject, overlayContainer.transform)); } PoolableObject newUserIcon = usersInfoPool.Get(); newUserIcon.gameObject.name = string.Format("UserIcon-{0}", userInfo.userName); newUserIcon.gameObject.transform.parent = overlayContainer.transform; newUserIcon.gameObject.transform.localScale = Vector3.one; ConfigureUserIcon(newUserIcon.gameObject, userInfo.worldPosition, userInfo.userName); usersInfoMarkers.Add(userInfo.userId, newUserIcon); } }
void IUsersAroundListHUDListView.AddOrUpdateUser(MinimapMetadata.MinimapUserInfo userInfo) { if (userElementDictionary.ContainsKey(userInfo.userId)) { return; } var profile = UserProfileController.userProfilesCatalog.Get(userInfo.userId); if (profile == null) { return; } UsersAroundListHUDListElementView view = null; if (availableElements.Count > 0) { view = availableElements.Dequeue(); } else { view = Instantiate(listElementView, contentPlayers); view.OnMuteUser += OnMuteUser; view.OnShowUserContexMenu += OnUserContextMenu; } view.OnPoolGet(); view.SetUserProfile(profile); userElementDictionary.Add(userInfo.userId, view); OnModifyListCount(); CheckListEmptyState(); }
private void UpdateAvatarIconInMinimap(MinimapMetadata.MinimapUserInfo userInfo) { MinimapMetadataController.i?.UpdateMinimapUserInformation(new MinimapMetadata.MinimapUserInfo { userId = userInfo.userId, userName = userInfo.userName, worldPosition = userInfo.worldPosition }); }
private void MapRenderer_OnUserInfoUpdated(MinimapMetadata.MinimapUserInfo userInfo) { if (!usersInfoMarkers.TryGetValue(userInfo.userId, out PoolableObject marker)) { marker = usersInfoPool.Get(); marker.gameObject.name = $"UserIcon-{userInfo.userName}"; marker.gameObject.transform.SetParent(overlayContainer.transform, true); marker.gameObject.transform.localScale = Vector3.one; usersInfoMarkers.Add(userInfo.userId, marker); } ConfigureUserIcon(marker.gameObject, userInfo.worldPosition); }
/// <summary> /// Updates the information of an user in the minimap. /// </summary> /// <param name="userInfo">User info model</param> /// <param name="isRemoved">True for remove the user info</param> public void UpdateMinimapUserInformation(MinimapMetadata.MinimapUserInfo userInfo, bool isRemoved = false) { if (string.IsNullOrEmpty(userInfo.userId)) { return; } if (!isRemoved) { minimapMetadata.AddOrUpdateUserInfo(userInfo); } else { minimapMetadata.RemoveUserInfo(userInfo.userId); } }
void MapRenderer_OnUserInfoUpdated(MinimapMetadata.MinimapUserInfo userInfo) { usersListView.AddOrUpdateUser(userInfo); if (!trackedUsersHashSet.Contains(userInfo.userId)) { trackedUsersHashSet.Add(userInfo.userId); bool isMuted = profile.muted.Contains(userInfo.userId); usersListView.SetUserMuted(userInfo.userId, isMuted); if (isMuteAll && !isMuted) { OnMuteUser(userInfo.userId, true); } } usersButtonView?.SetUsersCount(trackedUsersHashSet.Count); }
void IUsersAroundListHUDListView.AddOrUpdateUser(MinimapMetadata.MinimapUserInfo userInfo) { if (userElementDictionary.ContainsKey(userInfo.userId)) { return; } var profile = UserProfileController.userProfilesCatalog.Get(userInfo.userId); if (profile == null) { return; } bool isFriend = false; if (FriendsController.i && FriendsController.i.friends.TryGetValue(userInfo.userId, out FriendsController.UserStatus status)) { isFriend = status.friendshipStatus == FriendshipStatus.FRIEND; } UsersAroundListHUDListElementView view = null; if (availableElements.Count > 0) { view = availableElements.Dequeue(); view.transform.SetParent(isFriend ? contentFriends : contentPlayers); } else { view = Instantiate(listElementView, isFriend ? contentFriends : contentPlayers); view.OnMuteUser += OnMuteUser; view.OnShowUserContexMenu += OnUserContextMenu; } view.OnPoolGet(); view.SetUserProfile(profile); userElementDictionary.Add(userInfo.userId, view); ModifyListCount(isFriend, 1); }
public IEnumerator DisplayAndUpdateUserIconProperly() { Vector3 initialPosition = new Vector3(100, 0, 50); Vector3 modifiedPosition = new Vector3(150, 0, -30); var userInfo = new MinimapMetadata.MinimapUserInfo(); userInfo.userId = "testuser"; userInfo.worldPosition = initialPosition; // Create an user icon MinimapMetadata.GetMetadata().AddOrUpdateUserInfo(userInfo); MapSceneIcon[] icons = MapRenderer.i.GetComponentsInChildren <MapSceneIcon>(); Assert.AreEqual(1, icons.Length, "There should be only 1 user icon"); Vector2 iconGridPosition = DCL.Helpers.Utils.WorldToGridPositionUnclamped(initialPosition); Assert.AreEqual(DCL.Helpers.MapUtils.GetTileToLocalPosition(iconGridPosition.x, iconGridPosition.y), icons[0].transform.localPosition); // Modifify the position of the user icon userInfo.worldPosition = modifiedPosition; MinimapMetadata.GetMetadata().AddOrUpdateUserInfo(userInfo); icons = MapRenderer.i.GetComponentsInChildren <MapSceneIcon>(); Assert.AreEqual(1, icons.Length, "There should still be the same user icon"); iconGridPosition = DCL.Helpers.Utils.WorldToGridPositionUnclamped(modifiedPosition); Assert.AreEqual(DCL.Helpers.MapUtils.GetTileToLocalPosition(iconGridPosition.x, iconGridPosition.y), icons[0].transform.localPosition); // Remove the user icon MinimapMetadata.GetMetadata().RemoveUserInfo(userInfo.userId); icons = MapRenderer.i.GetComponentsInChildren <MapSceneIcon>(); Assert.AreEqual(0, icons.Length, "There should not be any user icon"); yield return(null); }
private void MapRenderer_OnUserInfoUpdated(MinimapMetadata.MinimapUserInfo userInfo) { if (usersInfo.TryGetValue(userInfo.userId, out MinimapMetadata.MinimapUserInfo existingUserInfo)) { existingUserInfo = userInfo; if (usersInfoMarkers.TryGetValue(userInfo.userId, out PoolableObject go)) { ConfigureUserIcon(go.gameObject, userInfo.worldPosition, userInfo.userName); } } else { usersInfo.Add(userInfo.userId, userInfo); PoolableObject newUserIcon = usersInfoPool.Get(); newUserIcon.gameObject.name = string.Format("UserIcon-{0}", userInfo.userName); newUserIcon.gameObject.transform.parent = overlayContainer.transform; newUserIcon.gameObject.transform.localScale = Vector3.one; ConfigureUserIcon(newUserIcon.gameObject, userInfo.worldPosition, userInfo.userName); usersInfoMarkers.Add(userInfo.userId, newUserIcon); } }