diff --git a/GeneralMods/Revitalize/Framework/Environment/DarkerNight.cs b/GeneralMods/Revitalize/Framework/Environment/DarkerNight.cs new file mode 100644 index 00000000..fa4c5d6a --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Environment/DarkerNight.cs @@ -0,0 +1,49 @@ +using StardewValley; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Revitalize.Framework.Illuminate; +using System.IO; + +namespace Revitalize.Framework.Environment +{ + public class DarkerNight + { + + public static float IncrediblyDark = 0.9f; + public static float VeryDark = 0.75f; + public static float SomewhatDark = 0.50f; + + public static DarkerNightConfig Config; + + public static void InitializeConfig() + { + if (File.Exists(Path.Combine(Revitalize.ModCore.ModHelper.DirectoryPath, "Configs", "DarkerNightConfig.json"))) + { + Config = Revitalize.ModCore.ModHelper.Data.ReadJsonFile(Path.Combine("Configs", "DarkerNightConfig.json")); + } + else + { + Config = new DarkerNightConfig(); + Revitalize.ModCore.ModHelper.Data.WriteJsonFile(Path.Combine("Configs", "DarkerNightConfig.json"),Config); + } + } + + public static void setDarkerNightColor() + { + if (Game1.player == null) return; + if (Game1.player.currentLocation.IsOutdoors && Game1.timeOfDay>= Game1.getTrulyDarkTime()) + { + //Game1.ambientLight = Game1.ambientLight.GreyScaleAverage(); + Game1.outdoorLight = Game1.ambientLight*Config.DarknessIntensity; + + Revitalize.ModCore.log("OUT: " + Game1.outdoorLight); + Revitalize.ModCore.log("Ambient"+Game1.ambientLight); + } + } + + + } +} diff --git a/GeneralMods/Revitalize/Framework/Environment/DarkerNightConfig.cs b/GeneralMods/Revitalize/Framework/Environment/DarkerNightConfig.cs new file mode 100644 index 00000000..f4da30bb --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Environment/DarkerNightConfig.cs @@ -0,0 +1,21 @@ +using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Revitalize.Framework.Environment +{ + public class DarkerNightConfig + { + public float DarknessIntensity; + + + public DarkerNightConfig() + { + this.DarknessIntensity = .9f; + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Illuminate/ColorExtensions.cs b/GeneralMods/Revitalize/Framework/Illuminate/ColorExtensions.cs new file mode 100644 index 00000000..1cc17128 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Illuminate/ColorExtensions.cs @@ -0,0 +1,19 @@ +using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Revitalize.Framework.Illuminate +{ + public static class ColorExtensions + { + public static Color GreyScaleAverage(this Color color) + { + int value = (color.R + color.G + color.B) / 3; + return new Color(new Vector3(value)); + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index 67b2edb0..cd6f2ab0 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -17,13 +17,16 @@ namespace Revitalize.Framework.Objects { /// /// A custom object template. + /// + /// Todo: + /// -Multiple Lights + /// -Events when walking over? + /// -Inventories /// public class CustomObject : PySObject { - public string id; public BasicItemInformation info; - public GameLocation location; /// diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 4c183826..2026cf8b 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -11,6 +11,8 @@ using System.Text; using System.Threading.Tasks; using Revitalize.Framework.Graphics; using Revitalize.Framework.Graphics.Animations; +using Revitalize.Framework.Environment; +using System.IO; namespace Revitalize { @@ -27,7 +29,29 @@ namespace Revitalize ModHelper = helper; ModMonitor = Monitor; + createDirectories(); + initailizeComponents(); + + ModHelper.Events.GameLoop.SaveLoaded += GameLoop_SaveLoaded; + ModHelper.Events.GameLoop.TimeChanged += GameLoop_TimeChanged; + } + + + private void createDirectories() + { + Directory.CreateDirectory(Path.Combine(this.Helper.DirectoryPath, "Configs")); + } + + private void initailizeComponents() + { + DarkerNight.InitializeConfig(); + } + + + private void GameLoop_TimeChanged(object sender, StardewModdingAPI.Events.TimeChangedEventArgs e) + { + DarkerNight.setDarkerNightColor(); } private void GameLoop_SaveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e) diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index dd1f7f2a..7c729339 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -45,9 +45,12 @@ + + +