diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-02-21 18:29:14 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-02-21 18:29:14 -0500 |
commit | 27accf55a5e008819015a599a484c8e670cc546f (patch) | |
tree | ca5c9ce16e5fb58b93b5cce0039066d2799f69d8 /src | |
parent | 033b3856413f51e26e74498ea9fe3de291d4e93a (diff) | |
download | SMAPI-27accf55a5e008819015a599a484c8e670cc546f.tar.gz SMAPI-27accf55a5e008819015a599a484c8e670cc546f.tar.bz2 SMAPI-27accf55a5e008819015a599a484c8e670cc546f.zip |
update ambient light when setting game time
Diffstat (limited to 'src')
-rw-r--r-- | src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetTimeCommand.cs | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetTimeCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetTimeCommand.cs index 6782e38a..2d4b4565 100644 --- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetTimeCommand.cs +++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetTimeCommand.cs @@ -1,5 +1,5 @@ -using System; using System.Linq; +using Microsoft.Xna.Framework; using StardewValley; namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World @@ -45,12 +45,8 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World /// <param name="time">The time of day.</param> 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) => (span.Hours * 100) + span.Minutes; - // transition to new time - int intervals = (int)((ToTimeSpan(time) - ToTimeSpan(Game1.timeOfDay)).TotalMinutes / 10); + int intervals = Utility.CalculateMinutesBetweenTimes(Game1.timeOfDay, time) / 10; if (intervals > 0) { for (int i = 0; i < intervals; i++) @@ -60,10 +56,20 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World { for (int i = 0; i > intervals; i--) { - Game1.timeOfDay = FromTimeSpan(ToTimeSpan(Game1.timeOfDay).Subtract(TimeSpan.FromMinutes(20))); // offset 20 minutes so game updates to next interval + Game1.timeOfDay = Utility.ModifyTime(Game1.timeOfDay, -20); // offset 20 mins so game updates to next interval Game1.performTenMinuteClockUpdate(); } } + + // reset ambient light + // White is the default non-raining color. If it's raining or dark out, UpdateGameClock + // below will update it automatically. + Game1.outdoorLight = Color.White; + Game1.ambientLight = Color.White; + + // run clock update (to correct lighting, etc) + Game1.gameTimeInterval = 0; + Game1.UpdateGameClock(Game1.currentGameTime); } } } |