Skip to content

Commit

Permalink
initialization thingies + seatruck sleeper rename
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexejhero committed Apr 25, 2024
1 parent baceedb commit faa25cf
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
25 changes: 25 additions & 0 deletions SCHIZO/Attributes/InitializeModAttribute.cs
Original file line number Diff line number Diff line change
@@ -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<MethodInfo> methods = PLUGIN_ASSEMBLY.GetTypes()
.SelectMany(t => t.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))
.Where(m => m.GetCustomAttribute<InitializeModAttribute>() != null);

foreach (MethodInfo method in methods)
{
LOGGER.LogInfo($"Calling initialization method {method.DeclaringType}.{method.Name}");
method.Invoke(null, null);
}
}
}
5 changes: 5 additions & 0 deletions SCHIZO/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -44,6 +47,8 @@ private IEnumerator Start()
Assets.Mod_Registry.InvokeRegister();
Assets.Mod_Registry.InvokePostRegister();

InitializeModAttribute.Run();

RegisterConsoleCommandsAttribute.RegisterAll();
}
}
16 changes: 16 additions & 0 deletions SCHIZO/Tweaks/SeatruckSleeperModuleRename.BelowZero.cs
Original file line number Diff line number Diff line change
@@ -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");
}
}

0 comments on commit faa25cf

Please sign in to comment.