| | 1 | | using System; |
| | 2 | | using DCL.Components; |
| | 3 | | using DCL.Interface; |
| | 4 | | using System.Collections; |
| | 5 | | using System.Collections.Generic; |
| | 6 | | using System.Linq; |
| | 7 | | using System.Threading; |
| | 8 | | using AvatarSystem; |
| | 9 | | using DCL.Configuration; |
| | 10 | | using DCL.Controllers; |
| | 11 | | using DCL.Emotes; |
| | 12 | | using DCL.Helpers; |
| | 13 | | using DCL.Models; |
| | 14 | | using UnityEngine; |
| | 15 | | using LOD = AvatarSystem.LOD; |
| | 16 | |
|
| | 17 | | namespace DCL |
| | 18 | | { |
| | 19 | | public class AvatarShape : BaseComponent, IHideAvatarAreaHandler, IHidePassportAreaHandler, IOutOfSceneBoundariesHan |
| | 20 | | { |
| | 21 | | private const string CURRENT_PLAYER_ID = "CurrentPlayerInfoCardId"; |
| | 22 | | private const float MINIMUM_PLAYERNAME_HEIGHT = 2.7f; |
| | 23 | | private const float AVATAR_PASSPORT_TOGGLE_ALPHA_THRESHOLD = 0.9f; |
| | 24 | | private const string VISIBILITY_CONSTRAINT_HIDE_AREA = "IN_HIDE_AREA"; |
| | 25 | | private const string VISIBILITY_CONSTRAINT_OUTSIDE_SCENE_BOUNDS = "OUTSIDE_SCENE_BOUNDS"; |
| | 26 | |
|
| | 27 | | public static event Action<IDCLEntity, AvatarShape> OnAvatarShapeUpdated; |
| | 28 | |
|
| | 29 | | public GameObject avatarContainer; |
| | 30 | | public Collider avatarCollider; |
| | 31 | | public AvatarMovementController avatarMovementController; |
| | 32 | | public StickersController stickersControllers; |
| | 33 | | [SerializeField] private Transform avatarRevealContainer; |
| | 34 | | [SerializeField] private GameObject armatureContainer; |
| | 35 | |
|
| | 36 | | [SerializeField] internal AvatarOnPointerDown onPointerDown; |
| | 37 | | [SerializeField] internal AvatarOutlineOnHoverEvent outlineOnHover; |
| | 38 | | [SerializeField] internal GameObject playerNameContainer; |
| | 39 | | internal IPlayerName playerName; |
| | 40 | | internal IAvatarReporterController avatarReporterController; |
| | 41 | |
|
| | 42 | | private StringVariable currentPlayerInfoCardId; |
| | 43 | |
|
| | 44 | | public bool everythingIsLoaded; |
| | 45 | |
|
| | 46 | | bool initializedPosition = false; |
| | 47 | |
|
| | 48 | | private Player player = null; |
| 0 | 49 | | private BaseDictionary<string, Player> otherPlayers => DataStore.i.player.otherPlayers; |
| | 50 | |
|
| 328 | 51 | | private IAvatarAnchorPoints anchorPoints = new AvatarAnchorPoints(); |
| | 52 | | internal IAvatar avatar; |
| 328 | 53 | | private readonly AvatarModel currentAvatar = new AvatarModel { wearables = new List<string>() }; |
| | 54 | | private CancellationTokenSource loadingCts; |
| | 55 | | private ILazyTextureObserver currentLazyObserver; |
| 328 | 56 | | private bool isGlobalSceneAvatar = true; |
| | 57 | | private BaseRefCounter<AvatarModifierAreaID> currentActiveModifiers; |
| | 58 | | private IUserProfileBridge userProfileBridge; |
| | 59 | |
|
| 4 | 60 | | public override string componentName => "avatarShape"; |
| | 61 | |
|
| | 62 | | private void Awake() |
| | 63 | | { |
| 325 | 64 | | model = new AvatarModel(); |
| 325 | 65 | | currentPlayerInfoCardId = Resources.Load<StringVariable>(CURRENT_PLAYER_ID); |
| | 66 | | // TODO: user profile bridge should be retrieved from the service locator |
| 325 | 67 | | userProfileBridge = new UserProfileWebInterfaceBridge(); |
| | 68 | |
|
| 325 | 69 | | if (DataStore.i.avatarConfig.useHologramAvatar.Get()) |
| 2 | 70 | | avatar = GetAvatarWithHologram(); |
| | 71 | | else |
| 323 | 72 | | avatar = GetStandardAvatar(); |
| | 73 | |
|
| 325 | 74 | | if (avatarReporterController == null) |
| | 75 | | { |
| 325 | 76 | | avatarReporterController = new AvatarReporterController(Environment.i.world.state); |
| | 77 | | } |
| 325 | 78 | | } |
| | 79 | |
|
| | 80 | | public override void Initialize(IParcelScene scene, IDCLEntity entity) |
| | 81 | | { |
| 5 | 82 | | base.Initialize(scene, entity); |
| 5 | 83 | | DataStore.i.sceneBoundariesChecker?.Add(entity,this); |
| 5 | 84 | | } |
| | 85 | |
|
| | 86 | | private IAvatar GetStandardAvatar() |
| | 87 | | { |
| 323 | 88 | | var visibility = new Visibility(); |
| | 89 | |
|
| 323 | 90 | | return Environment.i.serviceLocator.Get<IAvatarFactory>() |
| | 91 | | .CreateAvatar( |
| | 92 | | avatarContainer, |
| | 93 | | GetComponentInChildren<AvatarAnimatorLegacy>(), |
| | 94 | | new LOD(avatarContainer, visibility, avatarMovementController), |
| | 95 | | visibility |
| | 96 | | ); |
| | 97 | | } |
| | 98 | |
|
| | 99 | | private IAvatar GetAvatarWithHologram() |
| | 100 | | { |
| 2 | 101 | | Visibility visibility = new Visibility(); |
| | 102 | |
|
| 2 | 103 | | return Environment.i.serviceLocator.Get<IAvatarFactory>() |
| | 104 | | .CreateAvatarWithHologram( |
| | 105 | | avatarContainer, |
| | 106 | | avatarRevealContainer, |
| | 107 | | armatureContainer, |
| | 108 | | GetComponentInChildren<AvatarAnimatorLegacy>(), |
| | 109 | | new LOD(avatarContainer, visibility, avatarMovementController), |
| | 110 | | visibility |
| | 111 | | ); |
| | 112 | | } |
| | 113 | |
|
| | 114 | | private void Start() |
| | 115 | | { |
| 1 | 116 | | playerName = GetComponentInChildren<IPlayerName>(); |
| 1 | 117 | | playerName?.Hide(true); |
| 1 | 118 | | currentActiveModifiers ??= new BaseRefCounter<AvatarModifierAreaID>(); |
| 1 | 119 | | } |
| | 120 | |
|
| | 121 | | private void PlayerClicked() |
| | 122 | | { |
| 0 | 123 | | if (model == null) |
| 0 | 124 | | return; |
| 0 | 125 | | currentPlayerInfoCardId.Set(((AvatarModel) model).id); |
| 0 | 126 | | } |
| | 127 | |
|
| | 128 | | public void OnDestroy() |
| | 129 | | { |
| 325 | 130 | | if(entity != null) |
| 0 | 131 | | DataStore.i.sceneBoundariesChecker?.Remove(entity,this); |
| | 132 | |
|
| 325 | 133 | | Cleanup(); |
| | 134 | |
|
| 325 | 135 | | if (poolableObject != null && poolableObject.isInsidePool) |
| 5 | 136 | | poolableObject.RemoveFromPool(); |
| 325 | 137 | | } |
| | 138 | |
|
| | 139 | | public override IEnumerator ApplyChanges(BaseModel newModel) |
| | 140 | | { |
| 5 | 141 | | isGlobalSceneAvatar = scene.sceneData.sceneNumber == EnvironmentSettings.AVATAR_GLOBAL_SCENE_NUMBER; |
| | 142 | |
|
| 5 | 143 | | var model = (AvatarModel) newModel; |
| | 144 | |
|
| 5 | 145 | | bool needsLoading = !model.HaveSameWearablesAndColors(currentAvatar); |
| 5 | 146 | | currentAvatar.CopyFrom(model); |
| | 147 | |
|
| 5 | 148 | | if (string.IsNullOrEmpty(model.bodyShape) || model.wearables.Count == 0) |
| 1 | 149 | | yield break; |
| | 150 | | #if UNITY_EDITOR |
| 4 | 151 | | gameObject.name = $"Avatar Shape {model.name}"; |
| | 152 | | #endif |
| 4 | 153 | | everythingIsLoaded = false; |
| | 154 | |
|
| | 155 | | bool avatarDone = false; |
| | 156 | | bool avatarFailed = false; |
| | 157 | |
|
| 4 | 158 | | yield return null; //NOTE(Brian): just in case we have a Object.Destroy waiting to be resolved. |
| | 159 | |
|
| | 160 | | // To deal with the cases in which the entity transform was configured before the AvatarShape |
| 0 | 161 | | if (!initializedPosition && scene.componentsManagerLegacy.HasComponent(entity, CLASS_ID_COMPONENT.TRANSFORM) |
| | 162 | | { |
| 0 | 163 | | initializedPosition = true; |
| 0 | 164 | | OnEntityTransformChanged(entity.gameObject.transform.localPosition, |
| | 165 | | entity.gameObject.transform.localRotation, true); |
| | 166 | | } |
| | 167 | |
|
| | 168 | | // NOTE: we subscribe here to transform changes since we might "lose" the message |
| | 169 | | // if we subscribe after a any yield |
| 0 | 170 | | entity.OnTransformChange -= OnEntityTransformChanged; |
| 0 | 171 | | entity.OnTransformChange += OnEntityTransformChanged; |
| | 172 | |
|
| 0 | 173 | | var wearableItems = model.wearables.ToList(); |
| 0 | 174 | | wearableItems.Add(model.bodyShape); |
| | 175 | |
|
| 0 | 176 | | if (avatar.status != IAvatar.Status.Loaded || needsLoading) |
| | 177 | | { |
| 0 | 178 | | HashSet<string> emotes = new HashSet<string>(currentAvatar.emotes.Select(x => x.urn)); |
| 0 | 179 | | var embeddedEmotesSo = Resources.Load<EmbeddedEmotesSO>("EmbeddedEmotes"); |
| 0 | 180 | | var embeddedEmoteIds = embeddedEmotesSo.emotes.Select(x => x.id); |
| | 181 | | //here we add emote ids to both new and old emote loading flow to merge the results later |
| | 182 | | //because some users might have emotes as wearables and others only as emotes |
| 0 | 183 | | foreach (var emoteId in embeddedEmoteIds) |
| | 184 | | { |
| 0 | 185 | | emotes.Add(emoteId); |
| 0 | 186 | | wearableItems.Add(emoteId); |
| | 187 | | } |
| | 188 | |
|
| | 189 | | //TODO Add Collider to the AvatarSystem |
| | 190 | | //TODO Without this the collider could get triggered disabling the avatar container, |
| | 191 | | // this would stop the loading process due to the underlying coroutines of the AssetLoader not starting |
| 0 | 192 | | avatarCollider.gameObject.SetActive(false); |
| | 193 | |
|
| 0 | 194 | | SetImpostor(model.id); |
| 0 | 195 | | loadingCts?.Cancel(); |
| 0 | 196 | | loadingCts?.Dispose(); |
| 0 | 197 | | loadingCts = new CancellationTokenSource(); |
| 0 | 198 | | if (DataStore.i.avatarConfig.useHologramAvatar.Get()) |
| | 199 | | { |
| 0 | 200 | | UserProfile profile = userProfileBridge.Get(model.id); |
| 0 | 201 | | playerName.SetName(model.name, profile?.hasClaimedName ?? false, profile?.isGuest ?? false); |
| 0 | 202 | | playerName.Show(true); |
| | 203 | | } |
| | 204 | |
|
| 0 | 205 | | avatar.Load(wearableItems, emotes.ToList(), new AvatarSettings |
| | 206 | | { |
| | 207 | | playerName = model.name, |
| | 208 | | bodyshapeId = model.bodyShape, |
| | 209 | | eyesColor = model.eyeColor, |
| | 210 | | skinColor = model.skinColor, |
| | 211 | | hairColor = model.hairColor, |
| | 212 | | }, loadingCts.Token); |
| | 213 | |
|
| | 214 | | // Yielding a UniTask doesn't do anything, we manually wait until the avatar is ready |
| 0 | 215 | | yield return new WaitUntil(() => avatar.status == IAvatar.Status.Loaded); |
| | 216 | | } |
| | 217 | |
|
| 0 | 218 | | avatar.PlayEmote(model.expressionTriggerId, model.expressionTriggerTimestamp); |
| | 219 | |
|
| 0 | 220 | | onPointerDown.OnPointerDownReport -= PlayerClicked; |
| 0 | 221 | | onPointerDown.OnPointerDownReport += PlayerClicked; |
| 0 | 222 | | onPointerDown.OnPointerEnterReport -= PlayerPointerEnter; |
| 0 | 223 | | onPointerDown.OnPointerEnterReport += PlayerPointerEnter; |
| 0 | 224 | | onPointerDown.OnPointerExitReport -= PlayerPointerExit; |
| 0 | 225 | | onPointerDown.OnPointerExitReport += PlayerPointerExit; |
| | 226 | |
|
| 0 | 227 | | outlineOnHover.OnPointerEnterReport -= PlayerPointerEnter; |
| 0 | 228 | | outlineOnHover.OnPointerEnterReport += PlayerPointerEnter; |
| 0 | 229 | | outlineOnHover.OnPointerExitReport -= PlayerPointerExit; |
| 0 | 230 | | outlineOnHover.OnPointerExitReport += PlayerPointerExit; |
| | 231 | |
|
| 0 | 232 | | UpdatePlayerStatus(model); |
| | 233 | |
|
| 0 | 234 | | onPointerDown.Initialize( |
| | 235 | | new OnPointerDown.Model() |
| | 236 | | { |
| | 237 | | type = OnPointerDown.NAME, |
| | 238 | | button = WebInterface.ACTION_BUTTON.POINTER.ToString(), |
| | 239 | | hoverText = "View Profile" |
| | 240 | | }, |
| | 241 | | entity, player |
| | 242 | | ); |
| | 243 | |
|
| 0 | 244 | | outlineOnHover.Initialize(new OnPointerDown.Model(), entity, player.avatar); |
| | 245 | |
|
| 0 | 246 | | avatarCollider.gameObject.SetActive(true); |
| | 247 | |
|
| 0 | 248 | | everythingIsLoaded = true; |
| 0 | 249 | | OnAvatarShapeUpdated?.Invoke(entity, this); |
| | 250 | |
|
| 0 | 251 | | onPointerDown.SetColliderEnabled(isGlobalSceneAvatar); |
| 0 | 252 | | onPointerDown.SetOnClickReportEnabled(isGlobalSceneAvatar); |
| 0 | 253 | | } |
| | 254 | |
|
| | 255 | | public void SetImpostor(string userId) |
| | 256 | | { |
| 0 | 257 | | currentLazyObserver?.RemoveListener(avatar.SetImpostorTexture); |
| 0 | 258 | | if (string.IsNullOrEmpty(userId)) |
| 0 | 259 | | return; |
| | 260 | |
|
| 0 | 261 | | UserProfile userProfile = UserProfileController.GetProfileByUserId(userId); |
| 0 | 262 | | if (userProfile == null) |
| 0 | 263 | | return; |
| | 264 | |
|
| 0 | 265 | | currentLazyObserver = userProfile.bodySnapshotObserver; |
| 0 | 266 | | currentLazyObserver.AddListener(avatar.SetImpostorTexture); |
| 0 | 267 | | } |
| | 268 | |
|
| | 269 | | private void PlayerPointerExit() |
| | 270 | | { |
| 0 | 271 | | playerName?.SetForceShow(false); |
| 0 | 272 | | } |
| | 273 | |
|
| | 274 | | private void PlayerPointerEnter() |
| | 275 | | { |
| 0 | 276 | | playerName?.SetForceShow(true); |
| 0 | 277 | | } |
| | 278 | |
|
| | 279 | | private void UpdatePlayerStatus(AvatarModel model) |
| | 280 | | { |
| | 281 | | // Remove the player status if the userId changes |
| 0 | 282 | | if (player != null && (player.id != model.id || player.name != model.name)) |
| 0 | 283 | | otherPlayers.Remove(player.id); |
| | 284 | |
|
| 0 | 285 | | if (isGlobalSceneAvatar && string.IsNullOrEmpty(model?.id)) |
| 0 | 286 | | return; |
| | 287 | |
|
| 0 | 288 | | bool isNew = player == null; |
| 0 | 289 | | if (isNew) |
| | 290 | | { |
| 0 | 291 | | player = new Player(); |
| | 292 | | } |
| | 293 | |
|
| 0 | 294 | | bool isNameDirty = player.name != model.name; |
| | 295 | |
|
| 0 | 296 | | player.id = model.id; |
| 0 | 297 | | player.name = model.name; |
| 0 | 298 | | player.isTalking = model.talking; |
| 0 | 299 | | player.worldPosition = entity.gameObject.transform.position; |
| 0 | 300 | | player.avatar = avatar; |
| 0 | 301 | | player.onPointerDownCollider = onPointerDown; |
| 0 | 302 | | player.collider = avatarCollider; |
| | 303 | |
|
| 0 | 304 | | if (isNew) |
| | 305 | | { |
| 0 | 306 | | player.playerName = playerName; |
| 0 | 307 | | player.playerName.Show(); |
| 0 | 308 | | player.anchorPoints = anchorPoints; |
| 0 | 309 | | if (isGlobalSceneAvatar) |
| | 310 | | { |
| | 311 | | // TODO: Note: This is having a problem, sometimes the users has been detected as new 2 times and it |
| | 312 | | // we should investigate this |
| 0 | 313 | | if (otherPlayers.ContainsKey(player.id)) |
| 0 | 314 | | otherPlayers.Remove(player.id); |
| 0 | 315 | | otherPlayers.Add(player.id, player); |
| | 316 | | } |
| 0 | 317 | | avatarReporterController.ReportAvatarRemoved(); |
| | 318 | | } |
| | 319 | |
|
| 0 | 320 | | avatarReporterController.SetUp(entity.scene.sceneData.sceneNumber, player.id); |
| | 321 | |
|
| 0 | 322 | | float height = AvatarSystemUtils.AVATAR_Y_OFFSET + avatar.extents.y; |
| | 323 | |
|
| 0 | 324 | | anchorPoints.Prepare(avatarContainer.transform, avatar.GetBones(), height); |
| | 325 | |
|
| 0 | 326 | | player.playerName.SetIsTalking(model.talking); |
| 0 | 327 | | player.playerName.SetYOffset(Mathf.Max(MINIMUM_PLAYERNAME_HEIGHT, height)); |
| | 328 | |
|
| 0 | 329 | | if (isNameDirty) |
| | 330 | | { |
| 0 | 331 | | UserProfile profile = userProfileBridge.Get(model.id); |
| 0 | 332 | | player.playerName.SetName(model.name, profile?.hasClaimedName ?? false, profile?.isGuest ?? false); |
| | 333 | | } |
| 0 | 334 | | } |
| | 335 | |
|
| | 336 | | private void Update() |
| | 337 | | { |
| 1 | 338 | | if (player != null) |
| | 339 | | { |
| 0 | 340 | | player.worldPosition = entity.gameObject.transform.position; |
| 0 | 341 | | player.forwardDirection = entity.gameObject.transform.forward; |
| 0 | 342 | | avatarReporterController.ReportAvatarPosition(player.worldPosition); |
| | 343 | | } |
| 1 | 344 | | } |
| | 345 | |
|
| | 346 | | private void OnEntityTransformChanged(object newModel) |
| | 347 | | { |
| 0 | 348 | | DCLTransform.Model newTransformModel = (DCLTransform.Model)newModel; |
| 0 | 349 | | OnEntityTransformChanged(newTransformModel.position, newTransformModel.rotation, !initializedPosition); |
| 0 | 350 | | } |
| | 351 | |
|
| | 352 | | private void OnEntityTransformChanged(in Vector3 position, in Quaternion rotation, bool inmediate) |
| | 353 | | { |
| 0 | 354 | | if (isGlobalSceneAvatar) |
| | 355 | | { |
| 0 | 356 | | avatarMovementController.OnTransformChanged(position, rotation, inmediate); |
| | 357 | | } |
| | 358 | | else |
| | 359 | | { |
| 0 | 360 | | var scenePosition = Utils.GridToWorldPosition(entity.scene.sceneData.basePosition.x, entity.scene.sceneD |
| 0 | 361 | | avatarMovementController.OnTransformChanged(scenePosition + position, rotation, inmediate); |
| | 362 | | } |
| 0 | 363 | | initializedPosition = true; |
| 0 | 364 | | } |
| | 365 | |
|
| | 366 | | public override void OnPoolGet() |
| | 367 | | { |
| 5 | 368 | | base.OnPoolGet(); |
| | 369 | |
|
| 5 | 370 | | everythingIsLoaded = false; |
| 5 | 371 | | initializedPosition = false; |
| 5 | 372 | | model = new AvatarModel(); |
| 5 | 373 | | player = null; |
| 5 | 374 | | } |
| | 375 | |
|
| | 376 | | public void ApplyHideAvatarModifier() |
| | 377 | | { |
| 0 | 378 | | if (!currentActiveModifiers.ContainsKey(AvatarModifierAreaID.HIDE_AVATAR)) |
| | 379 | | { |
| 0 | 380 | | avatar.AddVisibilityConstraint(VISIBILITY_CONSTRAINT_HIDE_AREA); |
| 0 | 381 | | onPointerDown.gameObject.SetActive(false); |
| 0 | 382 | | playerNameContainer.SetActive(false); |
| 0 | 383 | | stickersControllers.ToggleHideArea(true); |
| | 384 | | } |
| 0 | 385 | | currentActiveModifiers.AddRefCount(AvatarModifierAreaID.HIDE_AVATAR); |
| 0 | 386 | | } |
| | 387 | |
|
| | 388 | | public void RemoveHideAvatarModifier() |
| | 389 | | { |
| 0 | 390 | | currentActiveModifiers.RemoveRefCount(AvatarModifierAreaID.HIDE_AVATAR); |
| 0 | 391 | | if (!currentActiveModifiers.ContainsKey(AvatarModifierAreaID.HIDE_AVATAR)) |
| | 392 | | { |
| 0 | 393 | | avatar.RemoveVisibilityConstrain(VISIBILITY_CONSTRAINT_HIDE_AREA); |
| 0 | 394 | | onPointerDown.gameObject.SetActive(true); |
| 0 | 395 | | playerNameContainer.SetActive(true); |
| 0 | 396 | | stickersControllers.ToggleHideArea(false); |
| | 397 | | } |
| 0 | 398 | | } |
| | 399 | |
|
| | 400 | | public void ApplyHidePassportModifier() |
| | 401 | | { |
| 0 | 402 | | if (!currentActiveModifiers.ContainsKey(AvatarModifierAreaID.DISABLE_PASSPORT)) |
| | 403 | | { |
| 0 | 404 | | DisablePassport(); |
| | 405 | | } |
| 0 | 406 | | currentActiveModifiers.AddRefCount(AvatarModifierAreaID.DISABLE_PASSPORT); |
| 0 | 407 | | } |
| | 408 | |
|
| | 409 | | public void RemoveHidePassportModifier() |
| | 410 | | { |
| 0 | 411 | | currentActiveModifiers.RemoveRefCount(AvatarModifierAreaID.DISABLE_PASSPORT); |
| 0 | 412 | | if (!currentActiveModifiers.ContainsKey(AvatarModifierAreaID.DISABLE_PASSPORT)) |
| | 413 | | { |
| 0 | 414 | | EnablePasssport(); |
| | 415 | | } |
| 0 | 416 | | } |
| | 417 | |
|
| | 418 | | private void EnablePasssport() |
| | 419 | | { |
| 0 | 420 | | if (onPointerDown.collider == null) |
| 0 | 421 | | return; |
| | 422 | |
|
| 0 | 423 | | onPointerDown.SetPassportEnabled(true); |
| 0 | 424 | | } |
| | 425 | |
|
| | 426 | | private void DisablePassport() |
| | 427 | | { |
| 0 | 428 | | if (onPointerDown.collider == null) |
| 0 | 429 | | return; |
| | 430 | |
|
| 0 | 431 | | onPointerDown.SetPassportEnabled(false); |
| 0 | 432 | | } |
| | 433 | |
|
| | 434 | | public override void Cleanup() |
| | 435 | | { |
| 335 | 436 | | base.Cleanup(); |
| | 437 | |
|
| 335 | 438 | | playerName?.Hide(true); |
| 335 | 439 | | if (player != null) |
| | 440 | | { |
| | 441 | | // AvatarShape used from the SDK doesn't register the avatars in 'otherPlayers' |
| 0 | 442 | | if(!string.IsNullOrEmpty(player.id)) |
| 0 | 443 | | otherPlayers.Remove(player.id); |
| 0 | 444 | | player = null; |
| | 445 | | } |
| | 446 | |
|
| 335 | 447 | | loadingCts?.Cancel(); |
| 335 | 448 | | loadingCts?.Dispose(); |
| 335 | 449 | | loadingCts = null; |
| 335 | 450 | | currentLazyObserver?.RemoveListener(avatar.SetImpostorTexture); |
| 335 | 451 | | avatar.Dispose(); |
| | 452 | |
|
| 335 | 453 | | if (poolableObject != null) |
| | 454 | | { |
| 15 | 455 | | poolableObject.OnRelease -= Cleanup; |
| | 456 | | } |
| | 457 | |
|
| 335 | 458 | | onPointerDown.OnPointerDownReport -= PlayerClicked; |
| 335 | 459 | | onPointerDown.OnPointerEnterReport -= PlayerPointerEnter; |
| 335 | 460 | | onPointerDown.OnPointerExitReport -= PlayerPointerExit; |
| 335 | 461 | | outlineOnHover.OnPointerEnterReport -= PlayerPointerEnter; |
| 335 | 462 | | outlineOnHover.OnPointerExitReport -= PlayerPointerExit; |
| | 463 | |
|
| 335 | 464 | | if (entity != null) |
| | 465 | | { |
| 5 | 466 | | entity.OnTransformChange = null; |
| 5 | 467 | | entity = null; |
| | 468 | | } |
| | 469 | |
|
| 335 | 470 | | avatarReporterController.ReportAvatarRemoved(); |
| 335 | 471 | | } |
| | 472 | |
|
| | 473 | | public void UpdateOutOfBoundariesState(bool isInsideBoundaries) |
| | 474 | | { |
| 1 | 475 | | if (scene.isPersistent) |
| 0 | 476 | | isInsideBoundaries = true; |
| | 477 | |
|
| 1 | 478 | | if(isInsideBoundaries) |
| 0 | 479 | | avatar.RemoveVisibilityConstrain(VISIBILITY_CONSTRAINT_OUTSIDE_SCENE_BOUNDS); |
| | 480 | | else |
| 1 | 481 | | avatar.AddVisibilityConstraint(VISIBILITY_CONSTRAINT_OUTSIDE_SCENE_BOUNDS); |
| | 482 | |
|
| 1 | 483 | | onPointerDown.gameObject.SetActive(isInsideBoundaries); |
| 1 | 484 | | playerNameContainer.SetActive(isInsideBoundaries); |
| 1 | 485 | | stickersControllers.ToggleHideArea(!isInsideBoundaries); |
| 1 | 486 | | } |
| | 487 | |
|
| 1 | 488 | | public override int GetClassId() { return (int) CLASS_ID_COMPONENT.AVATAR_SHAPE; } |
| | 489 | |
|
| | 490 | | [ContextMenu("Print current profile")] |
| 0 | 491 | | private void PrintCurrentProfile() { Debug.Log(JsonUtility.ToJson(model)); } |
| | 492 | |
|
| | 493 | | } |
| | 494 | | } |