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 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 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 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); } } }
private void resetLocomotionState() { GameObject localPlayerGameObject = SceneRefs.ZoneLocalPlayerManager.LocalPlayerGameObject; if (localPlayerGameObject != null) { LocomotionController currentController = LocomotionHelper.GetCurrentController(localPlayerGameObject); if (currentController != null) { currentController.ResetState(); } } }
public override void OnEnter() { GameObject localPlayerGameObject = SceneRefs.ZoneLocalPlayerManager.LocalPlayerGameObject; if (localPlayerGameObject != null) { LocomotionController currentController = LocomotionHelper.GetCurrentController(localPlayerGameObject); if (currentController != null) { currentController.ResetState(); } } 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 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 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); } } }
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)); }
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(); }
public static void EnableLocomotionControls() { Service.Get <EventDispatcher>().DispatchEvent(new UIDisablerEvents.EnableUIElementGroup("ControlsButtons")); Service.Get <EventDispatcher>().DispatchEvent(new UIDisablerEvents.EnableUIElement("Joystick")); Service.Get <EventDispatcher>().DispatchEvent(new UIDisablerEvents.EnableUIElement("ActionButton")); Service.Get <EventDispatcher>().DispatchEvent(new UIDisablerEvents.EnableUIElement("ControlsButton2")); ClubPenguin.SceneRefs.ZoneLocalPlayerManager.LocalPlayerGameObject.GetComponent <AbstractPenguinSnowballThrower>().EnableSnowballThrow(enable: true); if (!(ClubPenguin.SceneRefs.ZoneLocalPlayerManager != null)) { return; } GameObject localPlayerGameObject = ClubPenguin.SceneRefs.ZoneLocalPlayerManager.LocalPlayerGameObject; if (localPlayerGameObject != null) { LocomotionController currentController = LocomotionHelper.GetCurrentController(localPlayerGameObject); if (currentController is RunController) { (currentController as RunController).Behaviour.Reset(); } } LocomotionHelper.GetCurrentController(ClubPenguin.SceneRefs.ZoneLocalPlayerManager.LocalPlayerGameObject).LoadControlsLayout(); }
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 != 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(); }
public override void OnProximityStay(ProximityListener other) { if (!other.gameObject.CompareTag("Player")) { return; } float num = calcDistance(); float value = num; value = 3f - Mathf.Clamp(value, 2.5f, 3f); value = 1f - value * 2f; anim.SetFloat(HASH_PARAM_WARN_DISTANCE, value); switch (chomperState) { case ChomperState.HUNGRY: if (num <= 2f) { chomperState = ChomperState.LUNGE; break; } setAnimation(ChomperAnimation.ANIM_IDLE_HUNGRY); base.transform.LookAt(LookAtPlayer(chomperState)); break; case ChomperState.LUNGE: setAnimation(ChomperAnimation.ANIM_LUNGE); base.transform.LookAt(LookAtPlayer(chomperState)); if (IsPenguinGrabbed) { chomperState = ChomperState.LUNGE_SUCCESS; dispatcher.DispatchEvent(new DivingEvents.CollisionEffects(penguinObj.tag)); } break; case ChomperState.LUNGE_SUCCESS: enablePenguinSwallow(isEnabled: false); setAnimation(ChomperAnimation.ANIM_SUCCESS); chomperState = ChomperState.LUNGE_SUCCESS_SPIT_WAIT; break; case ChomperState.LUNGE_SUCCESS_SPIT_COMPLETE: anim.SetFloat(HASH_PARAM_WARN_DISTANCE, 1f); enablePenguinSwallow(isEnabled: true); if (savedCollider != null) { Vector3 vector = (penguinObj.transform.position - base.transform.position).normalized * SpitStrength; Rigidbody attachedRigidbody = savedCollider.attachedRigidbody; if (attachedRigidbody != null) { attachedRigidbody.AddForce(vector, ForceMode.Impulse); } else { LocomotionController currentController = LocomotionHelper.GetCurrentController(savedCollider.gameObject); if (currentController != null) { currentController.SetForce(vector, base.gameObject); } } } isPenguinGrabbed = false; chomperState = ChomperState.LUNGE_SUCCESS_ANIMATION_WAIT; break; case ChomperState.LUNGE_SUCCESS_ANIMATION_COMPLETE: StartCoroutine(PauseChomper(3f)); chomperState = ChomperState.REVIVE_PAUSE_WAIT; break; case ChomperState.LUNGE_MISS: setAnimation(ChomperAnimation.ANIM_MISS); break; case ChomperState.LUNGE_MISS_ANIMATION_COMPLETE: StartCoroutine(PauseChomper(1f)); chomperState = ChomperState.REVIVE_PAUSE_WAIT; break; default: Log.LogError(this, $"O_o\t ChomperController.OnTriggerStay: ERROR: illegal internalState {(int)chomperState}, defaulting to hungry"); chomperState = ChomperState.HUNGRY; setAnimation(ChomperAnimation.ANIM_IDLE_HUNGRY); break; case ChomperState.LUNGE_SUCCESS_SPIT_WAIT: case ChomperState.LUNGE_SUCCESS_ANIMATION_WAIT: case ChomperState.LUNGE_MISS_ANIMATION_WAIT: case ChomperState.REVIVE_PAUSE_WAIT: break; } if (chomperState == ChomperState.LUNGE_SUCCESS_ANIMATION_WAIT) { return; } Vector3 eulerAngles = base.gameObject.transform.eulerAngles; if (chomperState == ChomperState.LUNGE) { eulerAngles.x = (eulerAngles.x + 90f) % 360f; if (eulerAngles.x > 90f && eulerAngles.x <= 180f) { eulerAngles.x = 90f; } else if (eulerAngles.x > 180f && eulerAngles.x < 270f) { eulerAngles.x = 270f; } } else { eulerAngles.x = 0f; } if (eulerAngles.y > 90f && eulerAngles.y <= 180f) { eulerAngles.y = 90f; } else if (eulerAngles.y > 180f && eulerAngles.y < 270f) { eulerAngles.y = 270f; } base.gameObject.transform.eulerAngles = eulerAngles; }
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 void Start() { localPlayerGO = SceneRefs.ZoneLocalPlayerManager.LocalPlayerGameObject; localPlayerGO.GetComponent <LocomotionEventBroadcaster>().OnControllerChangedEvent += onLocomotionControllerChanged; onLocomotionControllerChanged(LocomotionHelper.GetCurrentController(localPlayerGO)); }