Example #1
0
        RegenConfig myConfig;                  //Config data.

        public override void Entry(IModHelper helper)
        {
            myConfig = helper.ReadConfig <RegenConfig>();

            //Starting values at extremes which prevent unexpected behavior.
            lastStamina = 9999;
            //lastMaxStamina = 0.0;
            staminaCooldown = 0;

            lastHealth = 9999;
            //lastMaxHealth = 0;
            healthCooldown = 0;
            healthAccum    = 0.0;

            currentTime  = 0.0;
            timeElapsed  = 0.0;
            lastTickTime = 0.0;
            lastLogTime  = 0.0;

            updateTickCount = 1; //Avoids div by 0 errors

            helper.Events.GameLoop.GameLaunched += OnGameLaunched;
            helper.Events.GameLoop.SaveLoaded   += StartupTasks;
            helper.Events.GameLoop.DayStarted   += DailyUpdate;
            helper.Events.GameLoop.UpdateTicked += OnUpdate;    //Set to quarter-second intervals.

            Monitor.Log("ReRegeneration => Initialized", LogLevel.Info);
        }
Example #2
0
        private void TryLoadingGMCM()
        {
            //See if we can find GMCM, quit if not.
            var api = Helper.ModRegistry.GetApi <GenericModConfigMenu.GenericModConfigMenuAPI>("spacechase0.GenericModConfigMenu");

            if (api == null)
            {
                Monitor.Log("Unable to load GMCM API.", LogLevel.Info);
                return;
            }

            api.RegisterModConfig(ModManifest, () => myConfig = new RegenConfig(), () => Helper.WriteConfig(myConfig));

            //Basic Values
            api.RegisterLabel(ModManifest, "Basic Configuration", "Core settings for stamina and health regeneration.");
            api.RegisterClampedOption(ModManifest, "Stamina Regen/Sec", "How much stamina to regenerate passively per second. Use config file to enter values greater than 10.", () => myConfig.staminaRegenPerSecond, (float val) => myConfig.staminaRegenPerSecond      = val, 0, 10);
            api.RegisterClampedOption(ModManifest, "Stamina Idle Time", "How long to wait, in seconds, after an exertion to regen stamina. Use config file to enter values greater than 60.", () => myConfig.staminaIdleSeconds, (int val) => myConfig.staminaIdleSeconds = val, 1, 60);
            api.RegisterClampedOption(ModManifest, "Health Regen/Sec", "How much health to regenerate passively per second. Use config file to enter values greater than 10.", () => myConfig.healthRegenPerSecond, (float val) => myConfig.healthRegenPerSecond          = val, 0, 10);
            api.RegisterClampedOption(ModManifest, "Health Idle Time", "How long to wait, in seconds, after an injury to regen health. Use config file to enter values greater than 60.", () => myConfig.healthIdleSeconds, (int val) => myConfig.healthIdleSeconds       = val, 1, 60);

            //Advanced Values
            api.RegisterLabel(ModManifest, "Advanced Configuration", "More complex settings. Consult the readme to understand these.");
            api.RegisterSimpleOption(ModManifest, "Percentage Mode", "Whether to treat the regen values as percentages of max stamina/health. See readme for more details.", () => myConfig.percentageMode, (bool val) => myConfig.percentageMode     = val);
            api.RegisterClampedOption(ModManifest, "Max Stamina Ratio", "Percentage of player's maximum stamina that can be passively regenerated.", () => (int)(myConfig.maxStaminaRatioToRegen * 100), (int val) => myConfig.maxStaminaRatioToRegen = (float)val / 100, 1, 100);
            api.RegisterClampedOption(ModManifest, "Stamina Regen Scaling Rate", "See readme for an explanation of this entry.", () => (int)(myConfig.scaleStaminaRegenRateTo * 100), (int val) => myConfig.scaleStaminaRegenRateTo = (float)val / 100, 0, 100);
            api.RegisterClampedOption(ModManifest, "Stamina Delay Scaling Rate", "See readme for an explanation of this entry (use config file to enter value higher than 1.0 (i.e., 100%)).", () => (int)(myConfig.scaleStaminaRegenDelayTo * 100), (int val) => myConfig.scaleStaminaRegenDelayTo = (float)val / 100, 0, 100);
            api.RegisterClampedOption(ModManifest, "Max Health Ratio", "Percentage of player's maximum health that can be passively regenerated.", () => (int)(myConfig.maxHealthRatioToRegen * 100), (int val) => myConfig.maxHealthRatioToRegen = (float)val / 100, 1, 100);
            api.RegisterClampedOption(ModManifest, "Health Regen Scaling Rate", "See readme for an explanation of this entry.", () => (int)(myConfig.scaleHealthRegenRateTo * 100), (int val) => myConfig.scaleHealthRegenRateTo = (float)val / 100, 0, 100);
            api.RegisterClampedOption(ModManifest, "Health Delay Scaling Rate", "See readme for an explanation of this entry (use config file to enter value higher than 1.0 (i.e., 100%)).", () => (int)(myConfig.scaleHealthRegenDelayTo * 100), (int val) => myConfig.scaleHealthRegenDelayTo = (float)val / 100, 0, 100);
            api.RegisterClampedOption(ModManifest, "Active Regen Rate", "Rate of regeneration while fishing or riding a horse. See readme for an more info.", () => (int)(myConfig.regenWhileActiveRate * 100), (int val) => myConfig.regenWhileActiveRate = (float)val / 100, 0, 100);
            api.RegisterClampedOption(ModManifest, "Running Regen Rate", "Rate of regeneration while running. See readme for an more info.", () => (int)(myConfig.regenWhileRunningRate * 100), (int val) => myConfig.regenWhileRunningRate = (float)val / 100, 0, 100);
            api.RegisterClampedOption(ModManifest, "Exhaustion Penalty", "Percentage by which the amount of regeneration is decreased and the duration of the idle delay is increased while the player is exhausted. See readme for an more info.", () => (int)(myConfig.exhuastionPenalty * 100), (int val) => myConfig.exhuastionPenalty = (float)val / 100, 0, 100);
            api.RegisterClampedOption(ModManifest, "End Exhaustion At...", "At what percentage of max stamina should the exaustion penalty be removed. Enter 0 to disable this feature. See readme for an more info.", () => (int)(myConfig.endExhaustionAt * 100), (int val) => myConfig.endExhaustionAt = (float)val / 100, 0, 100);
            api.RegisterClampedOption(ModManifest, "Delay Stillness Bonus", "Shortens the regen delay while standing still by the specified percentage. Enter 0 to disable this feature. See readme for an more info.", () => (int)(myConfig.shortenDelayWhenStillBy * 100), (int val) => myConfig.lengthenDelayWhenRunningBy = (float)val / 100, 0, 100);
            api.RegisterClampedOption(ModManifest, "Delay Running Penalty", "Lengthens the regen delay while running by the specified percentage. Enter 0 to disable this feature. See readme for an more info. (Use config file to enter value higher than 1.0 (i.e., 100%).", () => (int)(myConfig.lengthenDelayWhenRunningBy * 100), (int val) => myConfig.lengthenDelayWhenRunningBy = (float)val / 100, 0, 100);
        }