From 9c1617c9ee51a0f6b93242fe8fc789336957460c Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 11 Apr 2018 21:15:16 -0400 Subject: drop support for Stardew Valley 1.2 (#453) --- .../Framework/Commands/World/DownMineLevelCommand.cs | 4 ---- .../Framework/Commands/World/SetMineLevelCommand.cs | 4 ---- 2 files changed, 8 deletions(-) (limited to 'src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World') diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/DownMineLevelCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/DownMineLevelCommand.cs index c83c3b07..2cec0fd3 100644 --- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/DownMineLevelCommand.cs +++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/DownMineLevelCommand.cs @@ -21,11 +21,7 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World { int level = (Game1.currentLocation as MineShaft)?.mineLevel ?? 0; monitor.Log($"OK, warping you to mine level {level + 1}.", LogLevel.Info); -#if STARDEW_VALLEY_1_3 Game1.enterMine(level + 1); -#else - Game1.enterMine(false, level + 1, ""); -#endif } } } diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetMineLevelCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetMineLevelCommand.cs index 5947af1a..b4f6d5b3 100644 --- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetMineLevelCommand.cs +++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetMineLevelCommand.cs @@ -26,11 +26,7 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World // handle level = Math.Max(1, level); monitor.Log($"OK, warping you to mine level {level}.", LogLevel.Info); -#if STARDEW_VALLEY_1_3 Game1.enterMine(level); -#else - Game1.enterMine(true, level, ""); -#endif } } } -- cgit From 6616c87c1806159ce6e751d4ccd54b5500d8b903 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 14 Apr 2018 00:24:24 -0400 Subject: fix world_settime command sometimes breaking NPC schedules --- docs/release-notes.md | 1 + .../Framework/Commands/World/SetTimeCommand.cs | 34 ++++++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) (limited to 'src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World') diff --git a/docs/release-notes.md b/docs/release-notes.md index f3e9af6f..e524ea65 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -6,6 +6,7 @@ * Added `Context.IsMultiplayer` and `Context.IsMainPlayer` flags. * Fixed SMAPI update checks not showing newer beta versions when using a beta version. * Fixed console color scheme on Mac or PowerShell, and added override option to `StardewModdingAPI.config.json`. + * Fixed `world_settime` console command sometimes breaking NPC schedules (e.g. so they stay in bed). * For modders: * Added code analysis to mod build config package to flag common issues as warnings. diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetTimeCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetTimeCommand.cs index d6c71387..7644ee46 100644 --- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetTimeCommand.cs +++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetTimeCommand.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System; +using System.Linq; using StardewValley; namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World @@ -31,9 +32,38 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World return; // handle - Game1.timeOfDay = time; + this.SafelySetTime(time); FreezeTimeCommand.FrozenTime = Game1.timeOfDay; monitor.Log($"OK, the time is now {Game1.timeOfDay.ToString().PadLeft(4, '0')}.", LogLevel.Info); } + + + /********* + ** Private methods + *********/ + /// Safely transition to the given time, allowing NPCs to update their schedule. + /// The time of day. + private void SafelySetTime(int time) + { + // define conversion between game time and TimeSpan + TimeSpan ToTimeSpan(int value) => new TimeSpan(0, value / 100, value % 100, 0); + int FromTimeSpan(TimeSpan span) => (int)((span.Hours * 100) + span.Minutes); + + // transition to new time + int intervals = (int)((ToTimeSpan(time) - ToTimeSpan(Game1.timeOfDay)).TotalMinutes / 10); + if (intervals > 0) + { + for (int i = 0; i < intervals; i++) + Game1.performTenMinuteClockUpdate(); + } + else if (intervals < 0) + { + for (int i = 0; i > intervals; i--) + { + Game1.timeOfDay = FromTimeSpan(ToTimeSpan(Game1.timeOfDay).Subtract(TimeSpan.FromMinutes(20))); // offset 20 mins so game updates to next interval + Game1.performTenMinuteClockUpdate(); + } + } + } } } -- cgit From ccd09eb9143bee60bfdc4182c3a7505fabddbe48 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 12 May 2018 16:04:18 -0400 Subject: fix world_setseason command not running season change logic --- docs/release-notes.md | 1 + .../Framework/Commands/World/SetSeasonCommand.cs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World') diff --git a/docs/release-notes.md b/docs/release-notes.md index cf531c57..ff9fcdac 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -10,6 +10,7 @@ * Fixed detection of GOG Galaxy install path in rare cases. * Fixed install error on Linux/Mac in some cases. * Fixed `smapi.io/install` not linking to a useful page. + * Fixed `world_setseason` command not running season-change logic. * Renamed `install.exe` to `install on Windows.exe` to avoid confusion. * For modders: diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetSeasonCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetSeasonCommand.cs index 897d052f..3d6d4b3d 100644 --- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetSeasonCommand.cs +++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetSeasonCommand.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using StardewValley; namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World @@ -39,6 +39,7 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World // handle Game1.currentSeason = season; + Game1.setGraphicsForSeason(); monitor.Log($"OK, the date is now {Game1.currentSeason} {Game1.dayOfMonth}.", LogLevel.Info); } } -- cgit From 317a33764621f7d0ff9af0239a5fcfea6662a7ed Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 9 Jun 2018 14:31:47 -0400 Subject: fix world_setseason command not normalising season --- docs/release-notes.md | 1 + .../Framework/Commands/World/SetSeasonCommand.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World') diff --git a/docs/release-notes.md b/docs/release-notes.md index 6e16032d..e7c946a3 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -55,6 +55,7 @@ * In console commands: * Added `player_add name`, which lets you add items to your inventory by name instead of ID. * Fixed `world_settime` sometimes breaking NPC schedules (e.g. so they stay in bed). + * Fixed `world_setseason` not normalising the season value. * For the log parser: * Redesigned upload page to make it more intuitive for new players. diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetSeasonCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetSeasonCommand.cs index 3d6d4b3d..b5db9c0d 100644 --- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetSeasonCommand.cs +++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetSeasonCommand.cs @@ -38,7 +38,7 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World return; // handle - Game1.currentSeason = season; + Game1.currentSeason = season.ToLower(); Game1.setGraphicsForSeason(); monitor.Log($"OK, the date is now {Game1.currentSeason} {Game1.dayOfMonth}.", LogLevel.Info); } -- cgit