Пример #1
0
 public static void VerifyConfigValues(MushroomRancherConfig config, MushroomRancher mod)
 {
     if (config.HutchInterior < 0 || config.HutchInterior >= InteriorChoices.Length)
     {
         config.HutchInterior = 1;
         mod.DebugLog("At least one config value was out of range and was reset.");
         mod.Helper.WriteConfig(config);
     }
 }
Пример #2
0
        public static bool MushroomIncubatorUpdate_Pre(StardewObject __instance, GameLocation location)
        {
            try
            {
                if (__instance.Name.Equals("MushroomIncubator") && __instance.heldObject.Value != null)
                {
                    if (__instance.MinutesUntilReady > 0)
                    {
                        var minutesWorking = 2880 - __instance.MinutesUntilReady;

                        if (minutesWorking < 1440)
                        {
                            __instance.MinutesUntilReady = Game1.MasterPlayer.professions.Contains(2) ? 0 : Utility.CalculateMinutesUntilMorning(Game1.timeOfDay);
                        }
                    }

                    if (__instance.MinutesUntilReady <= 0 && location is SlimeHutch && location.canSlimeHatchHere())
                    {
                        Monster monster = null;
                        Vector2 v       = new Vector2((int)__instance.TileLocation.X, (int)__instance.TileLocation.Y + 1) * 64f;
                        int     heldId  = __instance.heldObject.Value.ParentSheetIndex;

                        if (heldId == MushroomRancher.redMushroomId)
                        {
                            monster = MushroomRancher.CreateFriendlyLivingMushroom(v);
                        }
                        else if (heldId == MushroomRancher.magmaCapId)
                        {
                            monster = MushroomRancher.CreateFriendlyMagmaCap(v, mod);
                        }

                        if (monster != null)
                        {
                            // Game1.showGlobalMessage(slime.cute ? Game1.content.LoadString("Strings\\StringsFromCSFiles:Object.cs.12689") : Game1.content.LoadString("Strings\\StringsFromCSFiles:Object.cs.12691"));
                            Vector2 openSpot = Utility.recursiveFindOpenTileForCharacter(monster, location, __instance.TileLocation + new Vector2(0f, 1f), 10, false);
                            monster.setTilePosition((int)openSpot.X, (int)openSpot.Y);
                            location.characters.Add(monster);
                            __instance.heldObject.Value  = null;
                            __instance.MinutesUntilReady = -1;
                        }
                    }
                }

                return(true);
            }
            catch (Exception e)
            {
                mod.ErrorLog("There was an exception in a patch", e);

                return(true);
            }
        }
Пример #3
0
        public static RockCrab CreateFriendlyMagmaCap(Vector2 vector, MushroomRancher mod)
        {
            var monster = new RockCrab(vector, "False Magma Cap");

            monster.DamageToFarmer      = 0;
            monster.Speed              /= 2;
            monster.farmerPassesThrough = true;
            monster.coinsToDrop.Value   = 0;
            monster.objectsToDrop.Clear();
            monster.objectsToDrop.Add(MushroomRancher.magmaCapId);
            monster.moveTowardPlayerThreshold.Value = 2;

            return(monster);
        }
Пример #4
0
        public static void SetUpModConfigMenu(MushroomRancherConfig config, MushroomRancher mod)
        {
            IGenericModConfigMenuApi api = mod.Helper.ModRegistry.GetApi <IGenericModConfigMenuApi>("spacechase0.GenericModConfigMenu");

            if (api == null)
            {
                return;
            }

            var manifest = mod.ModManifest;

            api.RegisterModConfig(manifest, () => config = new MushroomRancherConfig(), delegate { mod.Helper.WriteConfig(config); VerifyConfigValues(config, mod); });

            api.AddTextOption(manifest, () => GetElementFromConfig(InteriorChoices, config.HutchInterior), (string val) => config.HutchInterior = GetIndexFromArrayElement(InteriorChoices, val), () => mod.Helper.Translation.Get("ConfigHutchInterior"), null, InteriorChoices, (s) => TranslateSpeechChoice(s, mod));
            api.AddBoolOption(manifest, () => config.RemovableSlimeHutchIncubator, (bool val) => config.RemovableSlimeHutchIncubator            = val, () => mod.Helper.Translation.Get("ConfigRemovableSlimeHutchIncubator"));
            api.AddBoolOption(manifest, () => config.RandomizeMonsterPositionInHutch, (bool val) => config.RandomizeMonsterPositionInHutch      = val, () => mod.Helper.Translation.Get("ConfigRandomizeMonsterPositionInHutch"));
        }
Пример #5
0
        public static void PatchAll(MushroomRancher mushroomRancher)
        {
            mod = mushroomRancher;

            var harmony = new Harmony(mod.ModManifest.UniqueID);

            harmony.Patch(
                original: AccessTools.Method(typeof(StardewObject), nameof(StardewObject.DayUpdate)),
                prefix: new HarmonyMethod(typeof(Patcher), nameof(MushroomIncubatorUpdate_Pre)));

            harmony.Patch(
                original: AccessTools.Method(typeof(SlimeHutch), nameof(SlimeHutch.DayUpdate)),
                prefix: new HarmonyMethod(typeof(Patcher), nameof(SlimeHutchDayUpdate_Pre)));

            harmony.Patch(
                original: AccessTools.Method(typeof(SlimeHutch), nameof(SlimeHutch.DayUpdate)),
                postfix: new HarmonyMethod(typeof(Patcher), nameof(SlimeHutchDayUpdate_Post)));

            harmony.Patch(
                original: AccessTools.Method(typeof(DustSpirit), nameof(DustSpirit.behaviorAtGameTick)),
                prefix: new HarmonyMethod(typeof(Patcher), nameof(BehaviorAtGameTick_LivingMushroom)));
        }
Пример #6
0
 private static string TranslateSpeechChoice(string englishValue, MushroomRancher mod)
 {
     return(mod.Helper.Translation.Get("ConfigHutchInterior" + englishValue));
 }