375 lines
12 KiB
C#
375 lines
12 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 BFAssetBundleObjectWrap
|
|
{
|
|
public static void __Register(RealStatePtr L)
|
|
{
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
System.Type type = typeof(BF.AssetBundleObject);
|
|
Utils.BeginObjectRegister(type, L, translator, 0, 7, 3, 0);
|
|
|
|
Utils.RegisterFunc(L, Utils.METHOD_IDX, "LoadBundleAsync", _m_LoadBundleAsync);
|
|
Utils.RegisterFunc(L, Utils.METHOD_IDX, "StartLoadAsync", _m_StartLoadAsync);
|
|
Utils.RegisterFunc(L, Utils.METHOD_IDX, "LoadSync", _m_LoadSync);
|
|
Utils.RegisterFunc(L, Utils.METHOD_IDX, "Tick", _m_Tick);
|
|
Utils.RegisterFunc(L, Utils.METHOD_IDX, "Complete", _m_Complete);
|
|
Utils.RegisterFunc(L, Utils.METHOD_IDX, "AddUnloadCallback", _m_AddUnloadCallback);
|
|
Utils.RegisterFunc(L, Utils.METHOD_IDX, "Unload", _m_Unload);
|
|
|
|
|
|
Utils.RegisterFunc(L, Utils.GETTER_IDX, "AssetBundleConfig", _g_get_AssetBundleConfig);
|
|
Utils.RegisterFunc(L, Utils.GETTER_IDX, "Assetbundle", _g_get_Assetbundle);
|
|
Utils.RegisterFunc(L, Utils.GETTER_IDX, "Timeout", _g_get_Timeout);
|
|
|
|
|
|
|
|
Utils.EndObjectRegister(type, L, translator, null, null,
|
|
null, null, null);
|
|
|
|
Utils.BeginClassRegister(type, L, __CreateInstance, 1, 1, 1);
|
|
|
|
|
|
|
|
Utils.RegisterFunc(L, Utils.CLS_GETTER_IDX, "fullpathDict", _g_get_fullpathDict);
|
|
|
|
Utils.RegisterFunc(L, Utils.CLS_SETTER_IDX, "fullpathDict", _s_set_fullpathDict);
|
|
|
|
|
|
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) == 3 && translator.Assignable<BF.AssetBundleConfig>(L, 2) && translator.Assignable<BF.AssetBundleLoader>(L, 3))
|
|
{
|
|
BF.AssetBundleConfig _config = (BF.AssetBundleConfig)translator.GetObject(L, 2, typeof(BF.AssetBundleConfig));
|
|
BF.AssetBundleLoader _loader = (BF.AssetBundleLoader)translator.GetObject(L, 3, typeof(BF.AssetBundleLoader));
|
|
|
|
var gen_ret = new BF.AssetBundleObject(_config, _loader);
|
|
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.AssetBundleObject constructor!");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _m_LoadBundleAsync(RealStatePtr L)
|
|
{
|
|
try {
|
|
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
|
|
BF.AssetBundleObject gen_to_be_invoked = (BF.AssetBundleObject)translator.FastGetCSObj(L, 1);
|
|
|
|
|
|
|
|
{
|
|
System.Action<BF.AssetBundleObject> _callback = translator.GetDelegate<System.Action<BF.AssetBundleObject>>(L, 2);
|
|
|
|
gen_to_be_invoked.LoadBundleAsync( _callback );
|
|
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _m_StartLoadAsync(RealStatePtr L)
|
|
{
|
|
try {
|
|
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
|
|
BF.AssetBundleObject gen_to_be_invoked = (BF.AssetBundleObject)translator.FastGetCSObj(L, 1);
|
|
|
|
|
|
|
|
{
|
|
|
|
gen_to_be_invoked.StartLoadAsync( );
|
|
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _m_LoadSync(RealStatePtr L)
|
|
{
|
|
try {
|
|
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
|
|
BF.AssetBundleObject gen_to_be_invoked = (BF.AssetBundleObject)translator.FastGetCSObj(L, 1);
|
|
|
|
|
|
int gen_param_count = LuaAPI.lua_gettop(L);
|
|
|
|
if(gen_param_count == 2&& LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 2))
|
|
{
|
|
bool _ignoreRefCount = LuaAPI.lua_toboolean(L, 2);
|
|
|
|
gen_to_be_invoked.LoadSync( _ignoreRefCount );
|
|
|
|
|
|
|
|
return 0;
|
|
}
|
|
if(gen_param_count == 1)
|
|
{
|
|
|
|
gen_to_be_invoked.LoadSync( );
|
|
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
|
|
return LuaAPI.luaL_error(L, "invalid arguments to BF.AssetBundleObject.LoadSync!");
|
|
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _m_Tick(RealStatePtr L)
|
|
{
|
|
try {
|
|
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
|
|
BF.AssetBundleObject gen_to_be_invoked = (BF.AssetBundleObject)translator.FastGetCSObj(L, 1);
|
|
|
|
|
|
|
|
{
|
|
|
|
var gen_ret = gen_to_be_invoked.Tick( );
|
|
LuaAPI.lua_pushboolean(L, gen_ret);
|
|
|
|
|
|
|
|
return 1;
|
|
}
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _m_Complete(RealStatePtr L)
|
|
{
|
|
try {
|
|
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
|
|
BF.AssetBundleObject gen_to_be_invoked = (BF.AssetBundleObject)translator.FastGetCSObj(L, 1);
|
|
|
|
|
|
|
|
{
|
|
UnityEngine.AssetBundle _ab = (UnityEngine.AssetBundle)translator.GetObject(L, 2, typeof(UnityEngine.AssetBundle));
|
|
|
|
gen_to_be_invoked.Complete( _ab );
|
|
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _m_AddUnloadCallback(RealStatePtr L)
|
|
{
|
|
try {
|
|
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
|
|
BF.AssetBundleObject gen_to_be_invoked = (BF.AssetBundleObject)translator.FastGetCSObj(L, 1);
|
|
|
|
|
|
|
|
{
|
|
System.Action _unloadCallback = translator.GetDelegate<System.Action>(L, 2);
|
|
|
|
gen_to_be_invoked.AddUnloadCallback( _unloadCallback );
|
|
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _m_Unload(RealStatePtr L)
|
|
{
|
|
try {
|
|
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
|
|
BF.AssetBundleObject gen_to_be_invoked = (BF.AssetBundleObject)translator.FastGetCSObj(L, 1);
|
|
|
|
|
|
|
|
{
|
|
bool _immediately = LuaAPI.lua_toboolean(L, 2);
|
|
|
|
var gen_ret = gen_to_be_invoked.Unload( _immediately );
|
|
LuaAPI.lua_pushboolean(L, gen_ret);
|
|
|
|
|
|
|
|
return 1;
|
|
}
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _g_get_AssetBundleConfig(RealStatePtr L)
|
|
{
|
|
try {
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
BF.AssetBundleObject gen_to_be_invoked = (BF.AssetBundleObject)translator.FastGetCSObj(L, 1);
|
|
translator.Push(L, gen_to_be_invoked.AssetBundleConfig);
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _g_get_Assetbundle(RealStatePtr L)
|
|
{
|
|
try {
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
BF.AssetBundleObject gen_to_be_invoked = (BF.AssetBundleObject)translator.FastGetCSObj(L, 1);
|
|
translator.Push(L, gen_to_be_invoked.Assetbundle);
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _g_get_Timeout(RealStatePtr L)
|
|
{
|
|
try {
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
BF.AssetBundleObject gen_to_be_invoked = (BF.AssetBundleObject)translator.FastGetCSObj(L, 1);
|
|
LuaAPI.lua_pushnumber(L, gen_to_be_invoked.Timeout);
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _g_get_fullpathDict(RealStatePtr L)
|
|
{
|
|
try {
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
translator.Push(L, BF.AssetBundleObject.fullpathDict);
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _s_set_fullpathDict(RealStatePtr L)
|
|
{
|
|
try {
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
BF.AssetBundleObject.fullpathDict = (System.Collections.Generic.Dictionary<string, string>)translator.GetObject(L, 1, typeof(System.Collections.Generic.Dictionary<string, string>));
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|