SMSMod-24HourTime/Plugin.cs
2024-05-02 19:06:57 +02:00

44 lines
1.4 KiB
C#

using BepInEx;
using HarmonyLib;
using MyBox;
using System;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace _24HourTime
{
[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
public class Plugin : BaseUnityPlugin
{
private void Awake()
{
Logger.LogInfo($"Plugin {PluginInfo.PLUGIN_GUID} is loaded! Applying patch...");
Harmony harmony = new Harmony(PluginInfo.PLUGIN_GUID);
harmony.PatchAll();
SceneManager.sceneLoaded += (a, b) =>
{
var go = GameObject.Find("Time BG");
if(go != null)
{
Logger.LogInfo("Moving Time BG");
go.transform.localPosition = new Vector3(1005f, go.transform.localPosition.y, go.transform.localPosition.z);
}
};
}
}
[HarmonyPatch(typeof(TimeText), "UpdateTimeText")]
public static class TimeText_UpdateTimeText_Patch
{
public static void Postfix(TimeText __instance)
{
string text = string.Concat(new string[]
{
(__instance.m_DayCycle.CurrentHour + (__instance.m_DayCycle.AM ^ __instance.m_DayCycle.CurrentHour == 12 ? 0 : 12)).ToString("00"),
":",
__instance.m_DayCycle.CurrentMinute.ToString("00")
});
__instance.m_TimeText.text = text;
}
}
}