public override void SetupAfterLoad(int index) { base.SetupAfterLoad(index); if (this.m_Loaded) { if (BowController.Get().IsActive()) { BowController.Get().SetArrow(this); return; } InventoryBackpack.Get().InsertItem(this, null, null, true, true, true, true, true); } }
public PlayerController GetLocalActiveControllerAnimClipReplacer() { if (BowController.Get().enabled) { return(BowController.Get()); } if (HeavyObjectController.Get().enabled) { return(HeavyObjectController.Get()); } if (ItemController.Get().enabled) { return(ItemController.Get()); } if (WeaponMeleeController.Get().enabled) { return(WeaponMeleeController.Get()); } if (WeaponSpearController.Get().enabled) { return(WeaponSpearController.Get()); } return(null); }
private void UpdateWantedSpeed() { if (!this.IsActive() || (FreeHandsLadderController.Get().IsActive() && !this.m_JumpInProgress)) { this.m_WantedSpeed.Reset(); this.m_SlidingSpeedSoft.Reset(); this.m_SlideDir = Vector3.zero; this.m_CurentMoveSpeed = 0f; this.m_CurrentMoveSpeed = MoveSpeed.Idle; return; } Vector2 vector = new Vector2(this.m_Inputs.m_Horizontal, this.m_Inputs.m_Vertical); if (vector.sqrMagnitude > 1f) { vector.Normalize(); } bool flag = (this.m_CollisionFlags & CollisionFlags.Below) == CollisionFlags.None; bool flag2 = !flag && (this.m_CollisionFlagsAddSpeed & CollisionFlags.Below) == CollisionFlags.None; bool flag3 = this.m_Inputs.m_Sprint; float num = 0f; this.m_CurrentMoveSpeed = MoveSpeed.Idle; bool flag4 = this.m_Player && this.m_Player.GetMovesBlocked(); if (this.m_RunDepletedStamina) { if (flag3) { flag3 = false; } else { this.m_RunDepletedStamina = false; } } if (BowController.Get().m_MaxAim) { flag3 = false; } if (flag3 && this.m_RunBlocked) { flag3 = false; } if (!flag4 && vector.magnitude > 0.5f) { if (flag3) { if (vector.y < -0.5f) { num = this.m_BackwardWalkSpeed; this.m_CurrentMoveSpeed = MoveSpeed.Walk; } else { num = this.m_RunSpeed; this.m_CurrentMoveSpeed = MoveSpeed.Run; } } else if (vector.magnitude > 0.5f) { num = ((vector.y >= 0f) ? this.m_WalkSpeed : this.m_BackwardWalkSpeed); this.m_CurrentMoveSpeed = MoveSpeed.Walk; } if (this.m_Player && this.m_Player.IsStaminaDepleted()) { num = this.m_WalkSpeed; this.m_CurrentMoveSpeed = MoveSpeed.Walk; if (flag3) { this.m_RunDepletedStamina = true; } } } if (this.m_Duck) { num *= this.m_DuckSpeedMul; } Vector3 vector2 = this.m_CharacterController.transform.InverseTransformVector(this.m_WantedSpeed.target); vector2.x = vector.x * num; vector2.z = vector.y * num; if (this.m_Dodge) { num = 10f; if (this.m_DodgeDirection != Direction.Backward) { vector2.x = ((this.m_DodgeDirection == Direction.Right) ? 1f : -1f); vector2.z = 0f; } else { vector2.x = 0f; vector2.z = -1f; } if (Time.time - this.m_DodgeStartTime > 0.15f) { this.m_Dodge = false; } } float y = vector2.y; vector2.y = 0f; vector2.Normalize(); vector2 *= num; vector2.y = y; if (InventoryBackpack.Get().IsMaxOverload()) { vector2 *= this.m_MaxOverloadSpeedMul; } bool flag5 = this.m_TimeInAir < 0.5f; if (flag5) { this.m_WantedSpeed.target = this.m_CharacterController.transform.TransformVector(vector2); } if (flag2) { this.m_SlideDir = this.m_AdditionalSpeed.normalized; } else if (!flag) { this.m_SlideDir = Vector3.zero; } if (flag || (!this.m_SlideDir.IsZero() && flag2)) { Vector3 vector3 = this.m_WantedSpeed.target; vector3.y = 0f; Vector3 slideDir = this.m_SlideDir; slideDir.y = 0f; if (Vector3.Dot(vector3, slideDir) < 0f) { Vector3 normalized = Vector3.Cross(slideDir, Vector3.up).normalized; vector3 = Vector3.Dot(vector3, normalized) * normalized; this.m_WantedSpeed.target.x = vector3.x; this.m_WantedSpeed.target.z = vector3.z; } } if (Time.timeScale > 0f) { if (this.m_SlideDir.IsZero()) { this.m_SlidingSpeedSoft.target = Vector3.zero; this.m_SlidingSpeedSoft.omega = this.m_SlideDeceleration; } else { float proportionalClamp = CJTools.Math.GetProportionalClamp(0f, 1f, this.m_SlideAngle, this.m_CharacterController.slopeLimit, this.m_CharacterController.slopeLimit + 20f); this.m_SlidingSpeedSoft.target = this.m_SlideDir * this.m_SlideMaxSpeed * Mathf.Lerp(0.2f, 1f, proportionalClamp); this.m_SlidingSpeedSoft.omega = Mathf.Lerp(this.m_SlideAcceleration * 0.1f, this.m_SlideAcceleration, proportionalClamp); } if (!flag5) { this.m_WantedSpeed.target = this.m_WantedSpeed.target - this.m_SlidingSpeedSoft; } this.m_SlidingSpeedSoft.Update(Time.deltaTime / Time.timeScale); this.m_WantedSpeed.target = this.m_WantedSpeed.target + this.m_SlidingSpeedSoft; } if (this.m_Player.m_UseGravity) { this.m_WantedSpeed.target = this.m_WantedSpeed.target + Physics.gravity * Time.deltaTime; } else { this.m_WantedSpeed.current.x = (this.m_WantedSpeed.target.x = 0f); this.m_WantedSpeed.current.y = (this.m_WantedSpeed.target.y = 0f); this.m_WantedSpeed.current.z = (this.m_WantedSpeed.target.z = 0f); } if (this.m_WantedSpeed.target.y < -10f) { this.m_WantedSpeed.target.y = -10f; } Vector3 b = Vector3.zero; if (!this.m_Player.GetMovesBlocked() && this.m_CharacterController.detectCollisions && !this.m_SkipCompensation && !FreeHandsLadderController.Get().IsActive()) { b = -this.m_CharacterController.transform.TransformVector(this.m_Player.m_CharacterControllerDelta); } b.y = 0f; if ((this.m_CollisionFlags & CollisionFlags.Below) == CollisionFlags.None) { this.m_WantedSpeed.omega = this.m_AccelerationInAir; this.m_WantedPos.omega = this.m_AccelerationInAir; } else if (this.m_Dodge) { this.m_WantedSpeed.omega = this.m_DodgeAcceleration; this.m_WantedPos.omega = this.m_DodgeAcceleration; } else { this.m_WantedSpeed.omega = this.m_Acceleration; this.m_WantedPos.omega = this.m_PositionAcceleration; } if (Time.timeScale > 0f) { this.m_WantedSpeed.Update(Time.deltaTime / Time.timeScale); } this.m_CurentMoveSpeed = this.m_WantedSpeed.current.To2D().magnitude; this.m_CollisionFlagsAddSpeed = CollisionFlags.None; this.m_SlideAngle = 0f; this.m_AdditionalSpeed = Vector3.zero; this.m_CollisionFlags = this.m_CharacterController.Move(this.m_Player.m_SpeedMul * this.m_WantedSpeed.current * Time.deltaTime, false); Vector2.zero.Set(this.m_WantedSpeed.current.x, this.m_WantedSpeed.current.z); if ((this.m_CollisionFlags & CollisionFlags.Sides) != CollisionFlags.None) { this.m_LastSideCollisionTime = Time.time; } if ((this.m_CollisionFlags & CollisionFlags.Below) != CollisionFlags.None && (this.m_LastCollisionFlags & CollisionFlags.Below) == CollisionFlags.None) { this.m_Player.OnLanding(this.m_CharacterController.velocity); this.m_JumpInProgress = false; } if ((this.m_CollisionFlags & CollisionFlags.Below) != CollisionFlags.None) { this.m_TimeInAir = 0f; } else { this.m_TimeInAir += Time.deltaTime; } this.m_LastCollisionFlags = this.m_CollisionFlags; this.m_SkipCompensation = false; this.m_WantedPos.current = base.transform.position; this.m_WantedPos.target = this.m_CharacterController.transform.position + b; if (Time.timeScale > 0f) { this.m_WantedPos.Update(Time.deltaTime / Time.timeScale); } base.transform.position = this.m_WantedPos.current; }