264 lines
8.5 KiB
C#
264 lines
8.5 KiB
C#
#if USE_UNI_LUA
|
|
using LuaAPI = UniLua.Lua;
|
|
using RealStatePtr = UniLua.ILuaState;
|
|
using LuaCSFunction = UniLua.CSharpFunctionDelegate;
|
|
#else
|
|
using LuaAPI = XLua.LuaDLL.Lua;
|
|
using RealStatePtr = System.IntPtr;
|
|
using LuaCSFunction = XLua.LuaDLL.lua_CSFunction;
|
|
#endif
|
|
|
|
using XLua;
|
|
using System.Collections.Generic;
|
|
|
|
|
|
namespace XLua.CSObjectWrap
|
|
{
|
|
using Utils = XLua.Utils;
|
|
public class BFBattleUnitAttrWrap
|
|
{
|
|
public static void __Register(RealStatePtr L)
|
|
{
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
System.Type type = typeof(BF.BattleUnitAttr);
|
|
Utils.BeginObjectRegister(type, L, translator, 0, 3, 3, 3);
|
|
|
|
Utils.RegisterFunc(L, Utils.METHOD_IDX, "BindGetAttributeFunc", _m_BindGetAttributeFunc);
|
|
Utils.RegisterFunc(L, Utils.METHOD_IDX, "TryGetAttributeFromLua", _m_TryGetAttributeFromLua);
|
|
Utils.RegisterFunc(L, Utils.METHOD_IDX, "GetAttribute", _m_GetAttribute);
|
|
|
|
|
|
Utils.RegisterFunc(L, Utils.GETTER_IDX, "UnitAttribute", _g_get_UnitAttribute);
|
|
Utils.RegisterFunc(L, Utils.GETTER_IDX, "LuaGetAttributeFunc", _g_get_LuaGetAttributeFunc);
|
|
Utils.RegisterFunc(L, Utils.GETTER_IDX, "Side", _g_get_Side);
|
|
|
|
Utils.RegisterFunc(L, Utils.SETTER_IDX, "UnitAttribute", _s_set_UnitAttribute);
|
|
Utils.RegisterFunc(L, Utils.SETTER_IDX, "LuaGetAttributeFunc", _s_set_LuaGetAttributeFunc);
|
|
Utils.RegisterFunc(L, Utils.SETTER_IDX, "Side", _s_set_Side);
|
|
|
|
|
|
Utils.EndObjectRegister(type, L, translator, null, null,
|
|
null, null, null);
|
|
|
|
Utils.BeginClassRegister(type, L, __CreateInstance, 1, 0, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Utils.EndClassRegister(type, L, translator);
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int __CreateInstance(RealStatePtr L)
|
|
{
|
|
|
|
try {
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
if(LuaAPI.lua_gettop(L) == 1)
|
|
{
|
|
|
|
var gen_ret = new BF.BattleUnitAttr();
|
|
translator.Push(L, gen_ret);
|
|
|
|
return 1;
|
|
}
|
|
|
|
}
|
|
catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
return LuaAPI.luaL_error(L, "invalid arguments to BF.BattleUnitAttr constructor!");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _m_BindGetAttributeFunc(RealStatePtr L)
|
|
{
|
|
try {
|
|
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
|
|
BF.BattleUnitAttr gen_to_be_invoked = (BF.BattleUnitAttr)translator.FastGetCSObj(L, 1);
|
|
|
|
|
|
|
|
{
|
|
System.Action<int> _getFunc = translator.GetDelegate<System.Action<int>>(L, 2);
|
|
|
|
gen_to_be_invoked.BindGetAttributeFunc( _getFunc );
|
|
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _m_TryGetAttributeFromLua(RealStatePtr L)
|
|
{
|
|
try {
|
|
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
|
|
BF.BattleUnitAttr gen_to_be_invoked = (BF.BattleUnitAttr)translator.FastGetCSObj(L, 1);
|
|
|
|
|
|
|
|
{
|
|
|
|
gen_to_be_invoked.TryGetAttributeFromLua( );
|
|
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _m_GetAttribute(RealStatePtr L)
|
|
{
|
|
try {
|
|
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
|
|
BF.BattleUnitAttr gen_to_be_invoked = (BF.BattleUnitAttr)translator.FastGetCSObj(L, 1);
|
|
|
|
|
|
|
|
{
|
|
string _attr = LuaAPI.lua_tostring(L, 2);
|
|
|
|
gen_to_be_invoked.GetAttribute( _attr );
|
|
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _g_get_UnitAttribute(RealStatePtr L)
|
|
{
|
|
try {
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
BF.BattleUnitAttr gen_to_be_invoked = (BF.BattleUnitAttr)translator.FastGetCSObj(L, 1);
|
|
translator.Push(L, gen_to_be_invoked.UnitAttribute);
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _g_get_LuaGetAttributeFunc(RealStatePtr L)
|
|
{
|
|
try {
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
BF.BattleUnitAttr gen_to_be_invoked = (BF.BattleUnitAttr)translator.FastGetCSObj(L, 1);
|
|
translator.Push(L, gen_to_be_invoked.LuaGetAttributeFunc);
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _g_get_Side(RealStatePtr L)
|
|
{
|
|
try {
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
BF.BattleUnitAttr gen_to_be_invoked = (BF.BattleUnitAttr)translator.FastGetCSObj(L, 1);
|
|
LuaAPI.xlua_pushinteger(L, gen_to_be_invoked.Side);
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _s_set_UnitAttribute(RealStatePtr L)
|
|
{
|
|
try {
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
BF.BattleUnitAttr gen_to_be_invoked = (BF.BattleUnitAttr)translator.FastGetCSObj(L, 1);
|
|
gen_to_be_invoked.UnitAttribute = (BF.BattleUnitAttribute)translator.GetObject(L, 2, typeof(BF.BattleUnitAttribute));
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _s_set_LuaGetAttributeFunc(RealStatePtr L)
|
|
{
|
|
try {
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
BF.BattleUnitAttr gen_to_be_invoked = (BF.BattleUnitAttr)translator.FastGetCSObj(L, 1);
|
|
gen_to_be_invoked.LuaGetAttributeFunc = translator.GetDelegate<System.Action<int>>(L, 2);
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _s_set_Side(RealStatePtr L)
|
|
{
|
|
try {
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
BF.BattleUnitAttr gen_to_be_invoked = (BF.BattleUnitAttr)translator.FastGetCSObj(L, 1);
|
|
gen_to_be_invoked.Side = LuaAPI.xlua_tointeger(L, 2);
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|