コード例 #1
0
 private void Update()
 {
     if (base.state.CurrentView == 7)
     {
         if (TheForest.Utils.Input.GetButtonAfterDelay("Take", 2.5f, false))
         {
             LocalPlayer.Tuts.HideReviveMP();
             LocalPlayer.Sfx.PlayTwinkle();
             PlayerHealed playerHealed = PlayerHealed.Create(GlobalTargets.Others);
             playerHealed.HealingItemId = this._healItemId;
             playerHealed.HealTarget    = base.entity;
             playerHealed.Send();
             this.OnEnable();
             this.GrabExit();
             base.gameObject.SetActive(false);
             EventRegistry.Achievements.Publish(TfEvent.Achievements.RevivedPlayer, base.entity.source.RemoteEndPoint.SteamId.Id);
         }
         else if (!this._pickupIcon.activeSelf)
         {
             this._sheenIcon.SetActive(false);
             this._pickupIcon.SetActive(true);
         }
     }
     else if (this._sheenIcon.activeSelf || this._pickupIcon.activeSelf)
     {
         this._sheenIcon.SetActive(false);
         this._pickupIcon.SetActive(false);
         LocalPlayer.Tuts.HideReviveMP();
     }
 }
コード例 #2
0
 public override void OnEvent(PlayerHealed evnt)
 {
     if (evnt.HealTarget == LocalPlayer.Entity && !Scene.Cams.DeadCam.activeSelf)
     {
         LocalPlayer.Stats.HealedMp();
     }
 }
コード例 #3
0
 public static void OnPlayerHealed(float amount)
 {
     if (PlayerHealed != null)
     {
         PlayerHealed.Invoke(amount);
     }
 }
コード例 #4
0
    /// <summary>
    /// Add Health to the player
    /// </summary>
    /// <param name="healthToAdd">Health to add to the player</param>
    private void AddHealth(float healthToAdd)
    {
        //Set the players health to either the new health or
        //the max health
        float resultantHealth = playerHealth + healthToAdd;

        playerHealth = Mathf.Min(resultantHealth, playerMaxHealth);

        //Call Event
        PlayerHealed?.Invoke(playerHealth);
    }
コード例 #5
0
 public override void OnEvent(PlayerHealed evnt)
 {
     if (!this.ValidateSender(evnt, SenderTypes.Any))
     {
         return;
     }
     if (evnt.HealTarget == LocalPlayer.Entity && !TheForest.Utils.Scene.Cams.DeadCam.activeSelf)
     {
         LocalPlayer.Stats.HealedMp();
     }
 }
コード例 #6
0
 private void Update()
 {
     if (TheForest.Utils.Input.GetButtonAfterDelay("Take", 2.5f))
     {
         LocalPlayer.Tuts.HideReviveMP();
         LocalPlayer.Sfx.PlayTwinkle();
         PlayerHealed playerHealed = PlayerHealed.Raise(GlobalTargets.Others);
         playerHealed.HealingItemId = this._healItemId;
         playerHealed.HealTarget    = this._entity;
         playerHealed.Send();
         base.gameObject.SetActive(false);
     }
     else if (!this._pickupIcon.activeSelf)
     {
         this._sheenIcon.SetActive(false);
         this._pickupIcon.SetActive(true);
     }
 }
コード例 #7
0
ファイル: KillPlayer.cs プロジェクト: zonde306/Forest
        public static void ReviveSinglePlayer(ClientSide.Player player)
        {
            GameObject triggerObject = player.DeadTriggerObject;

            if (triggerObject != null && triggerObject.activeSelf)
            {
                RespawnDeadTrigger trigger = triggerObject.GetComponent <RespawnDeadTrigger>();

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

                // Set revive trigger inactive
                trigger.SendMessage("SetActive", false);
            }
        }
コード例 #8
0
        protected override void Update()
        {
            try
            {
                if (Menu.Values.Other.InstaRevive && RespawnDeadTrigger != null && RespawnDeadTrigger.activeSelf && RespawnDeadTrigger.GetComponent <RespawnDeadTrigger>() != null)
                {
                    LocalPlayer.Tuts.HideReviveMP();
                    var playerHealed = PlayerHealed.Create(GlobalTargets.Others);
                    playerHealed.HealingItemId = RespawnDeadTrigger.GetComponent <RespawnDeadTrigger>()._healItemId;
                    playerHealed.HealTarget    = entity;
                    playerHealed.Send();
                    RespawnDeadTrigger.SetActive(false);
                }
            }
            catch (Exception e)
            {
                Logger.Exception("Exception while reviving player '{0}'", e, entity?.GetState <IPlayerState>()?.name);
            }

            base.Update();
        }
コード例 #9
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);
                    }
                }
            }
        }