using System.Diagnostics; using System.Reflection; using HarmonyLib; using JetBrains.Annotations; using KSA; using ModMenu; using StarMap.API; using static Brutal.Logging.DefaultCategory; namespace OemLoader; [UsedImplicitly] [StarMapMod] public class OemLoader { public static OemLoader? Instance { get; private set; } public static readonly DateTime KsaEpoch = new(2025, 11, 30, 0, 0, 0); [PublicAPI] public readonly string Version; public readonly MainWindow Window; private static Harmony? _harmony = new("OemLoader"); public OemLoader() { var version = typeof(OemLoader).Assembly .GetCustomAttribute()? .InformationalVersion; Debug.Assert(version is not null); Version = version; Window = new MainWindow($"OemLoader {Version}"); if (Instance is null) Instance = this; else Log.Warning("OemLoader: created multiple mod instances"); } [UsedImplicitly] [StarMapImmediateLoad] public void Init(Mod definingMod) { Log.Info($"OemLoader {Version} loaded"); } [UsedImplicitly] [StarMapAllModsLoaded] public void FullyLoaded() { _harmony?.PatchAll(typeof(OemLoader).Assembly); } [UsedImplicitly] [StarMapUnload] public void Unload() { _harmony?.UnpatchAll("OemLoader"); _harmony = null; } [UsedImplicitly] [ModMenuEntry("OemLoader")] public static void DrawMenu() { if (Instance is null) return; ImGuiHelper.DrawMenuItem("Ephemeris Loader", ref Instance.Window.Open); } }