public override IEnumerator ApplyChanges(string newJson) { //NOTE(Brian): Horrible fix to the double ApplyChanges call, as its breaking the needed logic. if (newJson == "{}") { yield break; } if (entity != null && entity.OnTransformChange == null) { entity.OnTransformChange += avatarMovementController.OnTransformChanged; entity.OnTransformChange += OnEntityTransformChanged; } if (currentSerialization == newJson) { yield break; } model = SceneController.i.SafeFromJson <AvatarModel>(newJson); everythingIsLoaded = false; bool avatarDone = false; bool avatarFailed = false; yield return(null); //NOTE(Brian): just in case we have a Object.Destroy waiting to be resolved. avatarRenderer.ApplyModel(model, () => avatarDone = true, () => avatarFailed = true); yield return(new WaitUntil(() => avatarDone || avatarFailed)); avatarName.SetName(model.name); SetMinimapRepresentationActive(true); everythingIsLoaded = true; onPointerDown.collider.enabled = true; avatarUserInfo.userId = model.id; avatarUserInfo.userName = model.name; avatarUserInfo.worldPosition = lastAvatarPosition != null ? lastAvatarPosition.Value : minimapRepresentation.transform.position; MinimapMetadataController.i?.UpdateMinimapUserInformation(avatarUserInfo); }
public override IEnumerator ApplyChanges(string newJson) { //NOTE(Brian): Horrible fix to the double ApplyChanges call, as its breaking the needed logic. if (newJson == "{}") { yield break; } if (currentSerialization == newJson) { yield break; } DisablePassport(); model = Utils.SafeFromJson <AvatarModel>(newJson); everythingIsLoaded = false; bool avatarDone = false; bool avatarFailed = false; yield return(null); //NOTE(Brian): just in case we have a Object.Destroy waiting to be resolved. avatarRenderer.ApplyModel(model, () => avatarDone = true, () => avatarFailed = true); yield return(new WaitUntil(() => avatarDone || avatarFailed)); onPointerDown.Setup(scene, entity, new OnPointerDown.Model() { type = OnPointerDown.NAME, button = WebInterface.ACTION_BUTTON.POINTER.ToString(), hoverText = "view profile" }); CommonScriptableObjects.worldOffset.OnChange -= OnWorldReposition; CommonScriptableObjects.worldOffset.OnChange += OnWorldReposition; entity.OnTransformChange -= avatarMovementController.OnTransformChanged; entity.OnTransformChange += avatarMovementController.OnTransformChanged; entity.OnTransformChange -= OnEntityTransformChanged; entity.OnTransformChange += OnEntityTransformChanged; onPointerDown.OnPointerDownReport -= PlayerClicked; onPointerDown.OnPointerDownReport += PlayerClicked; // To deal with the cases in which the entity transform was configured before the AvatarShape if (!initializedPosition && entity.components.ContainsKey(DCL.Models.CLASS_ID_COMPONENT.TRANSFORM)) { initializedPosition = true; avatarMovementController.MoveTo( entity.gameObject.transform.localPosition - Vector3.up * DCLCharacterController.i.characterController.height / 2, entity.gameObject.transform.localRotation, true); } avatarUserInfo.userId = model.id; avatarUserInfo.userName = model.name; avatarUserInfo.worldPosition = lastAvatarPosition != null ? lastAvatarPosition.Value : entity.gameObject.transform.localPosition; MinimapMetadataController.i?.UpdateMinimapUserInformation(avatarUserInfo); avatarName.SetName(model.name); avatarName.SetTalking(model.talking); avatarCollider.gameObject.SetActive(true); everythingIsLoaded = true; OnAvatarShapeUpdated?.Invoke(entity, this); EnablePassport(); }