예제 #1
0
        // ReSharper disable once UnusedMember.Local
        private void Update()
        {
            try
            {
                if (BoltNetwork.isRunning && LocalPlayer.Entity != null && LocalPlayer.Entity.isAttached)
                {
                    PlayerName = LocalPlayer.Entity.GetState <IPlayerState>().name;
                }
            }
            catch (Exception)
            {
                // ignored
            }

            if (ChatBox.IsChatOpen)
            {
                return;
            }

            if (OnTick != null)
            {
                try
                {
                    foreach (var action in OnTick.GetInvocationList())
                    {
                        try
                        {
                            action.DynamicInvoke(this, EventArgs.Empty);
                        }
                        catch (Exception e)
                        {
                            Logger.Exception($"Exception while notifying {nameof(OnTick)} listener: " + action.GetType().Name, e);
                        }
                    }
                }
                catch (Exception e)
                {
                    Logger.Exception($"Exception while looping over {nameof(OnTick)} listeners", e);
                }
            }

            if (BoltNetwork.isRunning)
            {
                // Visible player
                if (Menu.Values.Self.Visible && LocalPlayer.Entity != null && !LocalPlayer.Entity.isAttached)
                {
                    Utility.AttachLocalPlayer();
                }
                // Invisible player
                else if (!Menu.Values.Self.Visible && LocalPlayer.Entity != null && LocalPlayer.Entity.isAttached)
                {
                    Utility.DetachLocalPlayer();
                }

                // Add fire trail to movement
                if (Menu.Values.Self.FireTrail)
                {
                    var feetPos = LocalPlayer.Transform.position - new Vector3(0, 4, 0);
                    if (Vector3.Distance(LastFirePos, feetPos) > 2 || Environment.TickCount - LastFireTime > 5000)
                    {
                        LastFirePos  = feetPos;
                        LastFireTime = Environment.TickCount;
                        BoltPrefabsHelper.Spawn(BoltPrefabs.Fire, feetPos, LocalPlayer.Transform.rotation);
                    }
                }
            }

            if (FreeCam && !_lastFreeCam)
            {
                LocalPlayer.CamFollowHead.enabled = false;
                LocalPlayer.CamRotator.enabled    = false;
                LocalPlayer.MainRotator.enabled   = false;
                LocalPlayer.FpCharacter.enabled   = false;
                _lastFreeCam = true;
            }
            if (!FreeCam && _lastFreeCam)
            {
                LocalPlayer.CamFollowHead.enabled = true;
                LocalPlayer.CamRotator.enabled    = true;
                LocalPlayer.MainRotator.enabled   = true;
                LocalPlayer.FpCharacter.enabled   = true;
                _lastFreeCam = false;
            }

            if (FreeCam && !Menu.IsOpen && !LocalPlayer.FpCharacter.Locked)
            {
                var button1    = Input.GetButton("Crouch");
                var button2    = Input.GetButton("Run");
                var button3    = Input.GetButton("Jump");
                var multiplier = 0.1f;
                if (button2)
                {
                    multiplier = 2f;
                }

                var vector3 = Camera.main.transform.rotation * (
                    new Vector3(Input.GetAxis("Horizontal"),
                                0f,
                                Input.GetAxis("Vertical")
                                ) * multiplier);
                if (button3)
                {
                    vector3.y += multiplier;
                }
                if (button1)
                {
                    vector3.y -= multiplier;
                }
                Camera.main.transform.position += vector3;

                var rotationX = Camera.main.transform.localEulerAngles.y + Input.GetAxis("Mouse X") * 15f;
                _rotationY += Input.GetAxis("Mouse Y") * 15f;
                _rotationY  = Mathf.Clamp(_rotationY, -80f, 80f);
                Camera.main.transform.localEulerAngles = new Vector3(-_rotationY, rotationX, 0);
            }

            if (ModAPI.Input.GetButtonDown("FreeCam"))
            {
                FreeCam = !FreeCam;
            }

            if (ModAPI.Input.GetButton("SphereAction"))
            {
                SphereAction?.OnPrepare();
            }
            else
            {
                SphereAction?.OnTick();
            }

            if (LocalPlayer.Stats != null)
            {
                if (Menu.Values.Stats.FixBodyTemp)
                {
                    LocalPlayer.Stats.BodyTemp = Menu.Values.Stats.FixedBodyTemp;
                }
                if (Menu.Values.Stats.FixBatteryCharge)
                {
                    LocalPlayer.Stats.BatteryCharge = Menu.Values.Stats.FixedBatteryCharge;
                }
                if (Menu.Values.Stats.FixEnergy)
                {
                    LocalPlayer.Stats.Energy = Menu.Values.Stats.FixedEnergy;
                }
                if (Menu.Values.Stats.FixHealth)
                {
                    LocalPlayer.Stats.Health = Menu.Values.Stats.FixedHealth;
                }
                if (Menu.Values.Stats.FixStamina)
                {
                    LocalPlayer.Stats.Stamina = Menu.Values.Stats.FixedStamina;
                }
                if (Menu.Values.Stats.FixFullness)
                {
                    LocalPlayer.Stats.Fullness = Menu.Values.Stats.FixedFullness;
                }
                if (Menu.Values.Stats.FixStarvation)
                {
                    LocalPlayer.Stats.Starvation = Menu.Values.Stats.FixedStarvation;
                }
                if (Menu.Values.Stats.FixThirst)
                {
                    LocalPlayer.Stats.Thirst = Menu.Values.Stats.FixedThirst;
                }
            }

            if (BoltNetwork.isRunning && Menu.Values.Self.InstaRevive)
            {
                foreach (var player in PlayerManager.Players)
                {
                    var triggerObject = player.DeadTriggerObject;
                    if (triggerObject != null && triggerObject.activeSelf)
                    {
                        var trigger = triggerObject.GetComponent <RespawnDeadTrigger>();

                        //Logger.Info("Reviving " + player.Entity.GetState<IPlayerState>().name);

                        // Send revive packet
                        var playerHealed = PlayerHealed.Create(GlobalTargets.Others);
                        playerHealed.HealingItemId = trigger._healItemId;
                        playerHealed.HealTarget    = player.Entity;
                        PacketQueue.Add(playerHealed);

                        // Set revive trigger inactive
                        trigger.SendMessage("SetActive", false);
                    }
                }
            }
        }
