private void equipTube() { if (!LocomotionHelper.IsCurrentControllerOfType <SlideController>(ClubPenguin.SceneRefs.ZoneLocalPlayerManager.LocalPlayerGameObject)) { Service.Get <EventDispatcher>().DispatchEvent(new InputEvents.SwitchChangeEvent(InputEvents.Switches.Tube, _value: true)); } }
protected override void Update() { if (LocomotionHelper.IsCurrentControllerOfType <RunController>(GetTarget())) { RunController component = GetTarget().GetComponent <RunController>(); component.Behaviour = new RunController.ControllerBehaviour { IgnoreTranslation = !Controller, IgnoreCollisions = !Collisions, IgnoreRotation = !Steering, IgnoreGravity = !Gravity }; if (!Gravity) { component.ResetMomentum(); } } PenguinUserControl component2 = GetTarget().GetComponent <PenguinUserControl>(); if (component2 != null) { component2.enabled = UserControls; } Completed(); }
public bool CanInteract(long interactingPlayerId, GameObject actionGraphOwner) { InvitationalItemExperience component = actionGraphOwner.GetComponent <InvitationalItemExperience>(); if (component != null && !component.CanInteract(interactingPlayerId)) { return(false); } if (ExcludeIfSitting && LocomotionHelper.IsCurrentControllerOfType <SitController>(actionGraphOwner)) { return(false); } if (ExcludeIfSwimming && LocomotionHelper.IsCurrentControllerOfType <SwimController>(actionGraphOwner)) { return(false); } if (ExcludeIfInAir) { Animator component2 = actionGraphOwner.GetComponent <Animator>(); if (component2 != null && LocomotionUtils.IsInAir(LocomotionUtils.GetAnimatorStateInfo(component2))) { return(false); } } return(true); }
private bool getIdealDistanceToTarget(ref float distance, ref float height) { bool result = false; if (AlwaysUseDistOnIdle) { distance = DistanceOnIdle; height = HeightOffset; result = true; } else { setup(); distance = originalDistance; height = originalHeight; AnimatorStateInfo currentAnimatorStateInfo = anim.GetCurrentAnimatorStateInfo(AnimationHashes.Layers.Base); if (LocomotionUtils.IsIdling(currentAnimatorStateInfo) || LocomotionHelper.IsCurrentControllerOfType <SitController>(localPlayer)) { distance = DistanceOnIdle; height = HeightOffset; result = true; } } return(result); }
private void Update() { if (LocomotionHelper.IsCurrentControllerOfType <RunController>(base.gameObject)) { MoveIndicator.enabled = anim.GetBool("Dancing"); } }
private bool isTubing(GameObject playerObj) { if (playerObj != null && LocomotionHelper.IsCurrentControllerOfType <SlideController>(playerObj)) { return(true); } return(false); }
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); } }
public void OnTriggerExit(Collider col) { if (col != null && col.CompareTag(Tag) && col.gameObject != null && !LocomotionHelper.IsCurrentControllerOfType <RaceController>(col.gameObject) && Action == ActionType.StartingLine) { RaceController component = col.gameObject.GetComponent <RaceController>(); if (component != null) { component.setControlsEnabled(enabled: true); } } }
private IEnumerator ticSwitch() { for (timerCoroutineIsRunning = true; elapsedTime < PersistForTime; elapsedTime += Time.deltaTime) { yield return(null); } if (!PersistWhenSitting || !LocomotionHelper.IsCurrentControllerOfType <SitController>(propUser.gameObject)) { Change(onoff: false); } timerCoroutineIsRunning = false; }
private void locomotionStateChanged(LocomotionState state) { switch (state) { case LocomotionState.Slide: if (receivingEnabled) { locomotionTracker.SetCurrentController <SlideController>(); break; } pendingSlide = true; pendingRun = false; break; case LocomotionState.Racing: if (receivingEnabled) { if (playerDataHandle.IsLocalPlayer) { locomotionTracker.SetCurrentController <RaceController>(); } else if (LocomotionHelper.IsCurrentControllerOfType <SlideController>(base.gameObject)) { locomotionTracker.SetCurrentController <RaceController>(); } else { locomotionTracker.SetCurrentController <SlideController>(); } } else { pendingSlide = true; pendingRun = false; } break; case LocomotionState.Default: if (receivingEnabled) { locomotionTracker.SetCurrentController <RunController>(); break; } pendingSlide = false; pendingRun = true; break; default: pendingSlide = false; pendingRun = false; break; } }
private IEnumerator setSlideLocomotion(float waitTime, GameObject penguinObj) { yield return(new WaitForSeconds(waitTime)); if (!LocomotionHelper.IsCurrentControllerOfType <SlideController>(penguinObj)) { if (!LocomotionHelper.SetCurrentController <SlideController>(penguinObj)) { Log.LogErrorFormatted(this, "Failed to set the SlideController on {0}", penguinObj.GetPath()); } CoroutineRunner.Start(toggleWaterTrigger(2f), this, "toggleWaterCollider"); } }
private void onPropUserEnteredIdle() { if (base.OnOff && consuming) { propUser.EPropUserEnteredIdle -= onPropUserEnteredIdle; propUser.EPropStored -= onPropStored; consuming = false; if ((!PersistWhenSitting || !LocomotionHelper.IsCurrentControllerOfType <SitController>(propUser.gameObject)) && !timerCoroutineIsRunning) { Change(onoff: false); } } }
public void OnTriggerEnter(Collider col) { if (!(col != null) || !col.CompareTag(Tag) || !(col.gameObject != null) || (IsMemberOnly && !Service.Get <CPDataEntityCollection>().IsLocalPlayerMember())) { return; } if (Action == ActionType.StartingLine) { RaceController component = col.gameObject.GetComponent <RaceController>(); if ((object)component != null) { component.SetInitialTrackDir(base.transform.forward); hasPopupOpened = false; } } else if (Action == ActionType.FinishLine) { if (LocomotionHelper.IsCurrentControllerOfType <RaceController>(col.gameObject)) { RaceGameController raceGameController = col.gameObject.GetComponent <RaceGameController>(); if (raceGameController == null) { raceGameController = col.gameObject.AddComponent <RaceGameController>(); } raceGameController.FinishRace(); } } else if (Action == ActionType.EndOfTrack && LocomotionHelper.IsCurrentControllerOfType <RaceController>(col.gameObject)) { RaceController component = col.gameObject.GetComponent <RaceController>(); if (component != null) { component.setControlsEnabled(enabled: true); } LocomotionHelper.SetCurrentController <RunController>(col.gameObject); RaceGameController raceGameController = col.gameObject.GetComponent <RaceGameController>(); if (raceGameController != null) { raceGameController.RemoveLocalPlayerRaceData(); Object.Destroy(raceGameController); } if (!hasPopupOpened) { Service.Get <QuestService>().SendEvent("FinishredRace"); } } }
private void ShowPropControls() { if (Prop.IsOwnerLocalPlayer) { PropControlsOverride propControls = Prop.PropControls; GameObject target = dataEntityCollection.GetComponent <GameObjectReferenceData>(dataEntityCollection.LocalPlayerHandle).GameObject; InputButtonGroupContentKey inputButtonGroupContentKey = (LocomotionHelper.IsCurrentControllerOfType <SwimController>(target) ? ((!(LocomotionHelper.GetCurrentController(target) as SwimController).IsInShallowWater) ? getDivingControls(propControls) : propControls.SwimControls) : (LocomotionHelper.IsCurrentControllerOfType <SlideController>(target) ? getTubingControls(propControls) : ((!LocomotionHelper.IsCurrentControllerOfType <SitController>(target)) ? propControls.DefaultControls : ((!(LocomotionHelper.GetCurrentController(target) as SitController).IsUnderwater) ? getSittingControls(propControls) : propControls.SitSwimControls)))); 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"); } } }
protected override void Update() { GameObject target = GetTarget(); if (target == SceneRefs.ZoneLocalPlayerManager.LocalPlayerGameObject && !LocomotionHelper.IsCurrentControllerOfType <RaceController>(target)) { LocomotionHelper.SetCurrentController <RaceController>(target); LocomotionController currentController = LocomotionHelper.GetCurrentController(target); if (currentController is RaceController) { RaceGameController raceGameController = target.GetComponent <RaceGameController>(); if (raceGameController == null) { raceGameController = target.AddComponent <RaceGameController>(); } ((RaceController)currentController).InitializeRace(raceGameController); raceGameController.InitializeRace(RaceGate, Lite1a, Lite2a, Lite3a, Lite1b, Lite2b, Lite3b, SilverTimeMS, GoldTimeMS, LegendaryTimeMS, TrackId); } } Completed(); }
private void updateDesiredPercent() { int num = -1; bool flag = isZoomActive; isZoomActive = false; if (!isSuspended && isCameraInValidState()) { if (useCustomZoom) { isZoomActive = true; } else { for (int i = 0; i < Switches.Length; i++) { if (Switches[i].ActivationSwitch != null && Switches[i].ActivationSwitch.enabled && Switches[i].ActivationSwitch.OnOff) { isZoomActive = true; num = i; break; } } } } if (isZoomActive) { AnimatorStateInfo currentAnimatorStateInfo = anim.GetCurrentAnimatorStateInfo(AnimationHashes.Layers.Base); if (LocomotionUtils.IsLocomoting(currentAnimatorStateInfo) || LocomotionHelper.IsCurrentControllerOfType <SlideController>(localPlayer) || (LocomotionHelper.IsCurrentControllerOfType <SwimController>(localPlayer) && !LocomotionUtils.IsSwimmingIdle(currentAnimatorStateInfo))) { targetDesiredPercent = (useCustomZoom ? customZoom.ZoomPercentOnMove : Switches[num].ZoomPercentOnMove); } else { targetDesiredPercent = (useCustomZoom ? customZoom.ZoomPercentOnIdle : Switches[num].ZoomPercentOnIdle); } if (useCustomZoom) { zoomOutDelay = customZoom.ZoomOutDelay; targetDesiredHeightOffset = customZoom.HeightOffset; } else { zoomOutDelay = Switches[num].ZoomOutDelay; targetDesiredHeightOffset = Switches[num].HeightOffset; } zoomOutDelayActive = false; } else if (flag && zoomOutDelay > 0f) { zoomOutDelayActive = true; elapsedZoomOutDelay = 0f; } else if (!zoomOutDelayActive) { targetDesiredPercent = 0f; } if (zoomOutDelayActive) { elapsedZoomOutDelay += Time.deltaTime; if (elapsedZoomOutDelay >= zoomOutDelay) { elapsedZoomOutDelay = 0f; zoomOutDelayActive = false; targetDesiredPercent = 0f; } } if (targetDesiredPercent != desiredPercent || targetDesiredHeightOffset != desiredHeightOffset) { elapsedTime = 0f; startPercent = curPercent; desiredPercent = targetDesiredPercent; startHeightOffset = curHeightOffset; desiredHeightOffset = targetDesiredHeightOffset; } elapsedTime += Time.deltaTime; if (elapsedTime > Duration) { elapsedTime = Duration; } }
protected override void Update() { GameObject target = GetTarget(); if (target != null) { Vector3 vector = base.transform.forward; if (IncomingUserData != null && IncomingUserData.GetType() == typeof(Vector3)) { vector = ((Vector3)IncomingUserData).normalized; } else if (DirectionY != null) { vector = DirectionY.up; } else if (DirectionZ != null) { vector = DirectionZ.forward; } else if (DirectionTo != null) { vector = (DirectionTo.position - target.transform.position).normalized; } else if (Direction != Vector3.zero) { vector = Direction; } Vector3 vector2 = vector * Magnitude + AddDirection * AddMagnitude; bool flag = LocomotionHelper.IsCurrentControllerOfType <SlideController>(target); Rigidbody component = target.GetComponent <Rigidbody>(); if (!flag && component != null) { if (StartTransform != null) { component.transform.position = StartTransform.position; component.transform.rotation = StartTransform.rotation; component.velocity = Vector3.zero; component.angularVelocity = Vector3.zero; component.WakeUp(); } component.AddForce(vector2, ForceMode.VelocityChange); } else { if (SetRunLocomotion && (!PreserveTubing || !flag)) { LocomotionHelper.SetCurrentController <RunController>(target); flag = false; } if (!flag && StartTransform != null) { target.transform.position = StartTransform.position; target.transform.rotation = StartTransform.rotation; } LocomotionController currentController = LocomotionHelper.GetCurrentController(target); if (currentController != null) { if (currentController is RunController) { ((RunController)currentController).ClearAllVelocityInputs(); } currentController.SetForce(vector2, base.gameObject); } } } Completed(); }