Move the Lua IL patching bullshit to a separate service

This commit is contained in:
Evil Factory
2026-02-03 19:37:47 -03:00
committed by Maplewheels
parent ea602f6d2f
commit 70dd602bcf
7 changed files with 547 additions and 471 deletions
@@ -1,10 +1,9 @@
using System;
using System.Reflection;
using LuaCsCompatPatchFunc = Barotrauma.LuaCsPatch;
namespace Barotrauma.LuaCs.Services.Compatibility;
public interface ILuaCsHook : ILuaCsShim
public interface ILuaCsHook : ILuaPatcher, ILuaCsShim
{
// Event Services
[Obsolete("ACsMod is deprecated. Use ILuaEventService.Add() instead.")]
@@ -15,18 +14,8 @@ public interface ILuaCsHook : ILuaCsShim
//bool Exists(string eventName, string identifier);
object Call(string eventName, params object[] args);
T Call<T>(string eventName, params object[] args);
// Hook/Method Patching
string Patch(string identifier, string className, string methodName, string[] parameterTypes, LuaCsPatchFunc patch, HookMethodType hookType = HookMethodType.Before);
string Patch(string identifier, string className, string methodName, LuaCsPatchFunc patch, HookMethodType hookType = HookMethodType.Before);
string Patch(string className, string methodName, string[] parameterTypes, LuaCsPatchFunc patch, HookMethodType hookType = HookMethodType.Before);
string Patch(string className, string methodName, LuaCsPatchFunc patch, HookMethodType hookType = HookMethodType.Before);
bool RemovePatch(string identifier, string className, string methodName, string[] parameterTypes, HookMethodType hookType);
bool RemovePatch(string identifier, string className, string methodName, HookMethodType hookType);
void HookMethod(string identifier, MethodBase method, LuaCsCompatPatchFunc patch, HookMethodType hookType = HookMethodType.Before, IAssemblyPlugin owner = null);
// Needs to be here instead of ILuaPatcher for compatiility purposes
public enum HookMethodType
{
Before, After