コード例 #1
0
        /*********
        ** Public methods
        *********/
        /// <summary>The mod entry point, called after the mod is first loaded.</summary>
        /// <param name="helper">Provides simplified APIs for writing mods.</param>
        public override void Entry(IModHelper helper)
        {
            this.SprintBuff   = new Buff(0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, "Sprinting", "Sprinting");
            this.CooldownBuff = new Buff(0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -2, -2, 1, "Combat Dash Cooldown", "Combat Dash Cooldown");
            this.WindedBuff   = new Buff(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "Winded", "Winded");

            // read config
            this.Config       = helper.ReadConfig <SprintDashConfig>();
            this.StamCost     = Math.Max(1, this.Config.StamCost);
            this.DashDuration = Math.Max(1, Math.Min(10, this.Config.DashDuration)) * 1000; // 1-10 seconds
            this.DashCooldown = (int)(this.DashDuration * 2.5);
            this.WindedStep   = this.Config.WindedStep;
            if (this.WindedStep > 0)
            {
                this.EnableWindedness   = true;
                this.WindedCooldownStep = this.WindedStep * 200; //Recovering from winded-ness take 1/5 the time spent being winded.
                this.WindedStep        *= 1000;                  // convert config-based times to ms
            }
            this.EnableToggle = this.Config.ToggleMode;
            this.RunKey       = null;

            // hook events
            GameEvents.UpdateTick    += this.GameEvents_UpdateTick;
            ControlEvents.KeyPressed += this.ControlEvents_KeyPressed;

            // log info
            this.Monitor.Log($"Stamina cost: {this.StamCost}, dash duration: {this.DashDuration}, dash cooldown: {this.DashCooldown}, winded step: {this.WindedStep}, toggle mode: {this.EnableToggle}", LogLevel.Trace);
        }
コード例 #2
0
        private void StartupTasks(object sender, SaveLoadedEventArgs e)
        {
            myPlayer = Game1.player;
            myConfig = myHelper.ReadConfig <SprintDashConfig>();

            SprintButton = myConfig.SprintKey;
            DashButton   = myConfig.DashKey;

            StamCost     = Math.Max(1, myConfig.StamCost);
            DashDuration = Math.Min(10, myConfig.DashDuration) * 1000; // 1-10 seconds, < 0  turns off at later step.
            DashCooldown = (int)(DashDuration * 2.5);
            WindedStep   = Math.Max(0, myConfig.WindedStep);
            if (WindedStep > 0)
            {
                EnableWindedness   = true;
                WindedCooldownStep = WindedStep * 200; //Recovering from winded-ness take 1/5 the time spent being winded.
                WindedStep        *= 1000;             // convert config-based times to ms
            }
            MinStaminaToRefresh = Math.Max(0, Math.Min(0.99f, myConfig.QuitSprintingAt)) * myPlayer.maxStamina;
            EnableToggle        = myConfig.ToggleMode;

            //60 tick/sec, interval in 0-1 seconds acts as multiplier.
            IntervalTicks = Math.Max(1, Math.Min(60, (uint)(myConfig.TimeInterval * 60.0)));
            //Want a timeout that is slightly more than the interval. (1 itck is ~16.666.. ms)
            TimeoutCheck = 5 + Math.Max(17, Math.Min(1000, (int)(myConfig.TimeInterval * 1000)));

            Verbose = myConfig.VerboseMode;

            //This is complicated and necessary because SDV stores the run button as an array of buttons. Theoretically we may have more than one.
            if (RunKey == null)
            {
                RunKey = new Keys[Game1.options.runButton.Length];

                int i = 0;

                foreach (InputButton button in Game1.options.runButton)
                {
                    RunKey[i] = button.key;
                    i++;
                }
            }

            SaveHasLoaded = true;

            BasicConfigReport("Startup Tasks");
        }
コード例 #3
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 SprintDashConfig(), () => Helper.WriteConfig(myConfig));
            api.RegisterSimpleOption(ModManifest, "Sprint Button", "Set the button to use to sprint.", () => myConfig.SprintKey, (SButton val) => myConfig.SprintKey = val);
            api.RegisterSimpleOption(ModManifest, "Dash Button", "Set the button to use to dash.", () => myConfig.DashKey, (SButton val) => myConfig.DashKey         = val);
            api.RegisterClampedOption(ModManifest, "Stamina Cost", "Cost per second of sprinting. Use config file to enter values greater than 10.", () => myConfig.StamCost, (float val) => myConfig.StamCost = val, 1, 10);
            api.RegisterClampedOption(ModManifest, "Dash Duration", "How long the dash buff will last. Note that there is a cooldown/vulnerable phase 2.5x as long. Set to 0 to disable this feature.", () => myConfig.DashDuration, (int val) => myConfig.DashDuration = val, 0, 10);
            api.RegisterClampedOption(ModManifest, "Winded Step", "Values above 0 activate the 'winded' system, see reademe.txt for details. Use config file to enter values greater than 30.", () => myConfig.WindedStep, (int val) => myConfig.WindedStep             = val, 0, 30);
            api.RegisterClampedOption(ModManifest, "Sprint Requirement", "Stamina must be at least this percent of max stamina to run.", () => (int)(myConfig.QuitSprintingAt * 100), (int val) => myConfig.QuitSprintingAt = (float)val / 100, 0, 99);
            api.RegisterSimpleOption(ModManifest, "Toggle Mode", "This turns the sprint key into a toggle, such then you start sprinting when you press it and stop when you press it again.", () => myConfig.ToggleMode, (bool val) => myConfig.ToggleMode = val);
        }
コード例 #4
0
 private void OnGameLaunched(object sender, GameLaunchedEventArgs e)
 {
     myConfig = myHelper.ReadConfig <SprintDashConfig>();
     TryLoadingGMCM();
     BasicConfigReport("On Game Launched Event");
 }