You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

63 lines
2.3 KiB

using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using AOT;
using UnityEngine;
public partial class GameModule : CallbackHandler<GameModule>
{
private void BuildCallbacks()
{
var callbacks = new Callbacks
{
target = TargetPtr,
SetEntityModel = CreateCallback<GameSetEntityModelCallback>(Callback_GameSetEntityModel),
SetEntityTransform = CreateCallback<GameSetEntityTransformCallback>(Callback_GameSetEntityTransform),
RemoveEntity = CreateCallback<GameRemoveEntityCallback>(Callback_GameRemoveEntity),
};
RegisterCallbacks(callbacks);
}
/// <summary>
/// This matches unity_gamecalls_t from mod_uniquake.c in native code.
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 0)]
private class Callbacks
{
public IntPtr target;
public IntPtr SetEntityModel;
public IntPtr SetEntityTransform;
public IntPtr RemoveEntity;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void GameSetEntityModelCallback(IntPtr target, int entityNum, [MarshalAs(UnmanagedType.LPStr)] string modelName, int frame);
[MonoPInvokeCallback(typeof(GameSetEntityModelCallback))]
private static void Callback_GameSetEntityModel(IntPtr target, int entityNum, string modelName, int frame)
{
GetSelf(target).SetEntityModel(entityNum, modelName, frame);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void GameSetEntityTransformCallback(IntPtr target, int entityNum, QVec3 origin, QVec3 angles);
[MonoPInvokeCallback(typeof(GameSetEntityTransformCallback))]
private static void Callback_GameSetEntityTransform(IntPtr target, int entityNum, QVec3 origin, QVec3 angles)
{
GetSelf(target).SetEntityTransform(entityNum, origin, angles);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void GameRemoveEntityCallback(IntPtr target, int entityNum);
[MonoPInvokeCallback(typeof(GameRemoveEntityCallback))]
private static void Callback_GameRemoveEntity(IntPtr target, int entityNum)
{
GetSelf(target).RemoveEntity(entityNum);
}
}