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); }
public void LateUpdate() { if (snowballInst.Snowball != null && !LocomotionUtils.IsThrowingSnowball(LocomotionUtils.GetAnimatorStateInfo(anim, mutableData.AnimLayerIndex)) && !LocomotionUtils.IsChargingSnowball(LocomotionUtils.GetAnimatorStateInfo(anim, mutableData.AnimLayerIndex))) { abortSnowball(); } }
public override void OnEnter() { bool flag = false; PropUser component = SceneRefs.ZoneLocalPlayerManager.LocalPlayerGameObject.GetComponent <PropUser>(); if (component != null && component.Prop != null) { flag = component.Prop.PropId == propDefinition.GetNameOnServer(); if (flag) { Animator componentInParent = base.Owner.GetComponentInParent <Animator>(); if (componentInParent != null) { AnimatorStateInfo animatorStateInfo = LocomotionUtils.GetAnimatorStateInfo(componentInParent, 1); flag = LocomotionUtils.IsHolding(animatorStateInfo) || LocomotionUtils.IsRetrieving(animatorStateInfo); } else { LogWarning("Failed to get the animator controller. IsHoldingPropAction could only determine that the owner has a prop component and did not check the animator's state."); } } } if (flag) { base.Fsm.Event(OnTrueEvent); } else { base.Fsm.Event(OnFalseEvent); } Finish(); }
private int hasEquippedProp() { bool flag = false; int result = -1; PropUser component = SceneRefs.ZoneLocalPlayerManager.LocalPlayerGameObject.GetComponent <PropUser>(); if (component != null && component.Prop != null) { int num = PropDefinition.Length; for (int i = 0; i < num; i++) { flag = component.Prop.PropId == PropDefinition[i].GetNameOnServer(); if (flag) { result = i; break; } } if (flag) { Animator componentInParent = SceneRefs.ZoneLocalPlayerManager.LocalPlayerGameObject.GetComponentInParent <Animator>(); if (componentInParent != null) { AnimatorStateInfo animatorStateInfo = LocomotionUtils.GetAnimatorStateInfo(componentInParent, 1); flag = LocomotionUtils.IsHolding(animatorStateInfo) || LocomotionUtils.IsRetrieving(animatorStateInfo); } } } if (!flag) { result = -1; } return(result); }
protected IEnumerator waitForValidLocomotionModeToInteract() { if (locomotionTracker != null && locomotionTracker.GetCurrentController() is RunController) { Animator anim = GetComponent <Animator>(); RunController runController = (RunController)locomotionTracker.GetCurrentController(); RunController.ControllerBehaviour oldBehaviour = runController.Behaviour; runController.Behaviour = new RunController.ControllerBehaviour { IgnoreCollisions = false, IgnoreGravity = false, IgnoreRotation = false, IgnoreTranslation = false, IgnoreJumpRequests = true, IgnoreStickInput = true, LastModifier = this }; AnimatorStateInfo animStateInfo = LocomotionUtils.GetAnimatorStateInfo(anim); while (!LocomotionUtils.IsLocomoting(animStateInfo) && !LocomotionUtils.IsLanding(animStateInfo) && !LocomotionUtils.IsIdling(animStateInfo)) { yield return(null); animStateInfo = LocomotionUtils.GetAnimatorStateInfo(anim); } runController.ResetMomentum(); if (runController.Behaviour.LastModifier == this) { runController.Behaviour = oldBehaviour; } } }
private void Update() { AnimatorStateInfo animatorStateInfo = LocomotionUtils.GetAnimatorStateInfo(anim); curFacing = base.transform.forward; curFacing.y = 0f; curFacing.Normalize(); updateFX(); bool flag = LocomotionUtils.IsIdling(animatorStateInfo); if (isInTorpedoState) { lerpSpin(); if (!LocomotionUtils.IsTurboing(animatorStateInfo)) { isInTorpedoState = false; wsLastSteerDir = wsSteerDir; torpedoBubbles.Stop(); } } else if (LocomotionUtils.IsTurboing(animatorStateInfo)) { isInTorpedoState = true; curSpin = 0f; if (!IsInShallowWater) { torpedoBubbles.Play(); } } if (wsSteerDir != Vector3.zero) { speedMultAnimParam += mutableData.Accel * Time.deltaTime; } else if (flag) { speedMultAnimParam = mutableData.MinSpeedMult; } if (flag) { Momentum = Vector3.Lerp(Momentum, Vector3.zero, mutableData.DragSmoothing * Time.deltaTime); if ((double)Momentum.magnitude < 0.25) { Momentum = Vector3.zero; } } else { Momentum = (base.transform.position - prevPos) / Time.deltaTime; desiredFacing = wsSteerDir; } speedMultAnimParam = Mathf.Clamp(speedMultAnimParam, mutableData.MinSpeedMult, 1f); anim.SetFloat(AnimationHashes.Params.SwimSpeedMult, speedMultAnimParam); anim.SetFloat(AnimationHashes.Params.SwimSpeed, wsSteerDir.magnitude); prevPos = base.transform.position; }
private bool checkAnimatorState() { bool result = false; if (animator != null) { AnimatorStateInfo animatorStateInfo = LocomotionUtils.GetAnimatorStateInfo(animator); result = LocomotionUtils.IsIdling(animatorStateInfo); } return(result); }
private void Update() { if (animator != null && !isDisabledByScavengerHunt) { bool flag = LocomotionUtils.IsInAir(LocomotionUtils.GetAnimatorStateInfo(animator)); if (flag && !isDisabledByInAir) { disableButton(); } else if (!flag && isDisabledByInAir) { enableButton(); } } }
private void OnAnimatorMove() { AnimatorStateInfo animatorStateInfo = LocomotionUtils.GetAnimatorStateInfo(anim); if (wsSteerDir != Vector3.zero) { Quaternion identity = Quaternion.identity; if (LocomotionUtils.IsTurboing(animatorStateInfo)) { identity = Quaternion.LookRotation(wsLastSteerDir, wsUpDir); identity = Quaternion.AngleAxis(curSpin, wsLastSteerDir) * identity; } else { identity = Quaternion.LookRotation(wsSteerDir); } Output.wsRotation = Quaternion.Slerp(base.transform.rotation, identity, mutableData.RotationSmoothing * Time.deltaTime); } else if (!IsInShallowWater) { Quaternion identity = Quaternion.LookRotation(-cameraTransform.forward, cameraTransform.up); Output.wsRotation = Quaternion.Slerp(base.transform.rotation, identity, mutableData.RotationSmoothing * Time.deltaTime); } else if (snapToDesiredFacing) { if (Vector3.Angle(curFacing, desiredFacing) < 1f) { snapToDesiredFacing = false; } TurnToDesiredFacing(mutableData.RotationSmoothing); } else { Output.wsRotation = base.transform.rotation; } if (LocomotionUtils.IsIdling(animatorStateInfo)) { Output.wsDeltaPos = Momentum * Time.deltaTime; } else if (LocomotionUtils.IsTurboing(animatorStateInfo)) { Output.wsDeltaPos = anim.deltaPosition; } else { Output.wsDeltaPos = anim.deltaPosition * stickMagnitude; } }
protected void DefaultDoAction(LocomotionAction action, object userData = null) { switch (action) { case LocomotionAction.ChargeThrow: if (snowballThrow != null) { snowballThrow.ChargeSnowball(); } break; case LocomotionAction.LaunchThrow: if (snowballThrow != null) { snowballThrow.LaunchSnowball((float)userData); } break; case LocomotionAction.Interact: { PenguinInteraction component = GetComponent <PenguinInteraction>(); if (component != null && component.RequestInteraction()) { Broadcaster.BroadcastOnDoAction(action, userData); } break; } case LocomotionAction.Action1: case LocomotionAction.Action2: case LocomotionAction.Action3: { PenguinInteraction component = GetComponent <PenguinInteraction>(); if (component != null && !LocomotionUtils.IsInAir(LocomotionUtils.GetAnimatorStateInfo(animator))) { Broadcaster.BroadcastOnDoAction(action, userData); } break; } } }
private void startPropInteraction() { if (PlayerHandle.IsNull || !dataEntityCollection.TryGetComponent <GameObjectReferenceData>(PlayerHandle, out var component)) { return; } Animator component2 = component.GameObject.GetComponent <Animator>(); if (component2 != null) { AnimatorStateInfo animatorStateInfo = LocomotionUtils.GetAnimatorStateInfo(component2, 1); if (!LocomotionUtils.IsHolding(animatorStateInfo)) { component2.Play(AnimationHashes.States.TorsoHold, AnimationHashes.Layers.Torso); } } ParticipationController component3 = component.GameObject.GetComponent <ParticipationController>(); if (component3 != null) { component3.StartParticipation(new ParticipationRequest(ParticipationRequest.Type.Start, Prop.gameObject, "PropUser")); } }
private IEnumerator SampleSurface() { while (true) { if (base.isActiveAndEnabled) { Vector3 hitPoint = Vector3.zero; int num = LocomotionUtils.SampleSurface(base.transform, SurfaceSamplingData, out hitPoint); AnimatorStateInfo animatorStateInfo = LocomotionUtils.GetAnimatorStateInfo(anim); if (LocomotionUtils.IsLocomoting(animatorStateInfo)) { if (LocomotionUtils.IsWalking(animatorStateInfo)) { if (locoStatus != LocomotionStatus.Walking || num != prevSurfaceTypeIndex) { locoStatus = LocomotionStatus.Walking; if (num >= 0) { if (!string.IsNullOrEmpty(SurfaceSamplingData.Effects[num].WalkSwitch.SwitchValue)) { EventManager.Instance.PostEvent(SurfaceSamplingData.Effects[num].WalkSwitch.EventName, EventAction.SetSwitch, SurfaceSamplingData.Effects[num].WalkSwitch.SwitchValue, base.gameObject); } } else if (!string.IsNullOrEmpty(SurfaceSamplingData.DefaultWalkSwitch.EventName)) { EventManager.Instance.PostEvent(SurfaceSamplingData.DefaultWalkSwitch.EventName, EventAction.SetSwitch, SurfaceSamplingData.DefaultWalkSwitch.SwitchValue, base.gameObject); } } } else if (locoStatus != LocomotionStatus.Jogging || num != prevSurfaceTypeIndex) { locoStatus = LocomotionStatus.Jogging; if (num >= 0) { if (!string.IsNullOrEmpty(SurfaceSamplingData.Effects[num].JogSwitch.SwitchValue)) { EventManager.Instance.PostEvent(SurfaceSamplingData.Effects[num].JogSwitch.EventName, EventAction.SetSwitch, SurfaceSamplingData.Effects[num].JogSwitch.SwitchValue, base.gameObject); } } else if (!string.IsNullOrEmpty(SurfaceSamplingData.DefaultJogSwitch.EventName)) { EventManager.Instance.PostEvent(SurfaceSamplingData.DefaultJogSwitch.EventName, EventAction.SetSwitch, SurfaceSamplingData.DefaultJogSwitch.SwitchValue, base.gameObject); } } } else if (LocomotionUtils.IsInAir(animatorStateInfo) || LocomotionUtils.IsLanding(animatorStateInfo)) { if (locoStatus != LocomotionStatus.InAir || num != prevSurfaceTypeIndex) { locoStatus = LocomotionStatus.InAir; if (num >= 0) { if (!string.IsNullOrEmpty(SurfaceSamplingData.Effects[num].LandSwitch.SwitchValue)) { EventManager.Instance.PostEvent(SurfaceSamplingData.Effects[num].LandSwitch.EventName, EventAction.SetSwitch, SurfaceSamplingData.Effects[num].LandSwitch.SwitchValue, base.gameObject); } } else if (!string.IsNullOrEmpty(SurfaceSamplingData.DefaultLandSwitch.EventName)) { EventManager.Instance.PostEvent(SurfaceSamplingData.DefaultLandSwitch.EventName, EventAction.SetSwitch, SurfaceSamplingData.DefaultLandSwitch.SwitchValue, base.gameObject); } } } else if (tracker.IsCurrentControllerOfType <SlideController>()) { if (locoStatus != LocomotionStatus.Tubing || num != prevSurfaceTypeIndex) { locoStatus = LocomotionStatus.Tubing; if (num >= 0) { if (!string.IsNullOrEmpty(SurfaceSamplingData.Effects[num].TubeSlideLoopSwitch.SwitchValue)) { EventManager.Instance.PostEvent(SurfaceSamplingData.Effects[num].TubeSlideLoopSwitch.EventName, EventAction.SetSwitch, SurfaceSamplingData.Effects[num].TubeSlideLoopSwitch.SwitchValue, base.gameObject); } } else if (!string.IsNullOrEmpty(SurfaceSamplingData.DefaultTubeSlideLoopSwitch.EventName)) { EventManager.Instance.PostEvent(SurfaceSamplingData.DefaultTubeSlideLoopSwitch.EventName, EventAction.SetSwitch, SurfaceSamplingData.DefaultTubeSlideLoopSwitch.SwitchValue, base.gameObject); } } } else { locoStatus = LocomotionStatus.Unknown; } prevSurfaceTypeIndex = num; } yield return(new WaitForSeconds(sampleTime)); } }
private IEnumerator doMoveTo() { if (runController != null && runController.enabled) { Animator anim = actionTarget.GetComponent <Animator>(); Transform tempTransform = null; RunController.ControllerBehaviour oldRunBehaviour = runController.Behaviour; runController.Behaviour = new RunController.ControllerBehaviour { IgnoreCollisions = false, IgnoreGravity = false, IgnoreRotation = false, IgnoreTranslation = false, IgnoreJumpRequests = true, IgnoreStickInput = true, Style = Style }; bool runControllerBehaviourWasSet = true; AnimatorStateInfo animStateInfo = LocomotionUtils.GetAnimatorStateInfo(anim); while (!LocomotionUtils.IsLocomoting(animStateInfo) && !LocomotionUtils.IsLanding(animStateInfo) && !LocomotionUtils.IsIdling(animStateInfo)) { yield return(null); animStateInfo = LocomotionUtils.GetAnimatorStateInfo(anim); } runController.ResetMomentum(); if (IncomingUserData != null && IncomingUserData.GetType() == typeof(Vector3)) { Vector3 vector = (Vector3)IncomingUserData; Vector3 vector2 = vector - actionTarget.transform.position; vector2.y = 0f; if (vector2 == Vector3.zero) { vector2 = base.transform.forward; } tempTransform = new GameObject().transform; tempTransform.rotation = Quaternion.LookRotation(vector2); tempTransform.position = vector; Waypoints.Clear(); Waypoints.Add(tempTransform); } if (Waypoints.Count > 0) { float distThresholdSq = DistanceThreshold * DistanceThreshold; float prevDistSq = float.PositiveInfinity; float elapsedTime = 0f; bool done = false; int curWaypoint2 = 0; do { if (thisTransform.IsDestroyed() || actionTarget.IsDestroyed()) { Log.LogError(this, "Aborting LocomoteToAction as an object has been destroyed"); break; } if (UseShortestPath) { curWaypoint2 = FindFarthestReachableWaypoint(curWaypoint2); } Vector3 toTarget = Waypoints[curWaypoint2].position - thisTransform.position; toTarget.y = 0f; float distSq = toTarget.sqrMagnitude; if (distSq <= distThresholdSq || distSq > prevDistSq) { curWaypoint2++; if (curWaypoint2 >= Waypoints.Count) { done = true; } else { toTarget = Waypoints[curWaypoint2].position - thisTransform.position; toTarget.y = 0f; runController.Steer(toTarget.normalized); } } else { runController.Steer(toTarget.normalized); } elapsedTime += Time.deltaTime; if (elapsedTime > 5f) { done = true; } yield return(null); }while (!done); curWaypoint2 = Waypoints.Count - 1; runController.Steer(Vector3.zero); if (DontSnapYPosAtEnd) { Vector3 position = Waypoints[curWaypoint2].position; position.y = thisTransform.position.y; runController.SnapToPosition(position); } else { runController.SnapToPosition(Waypoints[curWaypoint2].position); } if (SnapRotAtEnd) { runController.SnapToFacing(Waypoints[curWaypoint2].forward); } } if (tempTransform != null) { Object.Destroy(tempTransform.gameObject); Waypoints.Clear(); } if (runControllerBehaviourWasSet) { runController.Behaviour = oldRunBehaviour; } } Completed(); }
private bool canSitFromCurrentState() { AnimatorStateInfo animatorStateInfo = LocomotionUtils.GetAnimatorStateInfo(animator); return(LocomotionUtils.IsIdling(animatorStateInfo) || LocomotionUtils.IsLocomoting(animatorStateInfo) || LocomotionUtils.IsInAir(animatorStateInfo) || LocomotionUtils.IsLanding(animatorStateInfo) || LocomotionUtils.IsSwimming(animatorStateInfo)); }