コード例 #1
0
        private void HealthRegen(UpdateTickedEventArgs e)
        {
            if (this.Config.Health.Enabled)
            {
                if (e.IsMultipleOf((uint)this.Config.Health.RegenRateInSeconds * 60))
                {
                    if (!this.Config.Health.DontCheckConditions)
                    {
                        // if player took damage
                        if (Game1.player.health < this.LastHealth.Value)
                        {
                            this.SecondsUntilHealthRegen = this.Config.Health.SecondsUntilRegenWhenTakenDamage;
                        }
                        //timer
                        else if (this.SecondsUntilHealthRegen > 0)
                        {
                            this.SecondsUntilHealthRegen--;
                        }
                        //regen
                        else if (this.SecondsUntilHealthRegen <= 0)
                        {
                            if (Game1.player.health < Game1.player.maxHealth)
                            {
                                Game1.player.health = Math.Min(Game1.player.maxHealth, Game1.player.health + this.Config.Health.HealthPerRegenRate);
                            }
                        }

                        this.LastHealth.Value = Game1.player.health;

                        if (this.DebugLogging)
                        {
                            this.Monitor.Log("Health Updated", LogLevel.Debug);
                            this.Monitor.Log($"Last Health: {LastHealth.ToString()} ");
                        }
                    }

                    else
                    {
                        Game1.player.health += this.Config.Health.HealthPerRegenRate;

                        if (this.DebugLogging)
                        {
                            this.Monitor.Log("Health Updated (No Regen Delay)", LogLevel.Debug);
                        }
                    }
                }
            }
        }
コード例 #2
0
        private void StaminaRegen(UpdateTickedEventArgs e)
        {
            if (this.Config.Stamina.Enabled)
            {
                if (e.IsMultipleOf((uint)this.Config.Stamina.RegenRateInSeconds * 60))
                {
                    if (!this.Config.Stamina.DontCheckConditions)
                    {
                        // if player used stamina
                        if (Game1.player.Stamina < this.LastStamina.Value)
                        {
                            this.SecondsUntilStaminaRegen = this.Config.Stamina.SecondsUntilRegenWhenUsedStamina;
                        }
                        //timer
                        else if (this.SecondsUntilStaminaRegen > 0)
                        {
                            this.SecondsUntilStaminaRegen--;
                        }
                        // regen
                        else if (this.SecondsUntilStaminaRegen <= 0)
                        {
                            if (Game1.player.Stamina < Game1.player.MaxStamina)
                            {
                                Game1.player.Stamina = Math.Min(Game1.player.MaxStamina, Game1.player.Stamina + this.Config.Stamina.StaminaPerRegenRate);
                            }
                        }

                        this.LastStamina.Value = Game1.player.Stamina;

                        if (this.DebugLogging)
                        {
                            this.Monitor.Log("Stamina Updated", LogLevel.Debug);
                            this.Monitor.Log($"Last Stamina: {LastStamina.ToString()}");
                        }
                    }

                    else
                    {
                        Game1.player.Stamina += this.Config.Stamina.StaminaPerRegenRate;

                        if (this.DebugLogging)
                        {
                            this.Monitor.Log("Stamina Updated (No Regen Delay)", LogLevel.Debug);
                        }
                    }
                }
            }
        }