public void TryToTransitToOtherBaseState(bool checkHasAnyControl, BaseMonoEntity attackTarget = null) { BaseFollowBaseState targetBaseState = this.GetTargetBaseState(checkHasAnyControl, attackTarget); if (targetBaseState != null) { this.TransitBaseState(targetBaseState, false); } }
public void TransitBaseState(BaseFollowBaseState toSubState, bool forceTransit = false) { if (this.CanBaseStateTransit(toSubState, forceTransit)) { if (this._nextBaseState != null) { } this._nextBaseState = toSubState; } }
private bool CanBaseStateTransit(BaseFollowBaseState toSubState, bool forceTransit = false) { if (!forceTransit) { if ((this._baseState == this.followAvatarState) && (toSubState == this.followAvatarState)) { return(false); } if (toSubState == this.followAvatarControlledRotate) { return(true); } if (this._baseState == this.followAvatarAndBossState) { return(false); } if (this._baseState == this.followAvatarAndCrowdState) { return(false); } } return(true); }
public override void Enter() { this.followCenterXZPosition = this.avatar.XZPosition; this.lastBaseState = this._baseState; this._baseState = this.GetTargetBaseState(false, this.avatar.AttackTarget); this._baseState.SetActive(true); this._baseState.Enter(); this.lastBaseState = null; this._lastFollowCenters = new Vector3[3]; if (this.needLPF) { for (int i = 0; i < this._lastFollowCenters.Length; i++) { this._lastFollowCenters[i] = this.followCenterXZPosition; } } if (this._enterPolarMode == EnterPolarMode.AlongAvatarFacing) { Vector3 faceDirection = this.avatar.FaceDirection; this.anchorPolar = Mathf.Atan2(-faceDirection.z, -faceDirection.x) * 57.29578f; } else if (this._enterPolarMode == EnterPolarMode.NearestPointOnSphere) { Vector3 vector3 = base._owner.transform.position - this.followCenterXZPosition; Vector3 normalized = vector3.normalized; this.anchorPolar = Mathf.Atan2(normalized.z, normalized.x) * 57.29578f; } else if (this._enterPolarMode == EnterPolarMode.AlongTargetPolar) { this.anchorPolar = this._enterPolarArgument; } this.ConvertToFollowData(); base.cameraPosition = this.followData.cameraPosition; base.cameraForward = this.followData.cameraForward; base.cameraFOV = base._owner.originalFOV; this._stableModeCDTimer = 0f; }
public override void Update() { if (this.needLPF) { for (int i = this._lastFollowCenters.Length - 1; i > 0; i--) { this._lastFollowCenters[i] = this._lastFollowCenters[i - 1]; } this._lastFollowCenters[0] = this.followCenterXZPosition; } Vector3 followCenterXZPosition = this.followCenterXZPosition; this.followCenterXZPosition = this.avatar.XZPosition; Vector3 vector2 = followCenterXZPosition - this.followCenterXZPosition; this.needLerpPositionThisFrame = true; this.needLerpForwardThisFrame = true; this.needSmoothFollowCenterThisFrame = false; this.SubStateTransitionUpdate(); if (this.recoverState.active) { this.recoverState.Update(); } if (this._nextBaseState != null) { this._baseState.Exit(); this._baseState.SetActive(false); this.lastBaseState = this._baseState; this._baseState = this._nextBaseState; this._baseState.Enter(); this._baseState.SetActive(true); this._nextBaseState = null; if ((this._shortState != null) && this._baseState.maskedShortStates.Contains(this._shortState)) { this.RemoveShortState(); } } if (this._shortState != null) { this._shortState.Update(); bool isSkippingBaseState = false; if (this._shortState != null) { isSkippingBaseState = this._shortState.isSkippingBaseState; } if (!isSkippingBaseState || this._baseState.cannotBeSkipped) { this._baseState.Update(); } if (this._shortState != null) { this._shortState.PostUpdate(); } } else { this._baseState.Update(); } if (this.needLPF && this.needSmoothFollowCenterThisFrame) { Vector3 vector3 = this.followCenterXZPosition; for (int j = 0; j < this._lastFollowCenters.Length; j++) { vector3 += this._lastFollowCenters[j]; } this.followCenterXZPosition = (Vector3)(vector3 / ((float)(this._lastFollowCenters.Length + 1))); UnityEngine.Debug.DrawLine(this.followCenterXZPosition, this.followCenterXZPosition + Vector3.up); } this.ConvertToFollowData(); Vector3 cameraPosition = this.followData.cameraPosition; Vector3 cameraForward = this.followData.cameraForward; Vector3 vector6 = cameraPosition - this.followData.followCenterPosition; float magnitude = vector6.magnitude; if (Physics.Raycast(this.followData.followCenterPosition, -this.followData.cameraForwardNoForwardDelta, out this._wallHit, magnitude, ((int)1) << InLevelData.CAMERA_COLLIDER_LAYER)) { float num4 = magnitude - this._wallHit.distance; cameraPosition = Vector3.Lerp(this._wallHit.point, cameraPosition, 0.1f); cameraPosition.y += num4 * 0.1f; base._owner.cameraComponent.nearClipPlane = Mathf.Lerp(base._owner.originalNearClip, 0.01f, num4 / magnitude); Vector3 axis = Vector3.Cross(Vector3.up, base.cameraForward); cameraForward = (Vector3)(Quaternion.AngleAxis((0.05f * num4) * 57.29578f, axis) * cameraForward); cameraForward.Normalize(); base.cameraShakeRatio = 1f - (num4 / magnitude); } else { base._owner.cameraComponent.nearClipPlane = base._owner.originalNearClip; } float num5 = Time.deltaTime * base._owner.TimeScale; float num6 = (num5 != 0f) ? (vector2.magnitude / Time.deltaTime) : 0f; float num7 = Miscs.NormalizedClamp(num6, 5f, 12f); if (this.needLerpPositionThisFrame) { float num8 = ((Time.deltaTime * 7.9f) * (1f + num7)) * this.posLerpRatio; Vector3 a = base.cameraPosition - this.followData.followCenterPosition; Vector3 b = cameraPosition - this.followData.followCenterPosition; Vector3 vector10 = Vector3.Slerp(a, b, Mathf.Clamp01(num8)); base.cameraPosition = vector10 + this.followData.followCenterPosition; this.lerpPositionOvershootLastFrame = num8 >= 1f; } else { base.cameraPosition = cameraPosition; } if (this.needLerpForwardThisFrame) { float num9 = ((Time.deltaTime * 5f) * (1f + num7)) * this.forwardLerpRatio; this.cameraForward.Normalize(); cameraForward.Normalize(); base.cameraForward = MonoMainCamera.CameraForwardLerp(base.cameraForward, cameraForward, Mathf.Clamp01(num9)); this.lerpForwardOvershootLastFrame = num9 >= 1f; } else if (this.focusOnAvatar) { Vector3 vector11 = this.followData.followCenterPosition - base.cameraPosition; base.cameraForward = vector11; this.cameraForward.Normalize(); } else { base.cameraForward = cameraForward; } if (base.cameraFOV > 0f) { base._owner.cameraComponent.fieldOfView = base.cameraFOV; } }