Пример #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)
        {
            // Make resources available.
            Instance = this;
            ModConfig.Load();

            // Apply Harmony patches.
            Harmony = HarmonyInstance.Create(ModManifest.UniqueID);
            EventPatches.Apply();
            FarmPatches.Apply();
            ItemGrabMenuPatches.Apply();
            ObjectPatches.Apply();
            UtilityPatches.Apply();

            // Add console commands.
            ConsoleCommands.Apply();

            // Listen for game events.
            helper.Events.GameLoop.GameLaunched += this.onGameLaunched;
            helper.Events.GameLoop.UpdateTicked += this.onUpdateTicked;
            helper.Events.GameLoop.SaveLoaded   += this.onSaveLoaded;
            helper.Events.GameLoop.DayStarted   += this.onDayStarted;
            helper.Events.Player.Warped         += this.onWarped;

            // Set up early portrait asset editor - used if set to automatic.
            helper.Content.AssetEditors.Add(new PortraitEditor(overrideEdits: false));
        }
Пример #2
0
        /// <summary>Resets all event flags related to grandpa's evaluation(s) when the 'reset_evaluation' command is invoked.</summary>
        /// <param name="command">The name of the command invoked.</param>
        /// <param name="args">The arguments received by the command. Each word after the command name is a separate argument.</param>
        private static void cmdResetEvaluation(string _command, string[] _args)
        {
            try
            {
                if (!Context.IsWorldReady)
                {
                    throw new Exception("An active save is required.");
                }
                var eventsToRemove = new List <int>
                {
                    558291, 558292, 321777 // Initial eval, Re-eval, and Evaluation request
                };
                foreach (int e in eventsToRemove)
                {
                    while (Game1.player.eventsSeen.Contains(e))
                    {
                        Game1.player.eventsSeen.Remove(e);
                    }
                }
                // Game1.player.eventsSeen.Remove(2146991); // Candles (removed instead by command_grandpaEvaluation postfix)
                Game1.getFarm().hasSeenGrandpaNote = false;                  // Seen the note on the shrine
                while (Game1.player.mailReceived.Contains("grandpaPerfect")) // Received the statue of perfection
                {
                    Game1.player.mailReceived.Remove("grandpaPerfect");
                }
                Game1.getFarm().grandpaScore.Value = 0;                   // Reset grandpaScore
                FarmPatches.RemoveCandlesticks(Game1.getFarm());          // Removes all candlesticks (not flames).
                Game1.getFarm().removeTemporarySpritesWithIDLocal(6666f); // Removes candle flames.

                // Remove flags added by this mod
                var flagsToRemove = new List <string>
                {
                    "6324bonusRewardsEnabled", "6324reward2candles", "6324reward3candles",                                                                    // Old, outdated flags
                    "6324grandpaNoteMail", "6324reward1candle", "6324reward2candle", "6324reward3candle", "6324reward4candle", "6324hasDoneModdedEvaluation", // Current used flags
                };
                foreach (string flag in flagsToRemove)
                {
                    while (Game1.player.mailReceived.Contains(flag))
                    {
                        Game1.player.mailReceived.Remove(flag);
                    }
                }

                if (!Game1.player.eventsSeen.Contains(2146991))
                {
                    Game1.player.eventsSeen.Add(2146991); // Make sure they can't see candle event before the next evaluation.
                }

                Monitor.Log($"Reset grandpaScore and associated event and mail flags for all evaluations.", LogLevel.Info);
            }
            catch (Exception ex)
            {
                Monitor.Log($"Command reset_evaluation failed:\n{ex}", LogLevel.Warn);
            }
        }