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); } }
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")); }
public override void Entry(IModHelper helper) { config = Helper.ReadConfig <MushroomRancherConfig>(); MushroomRancherConfig.VerifyConfigValues(config, this); Helper.Events.GameLoop.GameLaunched += delegate { MushroomRancherConfig.SetUpModConfigMenu(config, this); }; Helper.Events.GameLoop.SaveLoaded += RespawnLivingMushrooms; Helper.Events.GameLoop.DayStarted += GameLoop_DayStarted; Helper.Events.Player.Warped += Player_Warped; Patcher.PatchAll(this); foreach (var item in Enum.GetValues(typeof(HutchType))) { maps[(int)item] = Helper.Content.Load <Map>($"assets/{item}_hutch.tmx"); waterTextures[(int)item] = Helper.Content.Load <Texture2D>($"assets/water_spots_{item}.png"); } }