Client LuaCsForBarotrauma
ACsMod.cs
1 using System;
2 using System.Collections.Generic;
3 using System.IO;
4 
5 namespace Barotrauma
6 {
7  [Obsolete("Make your class implement IAssemblyPlugin instead.")]
8  public abstract class ACsMod : IAssemblyPlugin
9  {
10  private static List<ACsMod> mods = new List<ACsMod>();
11  public static List<ACsMod> LoadedMods { get => mods; }
12 
13  private const string MOD_STORE = "LocalMods/.modstore";
14  public static string GetStoreFolder<T>() where T : ACsMod
15  {
16  if (!Directory.Exists(MOD_STORE)) Directory.CreateDirectory(MOD_STORE);
17  var modFolder = $"{MOD_STORE}/{typeof(T)}";
18  if (!Directory.Exists(modFolder)) Directory.CreateDirectory(modFolder);
19  return modFolder;
20  }
21 
22  public bool IsDisposed { get; private set; }
23 
25  public ACsMod()
26  {
27  IsDisposed = false;
28  LoadedMods.Add(this);
29  }
30 
34  public virtual void Initialize() { }
35 
39  public virtual void OnLoadCompleted() { }
40 
45  public void PreInitPatching() { }
46 
47  public virtual void Dispose()
48  {
49  try
50  {
51  Stop();
52  }
53  catch (Exception e)
54  {
55  LuaCsLogger.HandleException(e, LuaCsMessageOrigin.CSharpMod);
56  }
57 
58  LoadedMods.Remove(this);
59  IsDisposed = true;
60  }
61 
62  public abstract void Stop();
63  }
64 }
ACsMod()
Mod initialization.
Definition: ACsMod.cs:25
virtual void OnLoadCompleted()
Called once all plugins have completed Initialization. Put cross-mod code here.
Definition: ACsMod.cs:39
bool IsDisposed
Definition: ACsMod.cs:22
abstract void Stop()
void PreInitPatching()
[NotImplemented] Called before vanilla content is loaded. Use to patch Barotrauma classes before they...
Definition: ACsMod.cs:45
virtual void Dispose()
Definition: ACsMod.cs:47
virtual void Initialize()
Called as soon as plugin loading begins, use this for internal setup only.
Definition: ACsMod.cs:34
static List< ACsMod > LoadedMods
Definition: ACsMod.cs:11
static string GetStoreFolder< T >()
Definition: ACsMod.cs:14
static void HandleException(Exception ex, LuaCsMessageOrigin origin)