new hook call method + function to delegate conversion
This commit is contained in:
@@ -9,12 +9,6 @@ namespace Barotrauma
|
||||
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()
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
|
||||
partial class LuaCsSetup
|
||||
{
|
||||
// CSharp wrapper for LuaCsHook
|
||||
public class CsHook : LuaCsHookWrapper
|
||||
{
|
||||
public CsHook(LuaCsHook hook) : base(hook) { }
|
||||
|
||||
public void HookMethod(string identifier, MethodInfo method, CsPatchDelegate hook, HookMethodType hookType = HookMethodType.Before, ACsMod owner = null) =>
|
||||
_hook.HookCsMethod(identifier, method, hook, hookType, owner);
|
||||
|
||||
public void UnhookMethod(string identifier, MethodInfo method, HookMethodType hookType = HookMethodType.Before) =>
|
||||
_hook.RemovePatch(identifier, method, hookType);
|
||||
|
||||
public void Add(string name, string hookName, CsHookDelegate hook, ACsMod owner = null) =>
|
||||
_hook.AddCsHook(name, hookName, hook, owner);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using Microsoft.CodeAnalysis.Scripting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection.Metadata;
|
||||
|
||||
@@ -28,7 +26,7 @@ namespace Barotrauma {
|
||||
};
|
||||
private static string[] typessProhibited = new string[] {
|
||||
//"System.Reflection",
|
||||
"System.IO.File",
|
||||
"System.IO",
|
||||
};
|
||||
public static bool IsTypeAllowed(string usingName)
|
||||
{
|
||||
|
||||
@@ -48,22 +48,13 @@ namespace Barotrauma
|
||||
{
|
||||
var s = str.Replace("\\", "/");
|
||||
|
||||
if (s.EndsWith(".cs"))
|
||||
{
|
||||
LuaCsSetup.PrintCsMessage(s);
|
||||
scriptFiles.Add(s);
|
||||
}
|
||||
if (s.EndsWith(".cs") && LuaCsFile.IsPathAllowedCsException(s)) scriptFiles.Add(s);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (scriptFiles.Count <= 0) return;
|
||||
|
||||
var mainFile = scriptFiles.Find(s => s.EndsWith("Main.cs"));
|
||||
if (mainFile == null) throw new Exception("Mod folder has no Main.cs file");
|
||||
scriptFiles.Remove(mainFile);
|
||||
scriptFiles.Add(mainFile);
|
||||
|
||||
// Check file content for prohibited stuff
|
||||
foreach (var file in scriptFiles)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user