public void ReceivedCommand(RaftPush.MoveDirection direction, float rotation) { this._direction = direction; this._rotation = rotation; this._activeCommandTime = Time.realtimeSinceStartup + this._commandDuration; base.enabled = true; }
public void PushRaft(RaftPush.MoveDirection dir) { if (dir == RaftPush.MoveDirection.Forward) { this._direction = this._raft.transform.forward; } else { if (dir != RaftPush.MoveDirection.Backward) { return; } this._direction = this._raft.transform.forward * -1f; } this._direction.y = 0f; this._direction *= this._speed * 1.25f; Vector3 velocity = this._rb.velocity; Vector3 target = this._direction - velocity; Vector3 vector = Vector3.zero; Vector3 zero = Vector3.zero; vector = Vector3.SmoothDamp(vector, target, ref zero, this._dampSpeed); this._rb.AddForce(vector, this._forceMode); if (this._rb.velocity.magnitude > this._maxVelocity) { Vector3 vector2 = this._rb.velocity.normalized; vector2 *= this._maxVelocity; this._rb.velocity = vector2; } }
private void UpdateDirectionMp(float axisD, RaftPush.MoveDirection dir) { if (BoltNetwork.isRunning && (!Mathf.Approximately(axisD, 0f) || this.allowDirection)) { RaftControl raftControl = RaftControl.Create(GlobalTargets.OnlyServer); raftControl.OarId = this._oarId; raftControl.Rotation = axisD; raftControl.Movement = (int)dir; raftControl.Raft = base.GetComponentInParent <BoltEntity>(); raftControl.Send(); } }
public void PushRaft(RaftPush.MoveDirection dir) { if (dir == RaftPush.MoveDirection.Forward) { this._direction = ((!this._relativeForce) ? this._raft.transform.forward : base.transform.forward); } else { if (dir != RaftPush.MoveDirection.Backward) { return; } this._direction = ((!this._relativeForce) ? this._raft.transform.forward : base.transform.forward) * -1f; } this._direction.y = 0f; float num = 1f; if (!this._buoyancy.InWater) { num = 0f; } this._direction *= this._speed * 2f * num; Vector3 velocity = this._rb.velocity; Vector3 target = this._direction - velocity; Vector3 vector = Vector3.zero; Vector3 zero = Vector3.zero; vector = Vector3.SmoothDamp(vector, target, ref zero, this._dampSpeed); if (this.UseRelativeForce) { Vector3 position = base.transform.position; if (this._buoyancy.OverrideCenterOfMass != null) { position.y = this._buoyancy.OverrideCenterOfMass.position.y; } this._rb.AddForceAtPosition(vector * (0.016666f / Time.fixedDeltaTime), position, this._forceMode); } else { this._rb.AddForce(vector * (0.016666f / Time.fixedDeltaTime), this._forceMode); } if (this._rb.velocity.magnitude > this._maxVelocity) { Vector3 vector2 = this._rb.velocity.normalized; vector2 *= this._maxVelocity; this._rb.velocity = vector2; } }
private void Update() { if ((this._state == RaftPush.States.DriverStanding || this._state == RaftPush.States.Idle) && !this._doingOutOfWorld) { this.allowDirection = false; } if (this._state == RaftPush.States.DriverStanding) { LocalPlayer.AnimControl.standingOnRaft = true; } else { LocalPlayer.AnimControl.standingOnRaft = false; } bool flag = this._isGrabbed && this._state == RaftPush.States.DriverStanding; if (flag && BoltNetwork.isRunning && base.state.GrabbedBy[this._oarId] != null) { flag = false; } if (!this._canLockIcon.gameObject.activeSelf.Equals(flag)) { this._canLockIcon.gameObject.SetActive(flag); } if (this._shouldUnlock) { this._shouldUnlock = false; if (BoltNetwork.isRunning) { RaftGrab raftGrab = RaftGrab.Create(GlobalTargets.OnlyServer); raftGrab.OarId = this._oarId; raftGrab.Raft = base.GetComponentInParent <BoltEntity>(); raftGrab.Player = null; raftGrab.Send(); } else { this.offRaft(); } return; } this._shouldUnlock = false; if (this.stickToRaft) { LocalPlayer.FpCharacter.enabled = false; LocalPlayer.AnimControl.controller.useGravity = false; LocalPlayer.AnimControl.controller.isKinematic = true; Vector3 position = this._driverPos.position; position.y += LocalPlayer.AnimControl.playerCollider.height / 2f - LocalPlayer.AnimControl.playerCollider.center.y; LocalPlayer.Transform.position = position; LocalPlayer.Transform.rotation = this._driverPos.rotation; LocalPlayer.Animator.SetLayerWeightReflected(2, 1f); } if (TheForest.Utils.Input.GetButtonDown("Take") && !this._doingOutOfWorld) { if (flag) { if (BoltNetwork.isRunning) { RaftGrab raftGrab2 = RaftGrab.Create(GlobalTargets.OnlyServer); raftGrab2.OarId = this._oarId; raftGrab2.Raft = base.GetComponentInParent <BoltEntity>(); raftGrab2.Player = LocalPlayer.Entity; raftGrab2.Send(); } else { this.onRaft(); } } else if (this._state == RaftPush.States.DriverLocked) { if (BoltNetwork.isRunning) { RaftGrab raftGrab3 = RaftGrab.Create(GlobalTargets.OnlyServer); raftGrab3.OarId = this._oarId; raftGrab3.Raft = base.GetComponentInParent <BoltEntity>(); raftGrab3.Player = null; raftGrab3.Send(); } else { this.offRaft(); } } } else if (this._state == RaftPush.States.DriverLocked && !this._doingOutOfWorld) { RaftPush.MoveDirection moveDirection = RaftPush.MoveDirection.None; bool flag2 = false; if (Vector3.Angle(this._raft.transform.up, Vector3.up) > 45f) { flag2 = true; } float num = TheForest.Utils.Input.GetAxis("Horizontal"); if (flag2) { num = 0f; } this.axisDirection = num; this.moveDirection = moveDirection; if ((TheForest.Utils.Input.GetButton("Fire1") || TheForest.Utils.Input.GetButton("AltFire")) && !flag2) { if (this.CheckDistanceFromOceanCollision() || LocalPlayer.AnimControl.doneOutOfWorldRoutine || !LocalPlayer.Inventory.Owns(LocalPlayer.AnimControl._timmyPhotoId, true)) { moveDirection = ((!TheForest.Utils.Input.GetButton("Fire1")) ? RaftPush.MoveDirection.Backward : RaftPush.MoveDirection.Forward); this.allowDirection = true; this.moveDirection = moveDirection; this._driver.enablePaddleOnRaft(true); } else { this.allowDirection = false; this._driver.enablePaddleOnRaft(false); if (!this._doingOutOfWorld) { base.StartCoroutine(this.outOfWorldRoutine()); } } } else { this.allowDirection = false; this._driver.enablePaddleOnRaft(false); } } else if (this._state == RaftPush.States.Auto) { this._direction = Scene.OceanCeto.transform.position - base.transform.position; this._direction.Normalize(); this._raft.GetComponent <Rigidbody>().AddForce(this._direction * this._speed * 5f, ForceMode.Impulse); if (this.CheckDistanceFromOceanCollision()) { this._state = RaftPush.States.DriverLocked; } } }
private void Update() { bool flag = this._isGrabbed && this._state == RaftPush.States.DriverStanding && this.InWater; if (flag && BoltNetwork.isRunning && base.state.GrabbedBy != null) { flag = false; } if (!this._canLockIcon.gameObject.activeSelf.Equals(flag)) { this._canLockIcon.gameObject.SetActive(flag); } if (this._shouldUnlock) { this._shouldUnlock = false; if (BoltNetwork.isRunning) { RaftGrab raftGrab = RaftGrab.Create(GlobalTargets.OnlyServer); raftGrab.Raft = base.GetComponentInParent <BoltEntity>(); raftGrab.Player = null; raftGrab.Send(); } else { this.offRaft(); } return; } if (this._state == RaftPush.States.DriverLocked && !this.InWater) { this._shouldUnlock = true; } else { this._shouldUnlock = false; } if (this.stickToRaft) { LocalPlayer.FpCharacter.enabled = false; LocalPlayer.AnimControl.controller.useGravity = false; LocalPlayer.AnimControl.controller.isKinematic = true; Vector3 position = this._driverPos.position; position.y += LocalPlayer.AnimControl.playerCollider.height / 2f - LocalPlayer.AnimControl.playerCollider.center.y; LocalPlayer.Transform.position = position; LocalPlayer.Transform.rotation = this._driverPos.rotation; LocalPlayer.Animator.SetLayerWeightReflected(2, 1f); } if (TheForest.Utils.Input.GetButtonDown("Take")) { if (flag) { if (BoltNetwork.isRunning) { RaftGrab raftGrab2 = RaftGrab.Create(GlobalTargets.OnlyServer); raftGrab2.Raft = base.GetComponentInParent <BoltEntity>(); raftGrab2.Player = LocalPlayer.Entity; raftGrab2.Send(); } else { this.onRaft(); } } else if (this._state == RaftPush.States.DriverLocked) { if (BoltNetwork.isRunning) { RaftGrab raftGrab3 = RaftGrab.Create(GlobalTargets.OnlyServer); raftGrab3.Raft = base.GetComponentInParent <BoltEntity>(); raftGrab3.Player = null; raftGrab3.Send(); } else { this.offRaft(); } } } else if (this._state == RaftPush.States.DriverLocked) { RaftControl raftControl = null; bool flag2 = false; RaftPush.MoveDirection moveDirection = RaftPush.MoveDirection.None; float axis = TheForest.Utils.Input.GetAxis("Horizontal"); if (!BoltNetwork.isRunning) { this.TurnRaft(axis); } if (TheForest.Utils.Input.GetButton("Fire1") || TheForest.Utils.Input.GetButton("AltFire")) { if (this.CheckDistanceFromOceanCenter()) { moveDirection = ((!TheForest.Utils.Input.GetButton("Fire1")) ? RaftPush.MoveDirection.Backward : RaftPush.MoveDirection.Forward); if (!BoltNetwork.isRunning) { this.PushRaft(moveDirection); } this._driver.enablePaddleOnRaft(true); flag2 = true; } } else { this._driver.enablePaddleOnRaft(false); } if (BoltNetwork.isRunning && (!Mathf.Approximately(axis, 0f) || flag2)) { if (BoltNetwork.isRunning) { raftControl = RaftControl.Create(GlobalTargets.OnlyServer); } raftControl.Rotation = axis; raftControl.Movement = (int)moveDirection; raftControl.Raft = base.GetComponentInParent <BoltEntity>(); raftControl.Send(); } } else if (this._state == RaftPush.States.Auto) { this._direction = Scene.OceanCeto.transform.position - base.transform.position; this._direction.Normalize(); this._raft.GetComponent <Rigidbody>().AddForce(this._direction * this._speed * 5f, ForceMode.Impulse); if (this.CheckDistanceFromOceanCenter()) { this._state = RaftPush.States.DriverLocked; } } }