private void onRaft() { if (Vector3.Angle(this._raft.transform.up, Vector3.up) > 90f) { this._raft.transform.localEulerAngles = new Vector3(0f, this._raft.transform.localEulerAngles.y, 0f); } PlayerInventory component = this._driver.GetComponent <PlayerInventory>(); LocalPlayer.AnimControl.oarHeld.SetActive(true); LocalPlayer.AnimControl.currRaft = base.gameObject; this._oar.SetActive(false); LocalPlayer.Inventory.HideAllEquiped(false); LocalPlayer.FpCharacter.enabled = false; LocalPlayer.AnimControl.controller.useGravity = false; LocalPlayer.AnimControl.controller.isKinematic = true; LocalPlayer.AnimControl.controller.Sleep(); LocalPlayer.AnimControl.playerCollider.enabled = false; LocalPlayer.AnimControl.playerHeadCollider.enabled = false; LocalPlayer.Transform.parent = this._raft.transform; 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.MainRotator.enabled = false; LocalPlayer.CamRotator.rotationRange = new Vector2(100f, 130f); this._driver.OnRaft(); this._canLockIcon.gameObject.SetActive(false); this._state = RaftPush.States.DriverLocked; LocalPlayer.ScriptSetup.pmControl.FsmVariables.GetFsmBool("paddleBool").Value = true; this.stickToRaft = true; }
private void Awake() { base.enabled = false; this._state = RaftPush.States.Idle; this._direction = Vector3.zero; this._canLockIcon.gameObject.SetActive(false); this._rb = base.transform.parent.GetComponent <Rigidbody>(); }
private void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("Player") && this._state == RaftPush.States.Idle) { base.enabled = true; this._driver = LocalPlayer.FpCharacter; this._state = RaftPush.States.DriverStanding; this._canLockIcon.gameObject.SetActive(true); } }
private void OnTriggerExit(Collider other) { if (other.gameObject.CompareTag("Player") && (this._state == RaftPush.States.DriverStanding || this._state == RaftPush.States.Idle)) { if (this._driver == LocalPlayer.FpCharacter) { this.offRaft(); } base.enabled = false; this._state = RaftPush.States.Idle; this._canLockIcon.gameObject.SetActive(false); } }
private void ShutDown() { this._driver.OffRaft(); this._driver = null; this._state = RaftPush.States.Idle; LocalPlayer.Transform.parent = null; LocalPlayer.AnimControl.controller.useGravity = true; LocalPlayer.AnimControl.controller.isKinematic = false; LocalPlayer.AnimControl.controller.WakeUp(); LocalPlayer.FpCharacter.enabled = true; LocalPlayer.FpCharacter.Locked = false; LocalPlayer.MainRotator.resetOriginalRotation = true; LocalPlayer.MainRotator.enabled = true; LocalPlayer.AnimControl.playerCollider.enabled = true; LocalPlayer.AnimControl.playerHeadCollider.enabled = true; LocalPlayer.CamRotator.rotationRange = new Vector2(170f, 0f); LocalPlayer.ScriptSetup.pmControl.FsmVariables.GetFsmBool("paddleBool").Value = false; LocalPlayer.Animator.SetBoolReflected("paddleBool", false); this.stickToRaft = false; LocalPlayer.Transform.localEulerAngles = new Vector3(0f, LocalPlayer.Transform.localEulerAngles.y, 0f); this._canLockIcon.gameObject.SetActive(false); base.enabled = false; }
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; } } }