private void setAfkProp(PropDefinition propDefinition) { if (propDefinition == null) { } DHeldObject dHeldObject = new DHeldObject(); switch (propDefinition.PropType) { case PropDefinition.PropTypes.Consumable: dHeldObject.ObjectType = HeldObjectType.CONSUMABLE; break; case PropDefinition.PropTypes.Durable: dHeldObject.ObjectType = HeldObjectType.DURABLE; break; case PropDefinition.PropTypes.InteractiveObject: dHeldObject.ObjectType = HeldObjectType.DISPENSABLE; break; case PropDefinition.PropTypes.PartyGame: dHeldObject.ObjectType = HeldObjectType.PARTYGAME; break; } dHeldObject.ObjectId = propDefinition.NameOnServer; if (AvatarDataHandle.TryGetPlayerHandle(base.gameObject, out var handle)) { dataEntityCollection.GetComponent <HeldObjectsData>(handle).HeldObject = dHeldObject; isUsingAFKProp = true; } }
private void clearAfkProp() { if (AvatarDataHandle.TryGetPlayerHandle(base.gameObject, out var handle)) { if (presenceData.AFKState.EquippedObject != null) { DHeldObject dHeldObject = new DHeldObject(); dHeldObject.ObjectId = presenceData.AFKState.EquippedObject.EquippedObjectId; if (presenceData.AFKState.EquippedObject.IsConsumable()) { dHeldObject.ObjectType = HeldObjectType.CONSUMABLE; } else if (presenceData.AFKState.EquippedObject.IsDurable()) { dHeldObject.ObjectType = HeldObjectType.DURABLE; } else if (presenceData.AFKState.EquippedObject.IsDispensable()) { dHeldObject.ObjectType = HeldObjectType.DISPENSABLE; } else if (presenceData.AFKState.EquippedObject.isPartyGame()) { dHeldObject.ObjectType = HeldObjectType.PARTYGAME; } dataEntityCollection.GetComponent <HeldObjectsData>(handle).HeldObject = dHeldObject; } else { dataEntityCollection.GetComponent <HeldObjectsData>(handle).HeldObject = null; } } isUsingAFKProp = false; }
private bool onLocomotionDataAdded(DataEntityEvents.ComponentAddedEvent <LocomotionData> evt) { if (AvatarDataHandle.TryGetPlayerHandle(base.gameObject, out var handle) && evt.Handle == handle) { dataEntityCollection.EventDispatcher.RemoveListener <DataEntityEvents.ComponentAddedEvent <LocomotionData> >(onLocomotionDataAdded); locomotionData = evt.Component; addListeners(); } return(false); }
private bool onAvatarDetailsAdded(DataEntityEvents.ComponentAddedEvent <AvatarDetailsData> evt) { if (AvatarDataHandle.TryGetPlayerHandle(base.gameObject, out var handle) && evt.Handle == handle) { dataEntityCollection.EventDispatcher.RemoveListener <DataEntityEvents.ComponentAddedEvent <AvatarDetailsData> >(onAvatarDetailsAdded); avatarDetailsData = evt.Component; processAvatarDetails(handle); } return(false); }
private void setupLocalPlayer() { DataEntityHandle localPlayerHandle = dataEntityCollection.LocalPlayerHandle; AvatarDataHandle avatarDataHandle = LocalPlayerGameObject.AddComponent <AvatarDataHandle>(); avatarDataHandle.SetHandle(localPlayerHandle, isLocalPlayer: true); GameObjectReferenceData gameObjectReferenceData = dataEntityCollection.AddComponent <GameObjectReferenceData>(localPlayerHandle); gameObjectReferenceData.GameObject = LocalPlayerGameObject; }
private void onLODGameObjectGenerated(GameObject remotePlayer, DataEntityHandle remotePlayerHandle, LODRequestData requestData) { requestData.OnGameObjectGeneratedEvent -= onLODGameObjectGenerated; remotePlayer.name = "rp_" + dataEntityCollection.GetComponent <DisplayNameData>(remotePlayerHandle).DisplayName; enableRenderers(remotePlayer, enable: false); remotePlayer.transform.SetParent(RemotePlayerContainer.transform); AvatarDataHandle component = remotePlayer.GetComponent <AvatarDataHandle>(); component.SetHandle(remotePlayerHandle); remotePlayer.GetComponent <LocomotionReceiver>().Init(); }
public static bool TryGetPlayerHandle(GameObject owner, out DataEntityHandle handle) { if (!owner.IsDestroyed()) { AvatarDataHandle component = owner.GetComponent <AvatarDataHandle>(); if (component != null) { handle = component.Handle; return(!handle.IsNull); } } handle = DataEntityHandle.NullHandle; return(false); }
private void Start() { dataEntityCollection = Service.Get <CPDataEntityCollection>(); playerDataHandle = GetComponent <AvatarDataHandle>(); eventDispatcher = Service.Get <EventDispatcher>(); if (!playerDataHandle.Handle.IsNull && dataEntityCollection.HasComponent <LocalPlayerInZoneData>(playerDataHandle.Handle)) { spawnLocalPlayerInZone(); } else { eventDispatcher.AddListener <PlayerSpawnedEvents.LocalPlayerReadyToSpawn>(onLocalPlayerReadyToSpawn, EventDispatcher.Priority.FIRST); } eventDispatcher.AddListener <SceneTransitionEvents.TransitionComplete>(onSceneTransitionComplete); }
private void Start() { dataEntityCollection = Service.Get <CPDataEntityCollection>(); if (AvatarDataHandle.TryGetPlayerHandle(base.gameObject, out var handle) && dataEntityCollection.TryGetComponent <PresenceData>(handle, out presenceData)) { presenceData.PresenceDataUpdated += onPresenceDataUpdated; if (presenceData.AFKState.Type != 0) { onPresenceDataUpdated(presenceData); } presenceData.TemporaryHeadStatusUpdated += onTemporaryHeadStatusUpdated; if (presenceData.TemporaryHeadStatusType != 0) { onTemporaryHeadStatusUpdated(presenceData); } } }
public void Start() { ConditionalConfiguration conditionalConfiguration = Service.Get <ConditionalConfiguration>(); Model.LodLevel = conditionalConfiguration.Get("AvatarSystem.LODLevel.property", 0); ZoneLocalPlayerManager zoneLocalPlayerManager = SceneRefs.ZoneLocalPlayerManager; isLocal = zoneLocalPlayerManager.LocalPlayerGameObject == base.gameObject; if (isLocal ? CombineLocal : CombineRemote) { base.gameObject.SetActive(value: false); AvatarViewCombined avatarViewCombined = base.gameObject.AddComponent <AvatarViewCombined>(); avatarViewCombined.UseGpuSkinning = UseGpuSkinning; avatarViewCombined.MaxAtlasDimension = conditionalConfiguration.Get("AvatarSystem.MaxAtlasDimension.property", 512); base.gameObject.SetActive(value: true); avatarView = avatarViewCombined; } else { avatarView = base.gameObject.AddComponent <AvatarViewDistinct>(); } if (isLocal) { zoneLocalPlayerManager.AssignAvatarView(avatarView); } base.gameObject.AddComponent <PlayerMediator>(); avatarView.OnBusy += avatarView_OnBusy; avatarView.OnReady += avatarView_OnReady; bool flag = true; if (AvatarDataHandle.TryGetPlayerHandle(base.gameObject, out var handle) && dataEntityCollection.TryGetComponent <AvatarDetailsData>(handle, out avatarDetailsData)) { processAvatarDetails(handle); flag = false; } if (flag) { dataEntityCollection.EventDispatcher.AddListener <DataEntityEvents.ComponentAddedEvent <AvatarDetailsData> >(onAvatarDetailsAdded); Model.ClearAllEquipment(); } }
private void onAvatarIsReady(AvatarBaseAsync avatarView) { avatarView.OnReady -= onAvatarIsReady; GameObject gameObject = avatarView.gameObject; AvatarDataHandle component = gameObject.GetComponent <AvatarDataHandle>(); if (!(component != null) || component.Handle.IsNull || !dataEntityCollection.TryGetComponent <RemotePlayerData>(component.Handle, out var _)) { return; } DataEntityHandle handle = null; if (AvatarDataHandle.TryGetPlayerHandle(gameObject, out handle)) { avatarViewReady.Add(handle); PositionData component3 = dataEntityCollection.GetComponent <PositionData>(handle); if (component3.Position != Vector3.zero) { placeRemotePlayer(gameObject, handle, component3.Position); } } Service.Get <EventDispatcher>().DispatchEvent(new PlayerSpawnedEvents.RemotePlayerSpawned(gameObject, component.Handle)); }
private void Start() { dataEntityCollection = Service.Get <CPDataEntityCollection>(); avatarView = GetComponent <AvatarView>(); if (AvatarDataHandle.TryGetPlayerHandle(base.gameObject, out var handle)) { if (dataEntityCollection.HasComponent <RemotePlayerData>(handle)) { if (dataEntityCollection.TryGetComponent <LocomotionData>(handle, out locomotionData)) { addListeners(); } else { Log.LogError(this, "Entity missing a LocomotionData component, locomotion state listeners not added"); } } } else { dataEntityCollection.EventDispatcher.AddListener <DataEntityEvents.ComponentAddedEvent <LocomotionData> >(onLocomotionDataAdded); } }
private void Awake() { avatarDataHandle = GetComponent <AvatarDataHandle>(); eventChannel = new EventChannel(Service.Get <EventDispatcher>()); dataEntityCollection = Service.Get <CPDataEntityCollection>(); }