public void OnPropRetrieveCompleted() { if (PlayerHandle.IsNull) { return; } isPropAnimCompleted = true; checkRetrieveCompleted(); HeldObjectsData component = dataEntityCollection.GetComponent <HeldObjectsData>(PlayerHandle); if (component != null && component.HeldObject != null) { HeldObjectType objectType = component.HeldObject.ObjectType; if (objectType == HeldObjectType.DURABLE && Prop != null) { InteractiveZonePropEventHandler component2 = Prop.GetComponent <InteractiveZonePropEventHandler>(); if (component2 != null) { UnityEngine.Object.Destroy(component2); } } } if (Prop != null && Prop.IsOwnerLocalPlayer) { ParticipationData component3 = dataEntityCollection.GetComponent <ParticipationData>(dataEntityCollection.LocalPlayerHandle); if (component3 != null) { component3.IsInteractButtonAvailable = true; } } }
private void Start() { dataEntityCollection = Service.Get <CPDataEntityCollection>(); if (AvatarDataHandle.TryGetPlayerHandle(base.gameObject, out DataEntityHandle handle)) { if (dataEntityCollection.TryGetComponent(handle, out ParticipationData component)) { participationData = component; ResetParticipation(); initializePriorityCompetition(); if (InitializationCompleteAction != null) { InitializationCompleteAction(); } } else { dataEntityCollection.EventDispatcher.AddListener <DataEntityEvents.ComponentAddedEvent <ParticipationData> >(onParticipationDataReady); } } else { Log.LogError(this, "Unable to find handle"); } }
private void onExperienceStarted(string instanceId, long ownerId, bool isOwnerLocalPlayer, PropDefinition propDef) { try { invitationExperienceInstanceId = instanceId; invitingPlayerId = ownerId; isInvitationLocalPlayer = isOwnerLocalPlayer; invitingPlayerObject = getInvitingPlayerObject(); if (invitingPlayerObject != null) { invitingPlayerAvatarView = invitingPlayerObject.GetComponent <AvatarView>(); } CPMMOItemId identifier = new CPMMOItemId(long.Parse(invitationExperienceInstanceId), CPMMOItemId.CPMMOItemParent.PLAYER); serverObjectHandle = dataEntityCollection.FindEntity <ServerObjectItemData, CPMMOItemId>(identifier); if (serverObjectHandle.IsNull) { onItemRemoved(); return; } serverObjectData = dataEntityCollection.GetComponent <ServerObjectItemData>(serverObjectHandle); AvailableItemQuantity = propDef.TotalItemQuantity; totalItemQuantity = propDef.TotalItemQuantity; setupNetworkServiceListeners(); if (isOwnerLocalPlayer) { GameObject target = dataEntityCollection.GetComponent <GameObjectReferenceData>(dataEntityCollection.LocalPlayerHandle).GameObject; InputButtonGroupContentKey inputButtonGroupContentKey = (LocomotionHelper.IsCurrentControllerOfType <SwimController>(target) ? ((!(LocomotionHelper.GetCurrentController(target) as SwimController).IsInShallowWater) ? DivingControlLayout : SwimControlLayout) : ((!LocomotionHelper.IsCurrentControllerOfType <SitController>(target)) ? ControlLayout : ((!(LocomotionHelper.GetCurrentController(target) as SitController).IsUnderwater) ? SitControlLayout : SitSwimControlLayout))); if (inputButtonGroupContentKey != null && !string.IsNullOrEmpty(inputButtonGroupContentKey.Key)) { Service.Get <EventDispatcher>().DispatchEvent(new ControlsScreenEvents.SetRightOption(inputButtonGroupContentKey)); } else { Log.LogError(this, "Did not find a valid controls content key for this state"); } ParticipationData component = dataEntityCollection.GetComponent <ParticipationData>(dataEntityCollection.LocalPlayerHandle); if (component != null) { component.CurrentParticipationState = ParticipationState.Participating; component.IsInteractButtonAvailable = false; } } Service.Get <EventDispatcher>().AddListener <PenguinInteraction.InteractionStartedEvent>(onInteractionStarted); if (invitingPlayerAvatarView != null) { if (invitingPlayerAvatarView.IsReady) { onAvatarReady(); } invitingPlayerAvatarView.OnReady += onAvatarViewReady; } switchToCamera(); } catch (FormatException ex) { Log.LogException(this, ex); } }
private bool onParticipationDataReady(DataEntityEvents.ComponentAddedEvent <ParticipationData> evt) { ResetParticipation(); if (AvatarDataHandle.TryGetPlayerHandle(base.gameObject, out DataEntityHandle handle) && evt.Handle == handle) { participationData = evt.Component; dataEntityCollection.EventDispatcher.RemoveListener <DataEntityEvents.ComponentAddedEvent <ParticipationData> >(onParticipationDataReady); initializePriorityCompetition(); } return(false); }
private void Start() { CPDataEntityCollection cPDataEntityCollection = Service.Get <CPDataEntityCollection>(); participationData = cPDataEntityCollection.GetComponent <ParticipationData>(cPDataEntityCollection.LocalPlayerHandle); membershipData = cPDataEntityCollection.GetComponent <MembershipData>(cPDataEntityCollection.LocalPlayerHandle); gameObjectReferenceData = cPDataEntityCollection.GetComponent <GameObjectReferenceData>(cPDataEntityCollection.LocalPlayerHandle); type = InteractInWorldIconType.UICanvas; type = ((tweakableType != 0) ? tweakableType : type); setState(type); propService = Service.Get <PropService>(); indicatorRequest = Content.LoadAsync(onInteractIndicatorLoaded, InteractIndicatorContentKey); }
protected override void start() { base.start(); eventChannel.AddListener <ActionSequencerEvents.ActionSequenceStarted>(onActionSequenceStarted); eventChannel.AddListener <ActionSequencerEvents.ActionSequenceCompleted>(onActionSequenceCompleted); CPDataEntityCollection cPDataEntityCollection = Service.Get <CPDataEntityCollection>(); if (!cPDataEntityCollection.LocalPlayerHandle.IsNull) { ParticipationData component = cPDataEntityCollection.GetComponent <ParticipationData>(cPDataEntityCollection.LocalPlayerHandle); if (component != null && ParticipationState.Retained == component.CurrentParticipationState) { disableAndLockForActionSequence(); } } }
private bool onLocalPlayerReadyToSpawn(PlayerSpawnedEvents.LocalPlayerReadyToSpawn evt) { eventDispatcher.RemoveListener <PlayerSpawnedEvents.LocalPlayerReadyToSpawn>(onLocalPlayerReadyToSpawn); ParticipationData component = dataEntityCollection.GetComponent <ParticipationData>(dataEntityCollection.LocalPlayerHandle); if (component != null) { component.CurrentParticipationState = ParticipationState.Ready; } createLocalPlayer(LocalPlayerGameObject, evt.Handle); Quest activeQuest = Service.Get <QuestService>().ActiveQuest; if (activeQuest == null || activeQuest.Definition.name != Service.Get <GameStateController>().FTUEConfig.FtueQuestId) { Service.Get <EventDispatcher>().DispatchEvent(default(UIDisablerEvents.EnableAllUIElements)); } readyForAvatar(); return(false); }
public void OnDestroy() { isDestroyed = true; CoroutineRunner.StopAllForOwner(this); Service.Get <EventDispatcher>().RemoveListener <InputEvents.ActionEvent>(onActionEvent); Service.Get <EventDispatcher>().RemoveListener <PenguinInteraction.InteractionStartedEvent>(onInteractionStarted); Service.Get <EventDispatcher>().RemoveListener <SessionEvents.SessionPausedEvent>(onSessionPaused); if (serverObjectData != null) { serverObjectData.ItemChanged -= onItemChanged; } if (!serverObjectHandle.IsNull) { dataEntityCollection.EventDispatcher.RemoveListener <DataEntityEvents.EntityRemovedEvent>(onItemRemoved); } if (itemObject != null) { UnityEngine.Object.Destroy(itemObject); } if (invitingPlayerObject != null) { stopOfferAnimation(); invitingPlayerAvatarView.OnReady -= onAvatarViewReady; } if (isInvitationLocalPlayer && !dataEntityCollection.LocalPlayerHandle.IsNull) { ParticipationData component = dataEntityCollection.GetComponent <ParticipationData>(dataEntityCollection.LocalPlayerHandle); if (component != null) { component.IsInteractButtonAvailable = true; } if (propExperience.PropDef.PropType != 0 || propExperience.PropDef.ExperienceType != PropDefinition.ConsumableExperience.PartyGameLobby) { Service.Get <EventDispatcher>().DispatchEvent(new UIDisablerEvents.EnableUIElement("ConsumablesButton")); } if (dataEntityCollection.TryGetComponent <GameObjectReferenceData>(dataEntityCollection.LocalPlayerHandle, out var component2) && component2.GameObject != null) { LocomotionHelper.GetCurrentController(component2.GameObject).LoadControlsLayout(); } } Service.Get <EventDispatcher>().DispatchEvent(new PlayerIndicatorEvents.RemovePlayerIndicator(invitingPlayerId, isStored)); }
public ParticipationCompetitionRules(DataEntityHandle playerHandle, CPDataEntityCollection dataEntityCollection, ParticipationData data) { PlayerHandle = playerHandle; DataEntityCollection = dataEntityCollection; participation = data; }