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