diff --git a/SCHIZO/Attributes/InitializeModAttribute.cs b/SCHIZO/Attributes/InitializeModAttribute.cs new file mode 100644 index 00000000..eedf5bb6 --- /dev/null +++ b/SCHIZO/Attributes/InitializeModAttribute.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using JetBrains.Annotations; + +namespace SCHIZO.Attributes; + +[AttributeUsage(AttributeTargets.Method, Inherited = false)] +[MeansImplicitUse] +public sealed class InitializeModAttribute : Attribute +{ + public static void Run() + { + IEnumerable methods = PLUGIN_ASSEMBLY.GetTypes() + .SelectMany(t => t.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)) + .Where(m => m.GetCustomAttribute() != null); + + foreach (MethodInfo method in methods) + { + LOGGER.LogInfo($"Calling initialization method {method.DeclaringType}.{method.Name}"); + method.Invoke(null, null); + } + } +} diff --git a/SCHIZO/Plugin.cs b/SCHIZO/Plugin.cs index bcc1f82d..10af62ad 100644 --- a/SCHIZO/Plugin.cs +++ b/SCHIZO/Plugin.cs @@ -5,9 +5,12 @@ using BepInEx.Logging; using ECCLibrary; using HarmonyLib; +using Nautilus.Handlers; +using SCHIZO.Attributes; using SCHIZO.ConsoleCommands; using SCHIZO.Helpers; using SCHIZO.Resources; +using SCHIZO.Tweaks; using UnityEngine; namespace SCHIZO; @@ -44,6 +47,8 @@ private IEnumerator Start() Assets.Mod_Registry.InvokeRegister(); Assets.Mod_Registry.InvokePostRegister(); + InitializeModAttribute.Run(); + RegisterConsoleCommandsAttribute.RegisterAll(); } } diff --git a/SCHIZO/Tweaks/SeatruckSleeperModuleRename.BelowZero.cs b/SCHIZO/Tweaks/SeatruckSleeperModuleRename.BelowZero.cs new file mode 100644 index 00000000..69cab168 --- /dev/null +++ b/SCHIZO/Tweaks/SeatruckSleeperModuleRename.BelowZero.cs @@ -0,0 +1,16 @@ +using Nautilus.Handlers; +using SCHIZO.Attributes; + +namespace SCHIZO.Tweaks; + +public static class SeatruckSleeperModuleRename +{ + [InitializeMod] + public static void Apply() + { + LanguageHandler.SetTechTypeName(TechType.SeaTruckSleeperModule, "Seatruck Jukebox Module"); + LanguageHandler.SetTechTypeName(TechType.SeaTruckSleeperModuleFragment, "Seatruck Jukebox Module Fragment"); + LanguageHandler.SetLanguageLine("Ency_SeaTruckSleeperModule", "Seatruck Jukebox Module"); + LanguageHandler.SetLanguageLine("PilotSeaTruckSleeperModule", "Pilot Jukebox Module"); + } +}