Exemplo n.º 1
0
        /// <summary>Raised after the player loads a save slot and the world is initialised.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event data.</param>
        private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
        {
            if (!IsEnabled)
            {
                return;
            }

            DataLoader.ToolsLoader.ReplaceOldTools();
            FarmerLoader.LoadData();
            DataLoader.ToolsLoader.LoadMail();
        }
Exemplo n.º 2
0
        /// <summary>Raised after the player loads a save slot and the world is initialised.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event data.</param>
        private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
        {
            if (!_isEnabled)
            {
                return;
            }

            DataLoader.ToolsLoader.ReplaceOldTools();
            FarmerLoader.LoadData();
            DataLoader.ToolsLoader.LoadMail();
            DataLoader.AnimalData.FillLikedTreatsIds();
        }
Exemplo n.º 3
0
        /// <summary>Raised after the player loads a save slot and the world is initialized.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event data.</param>
        private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
        {
            if (!_isEnabled)
            {
                return;
            }

            DataLoader.ToolsLoader.ReplaceOldTools();
            FarmerLoader.LoadData();
            FarmerLoader.MoveOldPregnancyData();
            FarmerLoader.MoveOldAnimalStatusData();
            DataLoader.ToolsLoader.LoadMail();
            DataLoader.AnimalData.FillLikedTreatsIds();
            EventsLoader.EventListener();
        }
Exemplo n.º 4
0
        /// <summary>Raised before the game is saved.</summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnSaving(object sender, SavingEventArgs e)
        {
            if (!_isEnabled)
            {
                return;
            }

            EventsLoader.CheckUnseenEvents();

            if (!DataLoader.ModConfig.DisablePregnancy)
            {
                PregnancyController.UpdatePregnancy();
            }
            FarmerLoader.SaveData();
        }
Exemplo n.º 5
0
        /// <summary>Raised before the game is saved.</summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnSaving(object sender, SavingEventArgs e)
        {
            if (!_isEnabled)
            {
                return;
            }

            if (Context.IsMainPlayer)
            {
                ItemUtility.RemoveModdedItemAnywhere(ParticipantRibbonOverrides.ParticipantRibbonKey);
            }

            EventsLoader.CheckUnseenEvents();

            if (!DataLoader.ModConfig.DisablePregnancy && Context.IsMainPlayer)
            {
                PregnancyController.UpdatePregnancy();
            }
            FarmerLoader.SaveData();
        }
Exemplo n.º 6
0
        public static void UpdatePregnancy()
        {
            FarmerLoader.FarmerData.PregnancyData.ForEach(a => a.DaysUntilBirth--);

            FarmerLoader.SaveData();
        }
