Got darker night working somewhat. Needs a lot of tweaking.
This commit is contained in:
parent
5c78f88e6a
commit
15455416a8
|
@ -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<DarkerNightConfig>(Path.Combine("Configs", "DarkerNightConfig.json"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Config = new DarkerNightConfig();
|
||||||
|
Revitalize.ModCore.ModHelper.Data.WriteJsonFile<DarkerNightConfig>(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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -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));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,13 +17,16 @@ namespace Revitalize.Framework.Objects
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A custom object template.
|
/// A custom object template.
|
||||||
|
///
|
||||||
|
/// Todo:
|
||||||
|
/// -Multiple Lights
|
||||||
|
/// -Events when walking over?
|
||||||
|
/// -Inventories
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CustomObject : PySObject
|
public class CustomObject : PySObject
|
||||||
{
|
{
|
||||||
|
|
||||||
public string id;
|
public string id;
|
||||||
public BasicItemInformation info;
|
public BasicItemInformation info;
|
||||||
|
|
||||||
public GameLocation location;
|
public GameLocation location;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -11,6 +11,8 @@ using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Revitalize.Framework.Graphics;
|
using Revitalize.Framework.Graphics;
|
||||||
using Revitalize.Framework.Graphics.Animations;
|
using Revitalize.Framework.Graphics.Animations;
|
||||||
|
using Revitalize.Framework.Environment;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace Revitalize
|
namespace Revitalize
|
||||||
{
|
{
|
||||||
|
@ -27,7 +29,29 @@ namespace Revitalize
|
||||||
ModHelper = helper;
|
ModHelper = helper;
|
||||||
ModMonitor = Monitor;
|
ModMonitor = Monitor;
|
||||||
|
|
||||||
|
createDirectories();
|
||||||
|
initailizeComponents();
|
||||||
|
|
||||||
|
|
||||||
ModHelper.Events.GameLoop.SaveLoaded += GameLoop_SaveLoaded;
|
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)
|
private void GameLoop_SaveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e)
|
||||||
|
|
|
@ -45,9 +45,12 @@
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Framework\Environment\DarkerNight.cs" />
|
||||||
|
<Compile Include="Framework\Environment\DarkerNightConfig.cs" />
|
||||||
<Compile Include="Framework\Graphics\Animations\Animation.cs" />
|
<Compile Include="Framework\Graphics\Animations\Animation.cs" />
|
||||||
<Compile Include="Framework\Graphics\Animations\AnimationManager.cs" />
|
<Compile Include="Framework\Graphics\Animations\AnimationManager.cs" />
|
||||||
<Compile Include="Framework\Graphics\Texture2DExtended.cs" />
|
<Compile Include="Framework\Graphics\Texture2DExtended.cs" />
|
||||||
|
<Compile Include="Framework\Illuminate\ColorExtensions.cs" />
|
||||||
<Compile Include="Framework\Objects\BasicItemInformation.cs" />
|
<Compile Include="Framework\Objects\BasicItemInformation.cs" />
|
||||||
<Compile Include="Framework\Objects\CustomObject.cs" />
|
<Compile Include="Framework\Objects\CustomObject.cs" />
|
||||||
<Compile Include="Framework\Objects\MultiTiledComponent.cs" />
|
<Compile Include="Framework\Objects\MultiTiledComponent.cs" />
|
||||||
|
|
Loading…
Reference in New Issue