time is now configurabe
This commit is contained in:
@@ -14,7 +14,7 @@ public class Behaviour : MonoBehaviour
|
||||
{
|
||||
DayCycleManager __instance = Singleton<DayCycleManager>.Instance;
|
||||
StoreLightManager __storelightmanager = Singleton<StoreLightManager>.Instance;
|
||||
if (__instance.CurrentHour == 6 && __instance.CurrentMinute == 0 && __instance.AM == false)
|
||||
if (__instance.CurrentHour == Plugin.Hour && __instance.CurrentMinute == Plugin.Minute && __instance.AM == Plugin.AM)
|
||||
{
|
||||
for (int i = 0; i < LightSwitches.Length; i++)
|
||||
{
|
||||
|
||||
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [1.1.0] - 2026-04-06
|
||||
|
||||
### Added
|
||||
- time is now configurable
|
||||
|
||||
## [1.0.0] - 2026-04-04
|
||||
|
||||
### Added
|
||||
|
||||
46
Plugin.cs
46
Plugin.cs
@@ -1,4 +1,6 @@
|
||||
using BepInEx;
|
||||
using System.Net;
|
||||
using BepInEx;
|
||||
using BepInEx.Configuration;
|
||||
using BepInEx.Logging;
|
||||
using BepInEx.Unity.IL2CPP;
|
||||
using Il2CppInterop.Runtime.Injection;
|
||||
@@ -13,15 +15,55 @@ public class Plugin : BasePlugin
|
||||
{
|
||||
public const string PLUGIN_GUID = "de.mpburgmann.AutoLight";
|
||||
public const string PLUGIN_NAME = "AutoLight";
|
||||
public const string PLUGIN_VERSION = "1.0.0";
|
||||
public const string PLUGIN_VERSION = "1.1.0";
|
||||
internal static new ManualLogSource Log;
|
||||
|
||||
private static ConfigEntry<string> Time;
|
||||
public static int Hour;
|
||||
public static int Minute;
|
||||
public static bool AM;
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
Log = base.Log;
|
||||
Log.LogInfo($"Plugin {PLUGIN_GUID} is loaded!");
|
||||
|
||||
SceneManager.sceneLoaded += (UnityAction<Scene, LoadSceneMode>) OnSceneLoaded;
|
||||
|
||||
Time = Config.Bind("Settings", "Time", "18:00", "Time to turn light on. Use 24HR format");
|
||||
LoadTime();
|
||||
}
|
||||
|
||||
private static void LoadTime()
|
||||
{
|
||||
string[] time_parts = Time.Value.Split(":");
|
||||
if (time_parts.Length == 2)
|
||||
{
|
||||
Hour = int.Parse(time_parts[0]);
|
||||
Minute = int.Parse(time_parts[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Hour = 18;
|
||||
Minute = 0;
|
||||
}
|
||||
|
||||
if (Hour < 8 || Hour > 21)
|
||||
{
|
||||
Time.Value = "18:00";
|
||||
Hour = 18;
|
||||
Minute = 0;
|
||||
}
|
||||
|
||||
if (Hour >= 12)
|
||||
{
|
||||
AM = false;
|
||||
Hour -= 12;
|
||||
}
|
||||
else
|
||||
{
|
||||
AM = true;
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
|
||||
|
||||
Reference in New Issue
Block a user