40 lines
989 B
C#
40 lines
989 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using MoonSharp.Interpreter;
|
|
using Microsoft.Xna.Framework;
|
|
|
|
namespace Barotrauma
|
|
{
|
|
|
|
public static class LuaCustomConverters
|
|
{
|
|
|
|
public static void RegisterAll()
|
|
{
|
|
RegisterSimpleAction<Item>();
|
|
RegisterSimpleAction();
|
|
}
|
|
|
|
public static void RegisterSimpleAction<T>()
|
|
{
|
|
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(Action<T>), v =>
|
|
{
|
|
var function = v.Function;
|
|
return (Action<T>)(p => function.Call(p));
|
|
});
|
|
}
|
|
|
|
|
|
|
|
public static void RegisterSimpleAction()
|
|
{
|
|
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(Action), v =>
|
|
{
|
|
var function = v.Function;
|
|
return (Action)(() => function.Call());
|
|
});
|
|
}
|
|
}
|
|
}
|