From 7b529bce5716fa45c51428532fc6b6a42ed5bfda Mon Sep 17 00:00:00 2001 From: MapleWheels Date: Mon, 2 Feb 2026 16:32:36 -0500 Subject: [PATCH] Revert "- Removed ACsMod.cs" This reverts commit 54a3e2e5de0cff38ea4fc3750d2eb90f5ea73fe9. --- .../SharedSource/LuaCs/_Plugins/ACsMod.cs | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Plugins/ACsMod.cs diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Plugins/ACsMod.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Plugins/ACsMod.cs new file mode 100644 index 000000000..76dfac73f --- /dev/null +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Plugins/ACsMod.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.IO; + +namespace Barotrauma +{ + [Obsolete("Make your class implement IAssemblyPlugin instead.")] + public abstract class ACsMod : IAssemblyPlugin + { + private static List mods = new List(); + public static List LoadedMods { get => mods; } + + private const string MOD_STORE = "LocalMods/.modstore"; + public static string GetStoreFolder() where T : ACsMod + { + if (!Directory.Exists(MOD_STORE)) Directory.CreateDirectory(MOD_STORE); + var modFolder = $"{MOD_STORE}/{typeof(T)}"; + if (!Directory.Exists(modFolder)) Directory.CreateDirectory(modFolder); + return modFolder; + } + + public bool IsDisposed { get; private set; } + + /// Mod initialization + public ACsMod() + { + IsDisposed = false; + LoadedMods.Add(this); + } + + /// + /// Called as soon as plugin loading begins, use this for internal setup only. + /// + public virtual void Initialize() { } + + /// + /// Called once all plugins have completed Initialization. Put cross-mod code here. + /// + public virtual void OnLoadCompleted() { } + + /// + /// [NotImplemented] Called before vanilla content is loaded. Use to patch Barotrauma classes before they're + /// instantiated. + /// + public void PreInitPatching() { } + + public virtual void Dispose() + { + try + { + Stop(); + } + catch (Exception e) + { + LuaCsLogger.HandleException(e, LuaCsMessageOrigin.CSharpMod); + } + + LoadedMods.Remove(this); + IsDisposed = true; + } + + public abstract void Stop(); + } +}