private void Update() { if (LocomotionHelper.IsCurrentControllerOfType <RunController>(base.gameObject)) { MoveIndicator.enabled = anim.GetBool("Dancing"); } }
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); }
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 void Update() { for (int i = 0; i < colliders.Count; i++) { Collider collider = colliders[i]; if (collider == null) { colliders.RemoveAt(i); i--; continue; } Vector3 direction = Vector3.up; if (capsCollider.direction == 0) { direction = Vector3.right; } else if (capsCollider.direction == 2) { direction = Vector3.forward; } direction = base.transform.TransformDirection(direction); float num = capsCollider.height; float radius = capsCollider.radius; if (num < radius * 2f) { num = radius * 2f; } Vector3 a = base.transform.TransformPoint(capsCollider.center); Vector3 vector = a - direction * (num * 0.5f); Vector3 vector2 = vector + direction * Mathf.Max(0f, num - radius); Vector3 position = collider.transform.position; Vector3 vector3 = position - vector; float magnitude = Vector3.Cross(direction, vector3).magnitude; float num2 = Vector3.Dot(Vector3.Project(vector3 + vector, direction) - vector2, direction); float num3 = 0f; if (num2 > 0f) { Debug.DrawLine(position, vector2, Color.yellow); num3 = (position - vector2).magnitude / radius; } else { Debug.DrawLine(position, vector, Color.yellow); num3 = magnitude / radius; } num3 = Mathf.Clamp01(1f - num3) * Magnitude; Vector3 vector4 = direction * num3; Rigidbody attachedRigidbody = collider.attachedRigidbody; if (attachedRigidbody != null) { attachedRigidbody.AddForce(vector4, ForceMode.Impulse); continue; } LocomotionController currentController = LocomotionHelper.GetCurrentController(collider.gameObject); if (currentController != null && (!IgnoreIfRunController || !(currentController is RunController))) { currentController.AddForce(vector4, base.gameObject); } } }
public void ResetPropControls(bool isPropLocalPlayer) { if (isPropLocalPlayer && heldObjectsData.HeldObject == null && !dataEntityCollection.LocalPlayerHandle.IsNull && !SceneRefs.ZoneLocalPlayerManager.LocalPlayerGameObject.IsDestroyed()) { LocomotionHelper.GetCurrentController(SceneRefs.ZoneLocalPlayerManager.LocalPlayerGameObject).LoadControlsLayout(); } }
private void Update() { for (int i = 0; i < colliders.Count; i++) { Collider collider = colliders[i]; Vector3 vector = collider.transform.position - base.transform.position; float magnitude = vector.magnitude; float num = Magnitude; if (MaxDist > 0f) { num = Mathf.Clamp01(1f - magnitude / MaxDist) * Magnitude; } Vector3 vector2 = vector.normalized * num; Rigidbody attachedRigidbody = collider.attachedRigidbody; if (attachedRigidbody != null) { attachedRigidbody.AddForce(vector2, ForceMode.Impulse); continue; } LocomotionController currentController = LocomotionHelper.GetCurrentController(collider.gameObject); if (currentController != null && (!IgnoreIfRunController || !(currentController is RunController))) { currentController.AddForce(vector2, base.gameObject); } } }
private void onPromptButtonPressed(DPrompt.ButtonFlags pressed) { if (pressed != DPrompt.ButtonFlags.YES) { return; } LocomotionController currentController = LocomotionHelper.GetCurrentController(base.gameObject); if (currentController is SitController) { LocomotionHelper.SetCurrentController <SwimController>(base.gameObject); } bubbleState = BubbleState.TransitionToHidden; playAudioEvent(mutableData.AirCriticalAudioEvent, EventAction.StopSound); GameObject gameObject = GameObject.FindWithTag(UIConstants.Tags.UI_Tray_Root); if (gameObject != null) { StateMachineContext component = gameObject.GetComponent <StateMachineContext>(); if (component != null) { component.SendEvent(new ExternalEvent("Root", "noUI")); } } Invoke("startBubbleScreenWipe", 0.7f); swimController.ResurfaceAccepted(); dispatcher.DispatchEvent(default(DivingEvents.PlayerResurfaced)); }
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(); }
private bool isTubing(GameObject playerObj) { if (playerObj != null && LocomotionHelper.IsCurrentControllerOfType <SlideController>(playerObj)) { return(true); } return(false); }
protected override void Update() { if (!LocomotionHelper.SetCurrentController <ZiplineController>(GetTarget())) { Log.LogError(this, "Failed to set the ZiplineController"); } Completed(); }
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 override void OnEnter() { GameObject gameObject = GameObject.Find(Target.Value); if (gameObject != null) { LocomotionHelper.SetCurrentController <RunController>(gameObject); } Finish(); }
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 void handleLocalPlayerLeftLobby() { isLocalPlayerInLobby = false; Service.Get <EventDispatcher>().DispatchEvent(default(TubeRaceEvents.LocalPlayerLeftLobby)); moveLocalPlayerToPosition(LobbyExitPosition.position); LocomotionHelper.SetCurrentController <RunController>(SceneRefs.ZoneLocalPlayerManager.LocalPlayerGameObject); Service.Get <EventDispatcher>().DispatchEvent(new UIDisablerEvents.EnableUIElement("ControlsButton2")); Service.Get <EventDispatcher>().DispatchEvent(new UIDisablerEvents.EnableUIElement("ActionButton")); PartyGameUtils.EnableMainNavigation(); PartyGameUtils.EnableCellPhoneButton(); Service.Get <EventDispatcher>().DispatchEvent(new PlayerCardEvents.SetEnablePlayerCard(enable: true)); Service.Get <QuestService>().SendEvent($"Cancel{RaceDefinition.QuestEventIdentifier}Race"); }
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 resetLocomotionState() { GameObject localPlayerGameObject = SceneRefs.ZoneLocalPlayerManager.LocalPlayerGameObject; if (localPlayerGameObject != null) { LocomotionController currentController = LocomotionHelper.GetCurrentController(localPlayerGameObject); if (currentController != null) { currentController.ResetState(); } } }
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 override void OnEnter() { GameObject localPlayerGameObject = SceneRefs.ZoneLocalPlayerManager.LocalPlayerGameObject; if (localPlayerGameObject != null) { LocomotionController currentController = LocomotionHelper.GetCurrentController(localPlayerGameObject); if (currentController != null) { currentController.ResetState(); } } Finish(); }
private void handleLocalPlayerJoinedLobby() { isLocalPlayerInLobby = true; Service.Get <EventDispatcher>().DispatchEvent(default(TubeRaceEvents.LocalPlayerJoinedLobby)); moveLocalPlayerToPosition(LobbyPosition.position); LocomotionHelper.SetCurrentController <SlideController>(SceneRefs.ZoneLocalPlayerManager.LocalPlayerGameObject); Service.Get <EventDispatcher>().DispatchEvent(new UIDisablerEvents.DisableUIElement("ControlsButton2")); Service.Get <EventDispatcher>().DispatchEvent(new UIDisablerEvents.DisableUIElement("ActionButton")); PartyGameUtils.DisableMainNavigation(); PartyGameUtils.DisableCellPhoneButton(hide: true); Service.Get <EventDispatcher>().DispatchEvent(new PlayerCardEvents.SetEnablePlayerCard(enable: false)); Service.Get <EventDispatcher>().DispatchEvent(default(PlayerCardEvents.DismissPlayerCard)); Service.Get <QuestService>().SendEvent($"Join{RaceDefinition.QuestEventIdentifier}Race"); Service.Get <ICPSwrveService>().Action("tube_race", "lobby"); }
public override void OnEnter() { GameObject localPlayerGameObject = SceneRefs.ZoneLocalPlayerManager.LocalPlayerGameObject; if (localPlayerGameObject != null) { LocomotionHelper.SetCurrentController <RunController>(localPlayerGameObject); CharacterController component = localPlayerGameObject.GetComponent <CharacterController>(); if (component != null) { component.enabled = true; } } Finish(); }
protected override void Update() { ChairProperties component = SceneRefs.ActionSequencer.GetTrigger(GetTarget()).GetComponent <ChairProperties>(); if (component != null) { LocomotionHelper.SetCurrentController <SitController>(GetTarget()); LocomotionController currentController = LocomotionHelper.GetCurrentController(GetTarget()); if (currentController is SitController) { SitController sitController = (SitController)currentController; sitController.SetChair(component); } } Completed(); }
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"); } } }
public void OnTriggerEnter(Collider collider) { Vector3 vector = (collider.transform.position - base.transform.position).normalized * Magnitude; Rigidbody attachedRigidbody = collider.attachedRigidbody; if (attachedRigidbody != null) { attachedRigidbody.AddForce(vector, ForceMode.VelocityChange); return; } LocomotionController currentController = LocomotionHelper.GetCurrentController(collider.gameObject); if (currentController != null) { currentController.SetForce(vector, base.gameObject); } }
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"); } } }
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)); }
private void applyImpulse(Collider collider) { Vector3 vector = ((ZDirection != null) ? (ZDirection.forward * Magnitude) : (base.transform.forward * Magnitude)); LocomotionController locomotionController = LocomotionHelper.GetCurrentController(collider.gameObject); if (collider.gameObject.layer == LayerMask.NameToLayer(LayerConstants.TubeLayer)) { SlideControllerListener component = collider.GetComponent <SlideControllerListener>(); if (component != null) { locomotionController = component.SlideController; } } if (locomotionController != null) { if (!IgnoreIfRunController || !(locomotionController is RunController)) { if (Behaviour == ImpulseType.AddVelocity) { locomotionController.AddForce(vector * Time.fixedDeltaTime, base.gameObject); } else { locomotionController.SetForce(vector, base.gameObject); } } return; } Rigidbody attachedRigidbody = collider.attachedRigidbody; if (attachedRigidbody != null) { if (Behaviour == ImpulseType.SnapVelocity) { attachedRigidbody.velocity = vector; } else { attachedRigidbody.AddForce(vector, ForceMode.VelocityChange); } } }
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(); }