Exemplo n.º 7
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)
        {
            ModHelper = helper;
            monitor   = Monitor;

            if (this.Helper.ModRegistry.IsLoaded("DIGUS.BUTCHER"))
            {
                Monitor.Log("Animal Husbandry Mod can't run along side its older version, ButcherMod. " +
                            "You need to copy the 'data' directory from the ButcherMod directory, into the AnimalHusbandryMod directory, then delete the ButcherMod directory. " +
                            "Animal Husbandry Mod won't load until this is done.", LogLevel.Error);
            }
            else
            {
                DataLoader                   = new DataLoader(helper);
                _meatCleaverSpawnKey         = DataLoader.ModConfig.AddMeatCleaverToInventoryKey;
                _inseminationSyringeSpawnKey = DataLoader.ModConfig.AddInseminationSyringeToInventoryKey;
                _feedingBasketSpawnKey       = DataLoader.ModConfig.AddFeedingBasketToInventoryKey;

                SaveEvents.AfterLoad += DataLoader.ToolsLoader.ReplaceOldTools;
                SaveEvents.AfterLoad += (x, y) => FarmerLoader.LoadData();
                SaveEvents.AfterLoad += (x, y) => DataLoader.ToolsLoader.LoadMail();

                TimeEvents.AfterDayStarted += (x, y) => DataLoader.LivingWithTheAnimalsChannel.CheckChannelDay();

                //TimeEvents.AfterDayStarted += (x, y) => EventsLoader.CheckEventDay();

                if (!DataLoader.ModConfig.DisableMeat)
                {
                    TimeEvents.AfterDayStarted += (x, y) => DataLoader.RecipeLoader.MeatFridayChannel.CheckChannelDay();
                    ModHelper.ConsoleCommands.Add("player_addallmeatrecipes", "Add all meat recipes to the player.", DataLoader.RecipeLoader.AddAllMeatRecipes);
                }

                if (_meatCleaverSpawnKey != null || _inseminationSyringeSpawnKey != null || _feedingBasketSpawnKey != null)
                {
                    ControlEvents.KeyPressed += this.ControlEvents_KeyPress;
                }

                if (!DataLoader.ModConfig.DisablePregnancy)
                {
                    TimeEvents.AfterDayStarted += (x, y) => PregnancyController.CheckForBirth();
                    SaveEvents.BeforeSave      += (x, y) => PregnancyController.UpdatePregnancy();
                }



                var harmony = HarmonyInstance.Create("Digus.AnimalHusbandryMod");

                try
                {
                    var farmAnimalPet = typeof(FarmAnimal).GetMethod("pet");
                    var animalQueryMenuExtendedPet = typeof(AnimalQueryMenuExtended).GetMethod("Pet");
                    harmony.Patch(farmAnimalPet, new HarmonyMethod(animalQueryMenuExtendedPet), null);
                }
                catch (Exception)
                {
                    Monitor.Log("Erro patching the FarmAnimal 'pet' Method. Applying old method of opening the extended animal query menu.", LogLevel.Warn);
                    MenuEvents.MenuChanged += (s, e) =>
                    {
                        if (e.NewMenu is AnimalQueryMenu && !(e.NewMenu is AnimalQueryMenuExtended))
                        {
                            Game1.activeClickableMenu = new AnimalQueryMenuExtended(this.Helper.Reflection.GetField <FarmAnimal>(e.NewMenu, "animal").GetValue());
                        }
                    };
                }

                if (!DataLoader.ModConfig.DisableRancherMeatPriceAjust)
                {
                    var sellToStorePrice       = typeof(StardewValley.Object).GetMethod("sellToStorePrice");
                    var sellToStorePricePrefix = typeof(MeatOverrides).GetMethod("sellToStorePrice");
                    harmony.Patch(sellToStorePrice, new HarmonyMethod(sellToStorePricePrefix), null);
                }

                if (!DataLoader.ModConfig.DisableMeat)
                {
                    var objectIsPotentialBasicShippedCategory        = typeof(StardewValley.Object).GetMethod("isPotentialBasicShippedCategory");
                    var meatOverridesIsPotentialBasicShippedCategory = typeof(MeatOverrides).GetMethod("isPotentialBasicShippedCategory");
                    harmony.Patch(objectIsPotentialBasicShippedCategory, new HarmonyMethod(meatOverridesIsPotentialBasicShippedCategory), null);

                    var objectCountsForShippedCollection        = typeof(StardewValley.Object).GetMethod("countsForShippedCollection");
                    var meatOverridesCountsForShippedCollection = typeof(MeatOverrides).GetMethod("countsForShippedCollection");
                    harmony.Patch(objectCountsForShippedCollection, new HarmonyMethod(meatOverridesCountsForShippedCollection), null);
                }



                //var addSpecificTemporarySprite = typeof(Event).GetMethod("addSpecificTemporarySprite");
                //var addSpecificTemporarySprite = this.Helper.Reflection.GetMethod(new Event(), "addSpecificTemporarySprite").MethodInfo;
                //var addSpecificTemporarySpritePostfix = typeof(EventsOverrides).GetMethod("addSpecificTemporarySprite");
                //harmony.Patch(addSpecificTemporarySprite, null, new HarmonyMethod(addSpecificTemporarySpritePostfix));

                //var petCheckAction = typeof(Pet).GetMethod("checkAction");
                //var petCheckActionPrefix = typeof(PetOverrides).GetMethod("checkAction");
                //harmony.Patch(petCheckAction, new HarmonyMethod(petCheckActionPrefix), null);
            }
        }