Example #1
0
 private void offRaft()
 {
     this._buoyancy.ForceValidateTriggers = false;
     if (LocalPlayer.AnimControl != null)
     {
         LocalPlayer.AnimControl.oarHeld.SetActive(false);
         LocalPlayer.AnimControl.currRaft = null;
     }
     base.Invoke("turnOffFoam", 3f);
     this._oar.SetActive(true);
     if (this._driver)
     {
         PlayerInventory component = this._driver.GetComponent <PlayerInventory>();
         component.EquipPreviousWeaponDelayed();
     }
     if (this.stickToRaft)
     {
         this.ShutDown();
     }
     base.GetComponent <Collider>().enabled = false;
     base.GetComponent <Collider>().enabled = true;
     if (this._floor)
     {
         this._floor.refreshPlayerOffset();
         this._floor.enabled = true;
     }
     if (BoltNetwork.isRunning && base.entity.isAttached && base.state.GrabbedBy[this._oarId] == LocalPlayer.Entity)
     {
         RaftGrab raftGrab = RaftGrab.Create(GlobalTargets.OnlyServer);
         raftGrab.OarId  = this._oarId;
         raftGrab.Raft   = base.GetComponentInParent <BoltEntity>();
         raftGrab.Player = null;
         raftGrab.Send();
     }
 }
Example #2
0
    private void offRaft()
    {
        PlayerInventory component = this._driver.GetComponent <PlayerInventory>();

        LocalPlayer.AnimControl.oarHeld.SetActive(false);
        LocalPlayer.AnimControl.currRaft = null;
        this._oar.SetActive(true);
        component.EquipPreviousWeaponDelayed();
        if (this.stickToRaft)
        {
            this.ShutDown();
        }
        base.GetComponent <Collider>().enabled = false;
        base.GetComponent <Collider>().enabled = true;
        if (BoltNetwork.isRunning && this.entity.isAttached && base.state.GrabbedBy == LocalPlayer.Entity)
        {
            RaftGrab raftGrab = RaftGrab.Create(GlobalTargets.OnlyServer);
            raftGrab.Raft   = base.GetComponentInParent <BoltEntity>();
            raftGrab.Player = null;
            raftGrab.Send();
        }
    }
Example #3
0
    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;
            }
        }
    }
Example #4
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;
            }
        }
    }