/// <summary> Main mod function. </summary> /// <param name="helper">The helper. </param> public override void Entry(IModHelper helper) { RWeatherIcon = new Rectangle(); WeatherOpt = helper.ReadConfig <WeatherConfig>(); Dice = new MersenneTwister(); DebugOutput = new StringBuilder(); OurMoon = new SDVMoon(WeatherOpt, Dice); OurIcons = new Sprites.Icons(Helper.Content); CropList = new List <Vector2>(); Conditions = new WeatherConditions(OurIcons, Dice, Helper.Translation, Monitor, WeatherOpt); StaminaMngr = new StaminaDrain(WeatherOpt, Helper.Translation, Monitor); SeedsForDialogue = new int[] { Dice.Next(), Dice.Next() }; DescriptionEngine = new Descriptions(Helper.Translation, Dice, WeatherOpt, Monitor); queuedMsg = null; Vector2 snowPos = Vector2.Zero; TicksOutside = 0; TicksTotal = 0; ExpireTime = 0; if (WeatherOpt.Verbose) { Monitor.Log($"Loading climate type: {WeatherOpt.ClimateType} from file", LogLevel.Trace); } string path = Path.Combine("data", "weather", WeatherOpt.ClimateType + ".json"); GameClimate = helper.ReadJsonFile <FerngillClimate>(path); if (GameClimate is null) { this.Monitor.Log($"The required '{path}' file is missing. Try reinstalling the mod to fix that.", LogLevel.Error); this.Monitor.Log("This mod will now disable itself.", LogLevel.Error); this.Disabled = true; } if (!Disabled) { //subscribe to events TimeEvents.AfterDayStarted += HandleNewDay; SaveEvents.BeforeSave += OnEndOfDay; TimeEvents.TimeOfDayChanged += TenMinuteUpdate; MenuEvents.MenuChanged += MenuEvents_MenuChanged; GameEvents.UpdateTick += CheckForChanges; SaveEvents.AfterReturnToTitle += ResetMod; SaveEvents.AfterLoad += SaveEvents_AfterLoad; GraphicsEvents.OnPostRenderGuiEvent += DrawOverMenus; GraphicsEvents.OnPreRenderHudEvent += DrawPreHudObjects; GraphicsEvents.OnPostRenderHudEvent += DrawObjects; LocationEvents.CurrentLocationChanged += LocationEvents_CurrentLocationChanged; ControlEvents.KeyPressed += (sender, e) => this.ReceiveKeyPress(e.KeyPressed, this.WeatherOpt.Keyboard); MenuEvents.MenuClosed += (sender, e) => this.ReceiveMenuClosed(e.PriorMenu); //console commands helper.ConsoleCommands .Add("weather_settommorow", helper.Translation.Get("console-text.desc_tmrweather"), TomorrowWeatherChangeFromConsole) .Add("weather_changeweather", helper.Translation.Get("console-text.desc_setweather"), WeatherChangeFromConsole) .Add("world_solareclipse", "Starts the solar eclipse.", SolarEclipseEvent_CommandFired); } }
/********* ** Public methods *********/ /**** ** Constructors ****/ /// <summary>Construct an instance.</summary> public WeatherMenu(Sprites.Icons Icon, WeatherConditions weat, string text) { // save data MenuText = text; CurrentWeather = weat; IconSheet = Icon; // update layout UpdateLayout(); }
/********* ** Public methods *********/ /**** ** Constructors ****/ /// <summary>Construct an instance.</summary> /// <param name="monitor">Encapsulates logging and monitoring.</param> public WeatherMenu(IMonitor monitor, IReflectionHelper reflectionHelper, Sprites.Icons Icon, WeatherConditions weat, string text) { // save data MenuText = text; Monitor = monitor; Reflection = reflectionHelper; CurrentWeather = weat; IconSheet = Icon; // update layout UpdateLayout(); }
/********* ** Public methods *********/ /**** ** Constructors ****/ /// <summary>Construct an instance.</summary> /// <param name="monitor">Encapsulates logging and monitoring.</param> public WeatherMenu(IMonitor monitor, IReflectionHelper reflectionHelper, Sprites.Icons Icon, ITranslationHelper Helper, WeatherConditions weat, SDVMoon Termina, WeatherConfig ModCon, string text) { // save data this.MenuText = text; this.Monitor = monitor; this.Reflection = reflectionHelper; this.Helper = Helper; this.CurrentWeather = weat; this.IconSheet = Icon; this.OurMoon = Termina; this.OurConfig = ModCon; // update layout this.UpdateLayout(); }
/// <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) { RWeatherIcon = new Rectangle(); WeatherOpt = helper.ReadConfig <WeatherConfig>(); Logger = Monitor; Translator = Helper.Translation; Reflection = Helper.Reflection; MPHandler = Helper.Multiplayer; Dice = new Xoshiro.PRNG64.XoShiRo256starstar(); OurIcons = new Sprites.Icons(Helper.Content); WeatherProcessing.Init(); Conditions = new WeatherConditions(); DescriptionEngine = new Descriptions(WeatherOpt, Helper.Translation); queuedMsg = null; SummitRebornLoaded = false; if (WeatherOpt.Verbose) { Monitor.Log($"Loading climate type: {WeatherOpt.ClimateType} from file", LogLevel.Trace); } var path = Path.Combine("assets", "climates", WeatherOpt.ClimateType + ".json"); GameClimate = helper.Data.ReadJsonFile <FerngillClimate>(path); if (GameClimate is null) { this.Monitor.Log($"The required '{path}' file is missing. Try reinstalling the mod to fix that.", LogLevel.Error); this.Monitor.Log("This mod will now disable itself.", LogLevel.Error); this.Disabled = true; } if (Disabled) { return; } var harmony = new Harmony("koihimenakamura.climatesofferngill"); harmony.Patch( original: AccessTools.Method(typeof(GameLocation), "drawAboveAlwaysFrontLayer"), transpiler: new HarmonyMethod(AccessTools.Method(typeof(GameLocationPatches), "DAAFLTranspiler"))); Monitor.Log("Patching GameLocation::drawAboveAlwaysFrontLayer with a Transpiler.", LogLevel.Trace); harmony.Patch( original: AccessTools.Method(typeof(Game1), "drawWeather"), prefix: new HarmonyMethod(AccessTools.Method(typeof(Game1Patches), "DrawWeatherPrefix"))); Monitor.Log("Patching Game1::drawWeather with a prefix method.", LogLevel.Trace); harmony.Patch( original: AccessTools.Method(typeof(Game1), "updateWeather"), prefix: new HarmonyMethod(AccessTools.Method(typeof(Game1Patches), "UpdateWeatherPrefix"))); Monitor.Log("Patching Game1::updateWeather with a prefix method.", LogLevel.Trace); harmony.Patch( original: AccessTools.Method(AccessTools.TypeByName("StardewModdingAPI.Framework.SGame"), "DrawImpl"), transpiler: new HarmonyMethod(AccessTools.Method(typeof(SGamePatches), "DrawImplTranspiler"))); Monitor.Log("Patching SMAPI (SGame::DrawImpl) with a transpiler.", LogLevel.Trace); harmony.Patch( original: AccessTools.Constructor(AccessTools.TypeByName("StardewValley.WeatherDebris"), new[] { typeof(Vector2), typeof(int), typeof(float), typeof(float), typeof(float) }), postfix: new HarmonyMethod(AccessTools.Method(typeof(WeatherDebrisPatches), "CtorPostfix"))); Monitor.Log("Patching WeatherDebris's constructor method with a postfix method.", LogLevel.Trace); harmony.Patch( original: AccessTools.Method(typeof(WeatherDebris), "draw"), prefix: new HarmonyMethod(AccessTools.Method(typeof(WeatherDebrisPatches), "DrawPrefix"))); Monitor.Log("Patching WeatherDebris::draw with a prefix method.", LogLevel.Trace); harmony.Patch( original: AccessTools.Method(typeof(WeatherDebris), "update", new[] { typeof(bool) }), prefix: new HarmonyMethod(AccessTools.Method(typeof(WeatherDebrisPatches), "UpdatePrefix"))); Monitor.Log("Patching WeatherDebris::draw with a prefix method.", LogLevel.Trace); //INSERT DNT CHECKS HERE var modManifest = Helper.ModRegistry.Get("knakamura.dynamicnighttime"); if (modManifest != null) { if (modManifest.Manifest.Version.IsOlderThan("1.2.11")) { Monitor.Log("WARNING: Overcast weather may not work correctly unless you are running Dynamic Night Time 1.2.11 or later", LogLevel.Alert); } } else { harmony.Patch( original: AccessTools.Method(typeof(Game1), "UpdateGameClock"), postfix: new HarmonyMethod(AccessTools.Method(typeof(GameClockPatch), "Postfix"))); Monitor.Log("Patching Game1::UpdateGameClock with a Postfix method. (Used only when Climates is installed and DNT is not.)", LogLevel.Trace); } ConsoleCommands.Init(); SanityCheckConfigOptions(); //subscribe to events var events = helper.Events; events.GameLoop.DayStarted += OnDayStarted; events.GameLoop.Saving += OnSaving; events.GameLoop.TimeChanged += OnTimeChanged; events.Display.MenuChanged += OnMenuChanged; events.GameLoop.UpdateTicked += OnUpdateTicked; events.GameLoop.GameLaunched += OnGameLaunched; events.GameLoop.OneSecondUpdateTicked += OnOneSecondUpdateTicked; events.GameLoop.ReturnedToTitle += OnReturnedToTitle; events.GameLoop.SaveLoaded += OnSaveLoaded; events.Display.RenderedWorld += Display_RenderedWorld; //events.Display.RenderingHud += OnRenderingHud; events.Display.RenderedHud += OnRenderedHud; events.Input.ButtonPressed += OnButtonPressed; events.Multiplayer.ModMessageReceived += OnModMessageRecieved; //console commands helper.ConsoleCommands .Add("world_tmrwweather", helper.Translation.Get("console-text.desc_tmrweather"), ConsoleCommands.TomorrowWeatherChangeFromConsole) .Add("world_setweather", helper.Translation.Get("console-text.desc_setweather"), ConsoleCommands.WeatherChangeFromConsole) .Add("debug_clearspecial", "debug command to clear special weathers", ConsoleCommands.ClearSpecial) .Add("debug_weatherstatus", "!", ConsoleCommands.OutputWeather) .Add("debug_sswa", "Show Special Weather", ConsoleCommands.ShowSpecialWeather) .Add("debug_vrainc", "Set Rain Amt.", ConsoleCommands.SetRainAmt) .Add("debug_raindef", "Set Rain Deflection.", ConsoleCommands.SetRainDef) /* * .Add("debug_setwindchance", "Set Wind Chance", ConsoleCommands.SetWindChance) * .Add("debug_setwindtresh", "Set Wind Threshold", ConsoleCommands.SetWindThreshold) * .Add("debug_setwindrange", "Set Wind Range", ConsoleCommands.SetWindRange) * .Add("debug_raintotal", "Get Rain Total", ConsoleCommands.DisplayRainTotal) * .Add("debug_getcurrentwind", "Show wind values", ConsoleCommands.ShowWind) * .Add("debug_resetwind", "Reset Global Wind", ConsoleCommands.ResetGlobalWind) */ .Add("debug_printClimate", "Print Climate Tracker Data", ConsoleCommands.DisplayClimateTrackerData); }
/// <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) { RWeatherIcon = new Rectangle(); WeatherOpt = helper.ReadConfig <WeatherConfig>(); Logger = Monitor; Translator = Helper.Translation; Reflection = Helper.Reflection; MPHandler = Helper.Multiplayer; Dice = new MersenneTwister(); OurIcons = new Sprites.Icons(Helper.Content); WeatherProcessing.Init(); Conditions = new WeatherConditions(); DescriptionEngine = new Descriptions(WeatherOpt, Helper.Translation); queuedMsg = null; SummitRebornLoaded = false; if (WeatherOpt.Verbose) { Monitor.Log($"Loading climate type: {WeatherOpt.ClimateType} from file", LogLevel.Trace); } var path = Path.Combine("assets", "climates", WeatherOpt.ClimateType + ".json"); GameClimate = helper.Data.ReadJsonFile <FerngillClimate>(path); if (GameClimate is null) { this.Monitor.Log($"The required '{path}' file is missing. Try reinstalling the mod to fix that.", LogLevel.Error); this.Monitor.Log("This mod will now disable itself.", LogLevel.Error); this.Disabled = true; } if (Disabled) { return; } var harmony = HarmonyInstance.Create("koihimenakamura.climatesofferngill"); harmony.PatchAll(Assembly.GetExecutingAssembly()); ConsoleCommands.Init(); MethodInfo GameLocationDAAFL = AccessTools.Method(typeof(GameLocation), "drawAboveAlwaysFrontLayer"); HarmonyMethod DAAFLTranspiler = new HarmonyMethod(AccessTools.Method(typeof(GameLocationPatches), "DAAFLTranspiler")); Monitor.Log($"Patching {GameLocationDAAFL} with Transpiler: {DAAFLTranspiler}", LogLevel.Trace);; harmony.Patch(GameLocationDAAFL, transpiler: DAAFLTranspiler); MethodInfo GameDrawW = AccessTools.Method(typeof(Game1), "drawWeather"); HarmonyMethod DrawWeatherPrefix = new HarmonyMethod(AccessTools.Method(typeof(Game1Patches), "DrawWeatherPrefix")); Monitor.Log($"Patching {GameDrawW} with Prefix: {DrawWeatherPrefix}", LogLevel.Trace);; harmony.Patch(GameDrawW, prefix: DrawWeatherPrefix); Type t = AccessTools.TypeByName("StardewModdingAPI.Framework.SGame"); MethodInfo SGameDrawImpl = AccessTools.Method(t, "DrawImpl"); HarmonyMethod DrawTrans = new HarmonyMethod(AccessTools.Method(typeof(SGamePatches), "DrawImplTranspiler")); Monitor.Log($"Patching {SGameDrawImpl} with Transpiler: {DrawTrans}", LogLevel.Trace); harmony.Patch(SGameDrawImpl, transpiler: DrawTrans); t = AccessTools.TypeByName("StardewValley.WeatherDebris"); var DebrisConstructor = AccessTools.Constructor(t, new[] { typeof(Vector2), typeof(int), typeof(float), typeof(float), typeof(float) }); HarmonyMethod CtorPatch = new HarmonyMethod(AccessTools.Method(typeof(WeatherDebrisPatches), "CtorPostfix")); Monitor.Log($"Patching {DebrisConstructor} with Postfix: {CtorPatch}", LogLevel.Trace); harmony.Patch(DebrisConstructor, postfix: CtorPatch); MethodInfo DebrisDraw = AccessTools.Method(typeof(WeatherDebris), "draw"); HarmonyMethod DebrisPatch = new HarmonyMethod(AccessTools.Method(typeof(WeatherDebrisPatches), "DrawPrefix")); Monitor.Log($"Patching {DebrisDraw} with Prefix: {DebrisDraw}", LogLevel.Trace); harmony.Patch(DebrisDraw, prefix: DebrisPatch); MethodInfo DebrisUpdate = AccessTools.Method(typeof(WeatherDebris), "update", new[] { typeof(bool) }); HarmonyMethod DebrisUpdatePatch = new HarmonyMethod(AccessTools.Method(typeof(WeatherDebrisPatches), "UpdatePrefix")); Monitor.Log($"Patching {DebrisUpdate} with Prefix: {DebrisUpdatePatch}", LogLevel.Trace); harmony.Patch(DebrisUpdate, prefix: DebrisUpdatePatch); //INSERT DNT CHECKS HERE var modManifest = Helper.ModRegistry.Get("knakamura.dynamicnighttime"); if (modManifest != null) { if (modManifest.Manifest.Version.IsOlderThan("1.2.11")) { Monitor.Log("WARNING: Overcast weather may not work correctly unless you are running Dynamic Night Time 1.2.11 or later", LogLevel.Alert); } } else { //Normal Climates patch goes here. MethodInfo UpdateGameClock = helper.Reflection.GetMethod(SDVUtilities.GetSDVType("Game1"), "UpdateGameClock").MethodInfo; MethodInfo postfixClock = helper.Reflection.GetMethod(typeof(Patches.GameClockPatch), "Postfix").MethodInfo; Monitor.Log($"Postfixing {UpdateGameClock} with {postfixClock}", LogLevel.Trace); harmony.Patch(UpdateGameClock, null, new HarmonyMethod(postfixClock)); } SanityCheckConfigOptions(); //subscribe to events var events = helper.Events; events.GameLoop.DayStarted += OnDayStarted; events.GameLoop.Saving += OnSaving; events.GameLoop.TimeChanged += OnTimeChanged; events.Display.MenuChanged += OnMenuChanged; events.GameLoop.UpdateTicked += OnUpdateTicked; events.GameLoop.GameLaunched += OnGameLaunched; events.GameLoop.OneSecondUpdateTicked += OnOneSecondUpdateTicked; events.GameLoop.ReturnedToTitle += OnReturnedToTitle; events.GameLoop.SaveLoaded += OnSaveLoaded; events.Display.RenderingHud += OnRenderingHud; events.Display.RenderedHud += OnRenderedHud; events.Input.ButtonPressed += OnButtonPressed; events.Multiplayer.ModMessageReceived += OnModMessageRecieved; // events.GameLoop.UpdateTicking += GameLoop_UpdateTicking; //console commands helper.ConsoleCommands .Add("world_tmrwweather", helper.Translation.Get("console-text.desc_tmrweather"), ConsoleCommands.TomorrowWeatherChangeFromConsole) .Add("world_setweather", helper.Translation.Get("console-text.desc_setweather"), ConsoleCommands.WeatherChangeFromConsole) .Add("debug_clearspecial", "debug command to clear special weathers", ConsoleCommands.ClearSpecial) .Add("debug_weatherstatus", "!", ConsoleCommands.OutputWeather) .Add("debug_sswa", "Show Special Weather", ConsoleCommands.ShowSpecialWeather) .Add("debug_vrainc", "Set Rain Amt.", ConsoleCommands.SetRainAmt) .Add("debug_raintotal", "Get Rain Total", ConsoleCommands.DisplayRainTotal) .Add("debug_printClimate", "Print Climate Tracker Data", ConsoleCommands.DisplayClimateTrackerData); }
/// <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) { RWeatherIcon = new Rectangle(); WeatherOpt = helper.ReadConfig <WeatherConfig>(); Dice = new MersenneTwister(); OurIcons = new Sprites.Icons(Helper.Content); CropList = new List <Vector2>(); Conditions = new WeatherConditions(OurIcons, Dice, Helper.Translation, Monitor, WeatherOpt); DescriptionEngine = new Descriptions(Helper.Translation, Dice, WeatherOpt, Monitor); queuedMsg = null; ExpireTime = 0; if (WeatherOpt.Verbose) { Monitor.Log($"Loading climate type: {WeatherOpt.ClimateType} from file", LogLevel.Trace); } var path = Path.Combine("data", "weather", WeatherOpt.ClimateType + ".json"); GameClimate = helper.Data.ReadJsonFile <FerngillClimate>(path); if (GameClimate is null) { this.Monitor.Log($"The required '{path}' file is missing. Try reinstalling the mod to fix that.", LogLevel.Error); this.Monitor.Log("This mod will now disable itself.", LogLevel.Error); this.Disabled = true; } if (Disabled) { return; } var harmony = HarmonyInstance.Create("koihimenakamura.climatesofferngill"); harmony.PatchAll(Assembly.GetExecutingAssembly()); //patch SGame::DarkImpl //patch GameLocation::drawAboveAlwaysFrontLayer MethodInfo GameLocationDAAFL = AccessTools.Method(typeof(StardewValley.GameLocation), "drawAboveAlwaysFrontLayer"); HarmonyMethod DAAFLTranspiler = new HarmonyMethod(AccessTools.Method(typeof(GameLocationPatches), "Transpiler")); Monitor.Log($"Patching {GameLocationDAAFL} with Transpiler: {DAAFLTranspiler}", LogLevel.Trace);; harmony.Patch(GameLocationDAAFL, transpiler: DAAFLTranspiler); Type t = AccessTools.TypeByName("StardewModdingAPI.Framework.SGame"); MethodInfo SGameDrawImpl = AccessTools.Method(t, "DrawImpl"); HarmonyMethod DrawTrans = new HarmonyMethod(AccessTools.Method(typeof(SGamePatches), "Transpiler")); Monitor.Log($"Patching {SGameDrawImpl} with Transpiler: {DrawTrans}", LogLevel.Trace); harmony.Patch(SGameDrawImpl, transpiler: DrawTrans); //subscribe to events var events = helper.Events; events.GameLoop.DayStarted += OnDayStarted; events.GameLoop.Saving += OnSaving; events.GameLoop.TimeChanged += OnTimeChanged; events.Display.MenuChanged += OnMenuChanged; events.GameLoop.UpdateTicked += OnUpdateTicked; events.GameLoop.GameLaunched += OnGameLaunched; events.GameLoop.OneSecondUpdateTicked += OnOneSecondUpdateTicked; events.GameLoop.ReturnedToTitle += OnReturnedToTitle; events.GameLoop.SaveLoaded += OnSaveLoaded; events.Display.RenderingHud += OnRenderingHud; events.Display.RenderedHud += OnRenderedHud; events.Player.Warped += OnWarped; events.Input.ButtonPressed += OnButtonPressed; //console commands helper.ConsoleCommands .Add("world_tmrwweather", helper.Translation.Get("console-text.desc_tmrweather"), TomorrowWeatherChangeFromConsole) .Add("world_setweather", helper.Translation.Get("console-text.desc_setweather"), WeatherChangeFromConsole) .Add("debug_clearspecial", "debug command to clear special weathers", ClearSpecial) .Add("debug_weatherstatus", "!", OutputWeather); }