Added conversion for OnAttacked and OnDeath handlers and added new hook character.damageLimb

This commit is contained in:
EvilFactory
2023-04-25 10:20:24 -03:00
parent 9415219141
commit 93a5065171
3 changed files with 57 additions and 63 deletions
@@ -56,16 +56,19 @@ namespace Barotrauma
return default;
}));
DynValue Call(object function, params object[] arguments) => CallLuaFunction(function, arguments);
void RegisterHandler<T>(Func<Closure, T> converter) => Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(T), v => converter(v.Function));
RegisterHandler(f => (Character.OnDeathHandler)((a1, a2) => Call(f, a1, a2)));
RegisterHandler(f => (Character.OnAttackedHandler)((a1, a2) => Call(f, a1, a2)));
#if CLIENT
RegisterAction<Microsoft.Xna.Framework.Graphics.SpriteBatch, GUICustomComponent>();
RegisterAction<float, Microsoft.Xna.Framework.Graphics.SpriteBatch>();
RegisterAction<Microsoft.Xna.Framework.Graphics.SpriteBatch, float>();
{
DynValue Call(object function, params object[] arguments) => CallLuaFunction(function, arguments);
void RegisterHandler<T>(Func<Closure, T> converter)
=> Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(T), v => converter(v.Function));
RegisterHandler(f => (GUIComponent.SecondaryButtonDownHandler)(
(a1, a2) => Call(f, a1, a2)?.CastToBool() ?? default));