예제 #2
0
        // ReSharper disable once UnusedMember.Local
        private void Update()
        {
            try
            {
                if (LocalPlayer.Entity != null && LocalPlayer.Entity.isAttached)
                {
                    PlayerName = LocalPlayer.Entity.GetState <IPlayerState>().name;
                }
            }
            catch (Exception)
            {
                // ignored
            }

            if (ChatBox.IsChatOpen)
            {
                return;
            }

            if (OnTick != null)
            {
                try
                {
                    foreach (var action in OnTick.GetInvocationList())
                    {
                        try
                        {
                            action.DynamicInvoke(this, EventArgs.Empty);
                        }
                        catch (Exception e)
                        {
                            Logger.Exception("Exception while notifying OnTick listener: " + action.GetType().Name, e);
                        }
                    }
                }
                catch (Exception e)
                {
                    Logger.Exception("Exception while looping over OnTick listeners", e);
                }
            }

            if (Menu.Values.Player.Visible && LocalPlayer.Entity != null && !LocalPlayer.Entity.isAttached)
            {
                Utility.AttachLocalPlayer();
            }
            else if (!Menu.Values.Player.Visible && LocalPlayer.Entity != null && LocalPlayer.Entity.isAttached)
            {
                Utility.DetachLocalPlayer();
            }

            if (FreezeTime && !LastFreezeTime)
            {
                Time.timeScale = 0f;
                LastFreezeTime = true;
            }
            if (!FreezeTime && LastFreezeTime)
            {
                Time.timeScale = 1f;
                LastFreezeTime = false;
            }

            if (Menu.Values.Other.FreeCam && !LastFreeCam)
            {
                LocalPlayer.CamFollowHead.enabled = false;
                LocalPlayer.CamRotator.enabled    = false;
                LocalPlayer.MainRotator.enabled   = false;
                LocalPlayer.FpCharacter.enabled   = false;
                LastFreeCam = true;
            }
            if (!Menu.Values.Other.FreeCam && LastFreeCam)
            {
                LocalPlayer.CamFollowHead.enabled = true;
                LocalPlayer.CamRotator.enabled    = true;
                LocalPlayer.MainRotator.enabled   = true;
                LocalPlayer.FpCharacter.enabled   = true;
                LastFreeCam = false;
            }

            if (Menu.Values.Other.FreeCam && !Menu.IsOpen && !LocalPlayer.FpCharacter.Locked)
            {
                var button1    = Input.GetButton("Crouch");
                var button2    = Input.GetButton("Run");
                var button3    = Input.GetButton("Jump");
                var multiplier = 0.1f;
                if (button2)
                {
                    multiplier = 2f;
                }

                var vector3 = Camera.main.transform.rotation * (
                    new Vector3(Input.GetAxis("Horizontal"),
                                0f,
                                Input.GetAxis("Vertical")
                                ) * multiplier);
                if (button3)
                {
                    vector3.y += multiplier;
                }
                if (button1)
                {
                    vector3.y -= multiplier;
                }
                Camera.main.transform.position += vector3;

                var rotationX = Camera.main.transform.localEulerAngles.y + Input.GetAxis("Mouse X") * 15f;
                RotationY += Input.GetAxis("Mouse Y") * 15f;
                RotationY  = Mathf.Clamp(RotationY, -80f, 80f);
                Camera.main.transform.localEulerAngles = new Vector3(-RotationY, rotationX, 0);
            }

            if (ModAPI.Input.GetButtonDown("FreezeTime"))
            {
                FreezeTime = !FreezeTime;
            }

            if (ModAPI.Input.GetButtonDown("FreeCam"))
            {
                Menu.Values.Other.FreeCam = !Menu.Values.Other.FreeCam;
            }
            if (ModAPI.Input.GetButton("SphereAction"))
            {
                SphereAction?.OnPrepare();
            }
            else
            {
                SphereAction?.OnTick();
            }
            if (Menu.Values.Stats.FixBodyTemp)
            {
                LocalPlayer.Stats.BodyTemp = Menu.Values.Stats.FixedBodyTemp;
            }
            if (Menu.Values.Stats.FixBatteryCharge)
            {
                LocalPlayer.Stats.BatteryCharge = Menu.Values.Stats.FixedBatteryCharge;
            }
            if (Menu.Values.Stats.FixEnergy)
            {
                LocalPlayer.Stats.Energy = Menu.Values.Stats.FixedEnergy;
            }
            if (Menu.Values.Stats.FixHealth)
            {
                LocalPlayer.Stats.Health = Menu.Values.Stats.FixedHealth;
            }
            if (Menu.Values.Stats.FixStamina)
            {
                LocalPlayer.Stats.Stamina = Menu.Values.Stats.FixedStamina;
            }
            if (Menu.Values.Stats.FixFullness)
            {
                LocalPlayer.Stats.Fullness = Menu.Values.Stats.FixedFullness;
            }
            if (Menu.Values.Stats.FixStarvation)
            {
                LocalPlayer.Stats.Starvation = Menu.Values.Stats.FixedStarvation;
            }
            if (Menu.Values.Stats.FixThirst)
            {
                LocalPlayer.Stats.Thirst = Menu.Values.Stats.FixedThirst;
            }
        }