Esempio n. 1
0
 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();
     }
 }
Esempio n. 2
0
    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;
            }
        }
    }