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 showChatMessage(long sessionId, string message, int sizzleclipID, bool isAwaitingModeration = false, bool isLocalChatPhrase = false) { bool flag = dataEntityCollection.IsLocalPlayer(sessionId); if (!string.IsNullOrEmpty(message)) { WorldSpeechBubble speechBubble = getSpeechBubble(sessionId); if (isAwaitingModeration) { if (isLocalChatPhrase) { speechBubble.ShowChatPhraseMessage(sessionId, message); } else { speechBubble.ShowAwaitingModerationMessage(sessionId, message); } } else if (!isLocalChatPhrase || !flag) { speechBubble.ShowChatMessage(sessionId, message); } } if (sizzleclipID > 0 && (isAwaitingModeration || !flag)) { Transform avatar = getAvatar(sessionId); if (avatar != null && LocomotionUtils.CanPlaySizzle(avatar.gameObject)) { Animator component = avatar.GetComponent <Animator>(); component.SetInteger(AnimationHashes.Params.Emote, sizzleclipID); component.SetTrigger(AnimationHashes.Params.PlayEmote); } } }
public override void OnEnter() { GameObject localPlayerGameObject = SceneRefs.ZoneLocalPlayerManager.LocalPlayerGameObject; LocomotionUtils.UnEquipProp(localPlayerGameObject); Finish(); }
private void jumpToRestartLocation() { GameObject localPlayerGameObject = SceneRefs.ZoneLocalPlayerManager.LocalPlayerGameObject; Vector3 raceRestartPosition = tubeRaceDefinition.RaceRestartPosition; RaceController component = localPlayerGameObject.GetComponent <RaceController>(); if (component != null) { component.setControlsEnabled(enabled: true); } LocomotionTracker component2 = localPlayerGameObject.GetComponent <LocomotionTracker>(); if (!component2.IsCurrentControllerOfType <RunController>()) { component2.SetCurrentController <RunController>(); } localPlayerGameObject.transform.position = raceRestartPosition; RaceGameController component3 = localPlayerGameObject.GetComponent <RaceGameController>(); if (component3 != null) { component3.RemoveLocalPlayerRaceData(); Object.Destroy(component3); } Service.Get <EventDispatcher>().DispatchEvent(new CinematographyEvents.CameraSnapLockEvent(snapPosition: false, snapAim: true)); CoroutineRunner.Start(LocomotionUtils.nudgePlayer(component2), component2.gameObject, "MoveAfterJump"); }
private bool onFriendLocationReceived(FriendsServiceEvents.FriendLocationInRoomReceived evt) { eventChannel.RemoveListener <FriendsServiceEvents.FriendLocationInRoomReceived>(onFriendLocationReceived); eventChannel.RemoveListener <FriendsServiceEvents.FriendNotInRoom>(onFriendNotInRoom); Vector3 location = evt.Location; if (!(Vector3.Distance(SceneRefs.ZoneLocalPlayerManager.LocalPlayerGameObject.transform.position, location) <= 3f)) { LocomotionTracker component = SceneRefs.ZoneLocalPlayerManager.LocalPlayerGameObject.GetComponent <LocomotionTracker>(); GameObjectReferenceData component2; if (component.IsCurrentControllerOfType <SlideController>()) { component.SetCurrentController <RunController>(); } else if (component.IsCurrentControllerOfType <SwimController>() && dataEntityCollection.TryGetComponent <GameObjectReferenceData>(Handle, out component2)) { LocomotionTracker component3 = component2.GameObject.GetComponent <LocomotionTracker>(); if (component3.IsCurrentControllerOfType <RunController>()) { Animator component4 = SceneRefs.ZoneLocalPlayerManager.LocalPlayerGameObject.GetComponent <Animator>(); component4.SetTrigger(AnimationHashes.Params.SwimToWalk); component.SetCurrentController <RunController>(); } } if (component.IsCurrentControllerOfType <RunController>()) { location.y += 0.5f; } SceneRefs.ZoneLocalPlayerManager.LocalPlayerGameObject.transform.position = location; ClubPenguin.Core.SceneRefs.Get <BaseCamera>().Snap(); CoroutineRunner.Start(LocomotionUtils.nudgePlayer(component), component.gameObject, "MoveAfterJump"); } destroyAndCloseCellPhone(); return(false); }
private void OnDestroy() { dispatcher.RemoveListener <InputEvents.ActionEvent>(onActionEvent); CoroutineRunner.StopAllForOwner(this); changeToDefaultCamera(); LocomotionUtils.UnEquipProp(ClubPenguin.SceneRefs.ZoneLocalPlayerManager.LocalPlayerGameObject); }
public void LateUpdate() { if (snowballInst.Snowball != null && !LocomotionUtils.IsThrowingSnowball(LocomotionUtils.GetAnimatorStateInfo(anim, mutableData.AnimLayerIndex)) && !LocomotionUtils.IsChargingSnowball(LocomotionUtils.GetAnimatorStateInfo(anim, mutableData.AnimLayerIndex))) { abortSnowball(); } }
protected override void Update() { if (!LocomotionUtils.IsInAir(anim.GetCurrentAnimatorStateInfo(0))) { Completed(); } }
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); }
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 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); }
public override void SteerRotation(Vector2 steerInput) { Vector3 _wsSteerRotation = LocomotionUtils.StickInputToWorldSpaceTransform(steerInput, (!IsInShallowWater) ? LocomotionUtils.AxisIndex.Y : LocomotionUtils.AxisIndex.Z); if (snapToDesiredFacing || (int)Vector3.Angle(desiredFacing, _wsSteerRotation) > mutableData.RotationDegreesOffsetThreshold) { applyWorldSpaceSteerRotation(ref _wsSteerRotation); } }
public override void Steer(Vector2 steerInput) { stickMagnitude = steerInput.magnitude; Vector3 wsForward = default(Vector3); Vector3 wsUp = default(Vector3); LocomotionUtils.StickInputToWorldSpaceTransform(steerInput, out wsForward, out wsUp, (!IsInShallowWater) ? LocomotionUtils.AxisIndex.Y : LocomotionUtils.AxisIndex.Z); applyWorldSpaceSteering(ref wsForward, ref wsUp); }
private void moveLocalPlayerToPosition(Vector3 position) { GameObject localPlayerGameObject = SceneRefs.ZoneLocalPlayerManager.LocalPlayerGameObject; localPlayerGameObject.transform.position = position + new Vector3(0f, 0.5f, 0f); LocomotionTracker component = localPlayerGameObject.GetComponent <LocomotionTracker>(); CoroutineRunner.Start(LocomotionUtils.nudgePlayer(component), component.gameObject, "MoveAfterJump"); }
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); }
public void MoveTo(MyHexPosition selectorPosition, UnitModel selectedUnit, MyHexPosition magicUsePosition) { var magicType = _courseModel.GetPlayerMagicType(CurrentPlayer); if (magicUsePosition != null) { Assert.IsNull(_magicUsage); _magicUsage = new MagicUsage(magicType, magicUsePosition, _courseModel, CurrentPlayer, CameraShake, MasterSound); } _unitLocomotions.Push(LocomotionUtils.CreateMovementJourney(_courseModel, _unitModelToGameObjectMap[selectedUnit], selectorPosition)); _courseModel.NextTurn(); _possibleMoveTargetsCache = new Dictionary <PossibleMoveTargetsQueryKey, List <MyHexPosition> >(); }
protected override void Update() { if (itemInstance == null) { if (StoreExistingProp) { LocomotionUtils.UnEquipProp(GetTarget()); } itemInstance = UnityEngine.Object.Instantiate(ItemPrefab); Transform transform = GetTarget().transform; List <Transform> userBones = new List <Transform>(transform.GetComponentsInChildren <Transform>()); parentBatToTargetBone(userBones); } Completed(itemInstance); }
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; } }
public void SurfaceFX(string alias) { if (!base.enabled) { return; } Vector3 hitPoint; int num = LocomotionUtils.SampleSurface(base.transform, MasterData, out hitPoint); if (num < 0) { return; } if (prevEffect != null) { prevEffect.Stop(); if (system[prevSurfaceTypeIndex] != null) { system[prevSurfaceTypeIndex].Unspawn(prevEffect.gameObject); } } Vector3 position = Vector3.zero; bool flag = false; if (emitterPoints.TryGetValue(alias, out Transform value)) { position = value.position; flag = true; } if (flag) { if (MasterData.Effects[num].UseCollisionHeight) { position.y = hitPoint.y; } if (system[num] != null) { ParticleSystem component = system[num].Spawn().GetComponent <ParticleSystem>(); component.transform.position = position; component.Play(); prevEffect = component; prevSurfaceTypeIndex = num; } } }
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 applyWorldSpaceSteering(ref Vector3 _wsSteerDir, ref Vector3 _wsUpDir) { Vector3 v = wsSteerDir; wsSteerDir = _wsSteerDir; wsUpDir = _wsUpDir; targetSpin = 0f; if (wsSteerDir != Vector3.zero) { wsLastSteerDir = wsSteerDir; if (isInTorpedoState) { float num = LocomotionUtils.SignedAngle(v, wsSteerDir); if (num > 0f) { targetSpin = 180f; } } } Broadcaster.BroadcastOnSteerDirectionEvent(wsSteerDir); }
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 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 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; } }
private bool canSitFromCurrentState() { AnimatorStateInfo animatorStateInfo = LocomotionUtils.GetAnimatorStateInfo(animator); return(LocomotionUtils.IsIdling(animatorStateInfo) || LocomotionUtils.IsLocomoting(animatorStateInfo) || LocomotionUtils.IsInAir(animatorStateInfo) || LocomotionUtils.IsLanding(animatorStateInfo) || LocomotionUtils.IsSwimming(animatorStateInfo)); }
private void ProcessLocomotionStack <T>(Stack <LocomotionManager <T> > locomotions) where T : PawnModelComponent { if (_soloAnimations.Any()) { var animation = _soloAnimations.Peek(); animation.UpdateAnimation(); if (!animation.WeAreDuringAnimation()) { _soloAnimations.Pop(); if (_soloAnimations.Any()) { _soloAnimations.Peek().StartAnimation(); } } return; } if (_magicUsage != null) { if (_magicUsage.MagicUsageEnded) { _magicUsage = null; } else { _magicUsage.Update(); return; } } ; if (locomotions.Any()) { var currentLocomotion = locomotions.Peek(); if (currentLocomotion.LocomotionFinished) { locomotions.Pop(); } else { if (currentLocomotion.DuringAnimation) { currentLocomotion.UpdateAnimation(); return; } else { var steps = currentLocomotion.AdvanceJourney(_courseModel); var previousStep = steps.PreviousStep; var locomotionTarget = currentLocomotion.LocomotionTarget; if (previousStep != null) { if (previousStep.ShouldRemoveUnitAfterStep(_courseModel)) { locomotionTarget.PawnModel.SetUnitKilled(); locomotions.Pop(); return; } } if (steps.NextStep != null) { var battleResults = steps.NextStep.ApplyStepToModel(_courseModel, locomotionTarget); _unitLocomotions = new Stack <LocomotionManager <UnitModelComponent> >(_unitLocomotions .Where(c => !battleResults.UnitWasStruck(c.LocomotionTarget.Model)).Reverse()); foreach (var engagement in battleResults.Engagements) { var engagementResult = engagement.EngagementResult; var innerAnimations = engagement.EngagementElements.Select(element => { var active = GetPawnModelComponent(element.ActivePawn); var passive = GetPawnModelComponent(element.PassivePawn); return(element.EngagementVisibleConsequence.EngagementAnimation(_courseModel, MasterSound, active, passive)); }).ToList(); innerAnimations.AddRange(engagementResult.StruckUnits.Select(c => new UnitStruckAnimation(_unitModelToGameObjectMap[c]))); var anim = new CompositeAnimation(innerAnimations); _soloAnimations.Push(anim); if (_soloAnimations.Count >= 1) { _soloAnimations.Peek().StartAnimation(); } engagementResult.StruckUnits.ForEach(c => { _unitLocomotions.Push(LocomotionUtils.CreateDeathJourney(_unitModelToGameObjectMap[c])); }); engagementResult.Displacements.ForEach(c => { _unitLocomotions.Push(LocomotionUtils.CreatePushJourney(_courseModel, _unitModelToGameObjectMap[c.Unit], c.DisplacementEnd)); }); engagementResult.Projectiles.ForEach(c => { var projectile = AddProjectile(c); _projectileLocomotions.Push(LocomotionUtils.CreateProjectileJourney(projectile, c.EndPosition, c.Type)); }); } } } } } }
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)); } }