Purely proof-of-concept at the moment. Barely anything besides registering new script functions has been tested.
Website
The 'AGSPlugin' class contains the callback methods as described here.
RegisterScriptFunction example:
Declare a method:
Code: ags
and a matching delegate:
Code: ags
The delegate has to use the UnmanagedFunctionPointer attribute with CallingConvention.Cdecl.
Register the script header in EditorStartup:
Code: ags
Register the script function in EngineStartup:
Code: ags
Website
The 'AGSPlugin' class contains the callback methods as described here.
RegisterScriptFunction example:
Declare a method:
private static int AddNumbers(int a, int b)
{
return a + b;
}
and a matching delegate:
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int AddNumbersDel(int a, int b);
The delegate has to use the UnmanagedFunctionPointer attribute with CallingConvention.Cdecl.
Register the script header in EditorStartup:
public int EditorStartup(IAGSEditor editor)
{
editor.RegisterScriptHeader("import int AddNumbers(int, int);
");
return 0;
}
Register the script function in EngineStartup:
private AddNumbersDel del;
public void EngineStartup(IAGSEngine engine)
{
del = new AddNumbersDel(AddNumbers);
IntPtr address = Marshal.GetFunctionPointerForDelegate(del);
engine.RegisterScriptFunction("AddNumbers", address);
}