private void OnGameLanuched(object sender, GameLaunchedEventArgs e) { var api = Helper.ModRegistry.GetApi <Integrations.GenericModConfigMenuAPI>("spacechase0.GenericModConfigMenu"); if (api != null) { api.RegisterModConfig(ModManifest, () => OurConfig = new CartConfig(), () => Helper.WriteConfig(OurConfig)); api.RegisterClampedOption(ModManifest, "Monday Apparence", "The chance for the cart to appear on Monday", () => (float)OurConfig.MondayChance, (float val) => OurConfig.MondayChance = val, 0f, 1f); api.RegisterClampedOption(ModManifest, "Tuesday Apparence", "The chance for the cart to appear on Tuesday", () => (float)OurConfig.TuesdayChance, (float val) => OurConfig.TuesdayChance = val, 0f, 1f); api.RegisterClampedOption(ModManifest, "Wednesday Apparence", "The chance for the cart to appear on Wednesday", () => (float)OurConfig.WednesdayChance, (float val) => OurConfig.WednesdayChance = val, 0f, 1f); api.RegisterClampedOption(ModManifest, "Thursday Apparence", "The chance for the cart to appear on Thursday", () => (float)OurConfig.ThursdayChance, (float val) => OurConfig.ThursdayChance = val, 0f, 1f); api.RegisterClampedOption(ModManifest, "Friday Apparence", "The chance for the cart to appear on Friday", () => (float)OurConfig.FridayChance, (float val) => OurConfig.FridayChance = val, 0f, 1f); api.RegisterClampedOption(ModManifest, "Saturday Apparence", "The chance for the cart to appear on Saturday", () => (float)OurConfig.SaturdayChance, (float val) => OurConfig.SaturdayChance = val, 0f, 1f); api.RegisterClampedOption(ModManifest, "Sunday Apparence", "The chance for the cart to appear on Sunday", () => (float)OurConfig.SundayChance, (float val) => OurConfig.SundayChance = val, 0f, 1f); api.RegisterSimpleOption(ModManifest, "Appear Only At Start Of Season", "If selected, the cart only appears at the beginning of the season", () => OurConfig.AppearOnlyAtStartOfSeason, (bool val) => OurConfig.AppearOnlyAtStartOfSeason = val); api.RegisterSimpleOption(ModManifest, "Appear Only At End Of Season", "If selected, the cart only appears at the end of the season", () => OurConfig.AppearOnlyAtEndOfSeason, (bool val) => OurConfig.AppearOnlyAtEndOfSeason = val); api.RegisterSimpleOption(ModManifest, "Appear Only At Start and End Of Season", "If selected, the cart only appears at the beginning and end of the season", () => OurConfig.AppearOnlyAtStartAndEndOfSeason, (bool val) => OurConfig.AppearOnlyAtStartAndEndOfSeason = val); api.RegisterSimpleOption(ModManifest, "Appear Only Every Other Week", "If selected, the cart only appears every other week", () => OurConfig.AppearOnlyEveryOtherWeek, (bool val) => OurConfig.AppearOnlyEveryOtherWeek = val); api.RegisterSimpleOption(ModManifest, "Use Vanilla Max", "The game defaults to a max of 790. Turning this off allows PPJA assets to appear in the cart.", () => OurConfig.UseVanillaMax, (bool val) => OurConfig.UseVanillaMax = val); api.RegisterClampedOption(ModManifest, "Amount of Items", "The amount of items the cart contains.", () => OurConfig.AmountOfItems, (int val) => OurConfig.AmountOfItems = val, 3, 100); api.RegisterSimpleOption(ModManifest, "Use Cheaper Pricing", "Toggling this to true allows for cheaper pricing.", () => OurConfig.UseCheaperPricing, (bool val) => OurConfig.UseCheaperPricing = val); api.RegisterClampedOption(ModManifest, "Opening Time", "The time the cart opens. Please select a 10-minute time.", () => OurConfig.OpeningTime, (int val) => OurConfig.OpeningTime = val, 600, 2600); api.RegisterClampedOption(ModManifest, "Closing Time", "The time the cart closes for the night. Please select a 10-minute time. You don't have to go home, but you can't stay here.", () => OurConfig.ClosingTime, (int val) => OurConfig.ClosingTime = val, 600, 2600); } }
/// <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) { instance = this; Dice = new MersenneTwister(); OurConfig = helper.ReadConfig <CartConfig>(); Logger = Monitor; APIItemsToBeAdded = new Dictionary <StardewValley.Object, int[]>(); var harmony = HarmonyInstance.Create("koihimenakamura.customizablecart"); harmony.PatchAll(Assembly.GetExecutingAssembly()); MethodInfo CheckAction = AccessTools.Method(typeof(Forest), "checkAction"); HarmonyMethod CATranspiler = new HarmonyMethod(AccessTools.Method(typeof(ForestPatches), "CheckActionTranspiler")); Monitor.Log($"Patching {CheckAction} with Transpiler: {CATranspiler}", LogLevel.Trace);; harmony.Patch(CheckAction, transpiler: CATranspiler); MethodInfo ForestDraw = AccessTools.Method(typeof(Forest), "draw"); HarmonyMethod DrawTranspiler = new HarmonyMethod(AccessTools.Method(typeof(ForestPatches), "DrawTranspiler")); Monitor.Log($"Patching {ForestDraw} with Transpiler: {DrawTranspiler}", LogLevel.Trace);; harmony.Patch(ForestDraw, transpiler: DrawTranspiler); MethodInfo GenerateTMS = AccessTools.Method(typeof(Utility), "getTravelingMerchantStock"); HarmonyMethod LTMPrefix = new HarmonyMethod(AccessTools.Method(typeof(UtilityPatches), "getTravelingMerchantStockPrefix")); Monitor.Log($"Patching {GenerateTMS} with Prefix: {LTMPrefix}", LogLevel.Trace);; harmony.Patch(GenerateTMS, prefix: LTMPrefix); helper.Events.GameLoop.DayStarted += OnDayStarted; helper.Events.GameLoop.GameLaunched += OnGameLanuched; }