hook merge + hook wrappers

This commit is contained in:
Oiltanker
2022-04-13 01:34:38 +03:00
parent 1e6ac68e86
commit 5d06df437e
40 changed files with 539 additions and 284 deletions
@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Reflection;
namespace Barotrauma
{
public abstract class ACsMod : IDisposable
{
private static List<ACsMod> mods = new List<ACsMod>();
public static List<ACsMod> LoadedMods { get => mods; }
//public static ACsMod CreateInstance(Type type)
//{
// if (!type.IsSubclassOf(typeof(ACsMod))) throw new Exception("Type argument is not the subclass of ACsMod.");
// return type.GetConstructor(new Type[] { }).Invoke(new object[] { }) as ACsMod;
//}
public bool IsDisposed { get; private set; }
public ACsMod()
{
IsDisposed = false;
LoadedMods.Add(this);
Start();
}
public void Dispose() {
Stop();
LoadedMods.Remove(this);
IsDisposed = true;
}
// TODO: some hooks
/// Mod initialization
public abstract void Start();
/// Error or client exit
public abstract void Stop();
public virtual void Update() { }
}
}