Пример #1
0
        // BUG: player warps back to wizard hut after use
        private void OpenJunimoHutMenu()
        {
            var menu          = new CarpenterMenu(true);
            var blueprints    = Helper.Reflection.GetField <List <BluePrint> >(menu, "blueprints");
            var newBluePrints = new List <BluePrint> {
                new("Junimo Hut")
            };

            blueprints.SetValue(newBluePrints);
            Game1.activeClickableMenu = menu;
        }

        /// <summary>Raised after a game menu is opened, closed, or replaced.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        void OnMenuChanged(object sender, MenuChangedEventArgs e)
        {
            // closed Junimo Hut menu
            //
            // check that e.NewMenu is null because this event also fires when items are added to the chest
            // caution: this runs after any chest is closed, not just Junimo huts

            // closed menu
            if (e.OldMenu is ItemGrabMenu menu && e.NewMenu is null)
            {
                if (menu.context is not(JunimoHut or Chest))
                {
                    return;
                }
                if (menu.context is Chest chest &&
                    !chest.modData.ContainsKey($"{ModManifest.UniqueID}/JunimoChest"))
                {
                    return;
                }
                CheckHutsForWagesAndProgressionItems();
                JunimoAbilities.ResetCooldowns();
            }

            // opened menu
            if (e.OldMenu != null || e.NewMenu is not CarpenterMenu)
            {
                return;
            }
            if (!Helper.Reflection.GetField <bool>(e.NewMenu, "magicalConstruction").GetValue())
            {
                return;
            }
            // limit to only junimo hut
            if (!Game1.MasterPlayer.mailReceived.Contains("hasPickedUpMagicInk"))
            {
                OpenJunimoHutMenu();
            }
        }

        /// <summary>Raised after the game begins a new day (including when the player loads a save).</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        void OnDayStarted(object sender, DayStartedEventArgs e)
        {
            if (Config.JunimoPayment.WorkForWages)
            {
                Util.Payments.JunimoPaymentsToday.Clear();
                Util.Payments.WereJunimosPaidToday = false;
            }

            var huts = Game1.getFarm().buildings.OfType <JunimoHut>().ToList();

            // tag each hut chest so later we can tell whether a GrabMenu close is for a Junimo chest or some other chest
            foreach (var hut in huts)
            {
                hut.output.Value.modData[$"{ModManifest.UniqueID}/JunimoChest"] = "true";
            }

            if (huts.Any())
            {
                CheckHutsForWagesAndProgressionItems();
                Util.Progression.DayStartedProgressionPrompt(Game1.IsWinter, Game1.isRaining);
                JunimoAbilities.ResetCooldowns();
            }

            foreach (var location in Game1.locations)
            {
                var toRemove = location.characters.Where(npc => npc is JunimoHarvester).ToList();
                if (toRemove.Count > 0)
                {
                    Monitor.Log($"{location.Name} has {toRemove.Count} Junimos", LogLevel.Trace);
                }

                foreach (var npc in toRemove)
                {
                    var junimo = (JunimoHarvester)npc;
                    Monitor.Log($"    Removing Junimo {junimo.whichJunimoFromThisHut} from {location.Name}",
                                LogLevel.Trace);
                    location.characters.Remove(npc);
                }
            }

            // reset for rainy days, winter, or Generic Mod Config Menu options change
            SaveConfig();
        }
Пример #2
0
 private void ResetCooldowns(string command, string[] args)
 {
     JunimoAbilities.ResetCooldowns();
 }