static int __CreateInstance(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); if (LuaAPI.lua_gettop(L) == 1) { EventDelegate __cl_gen_ret = new EventDelegate(); translator.Push(L, __cl_gen_ret); return(1); } if (LuaAPI.lua_gettop(L) == 2 && translator.Assignable <EventDelegate.Callback>(L, 2)) { EventDelegate.Callback call = translator.GetDelegate <EventDelegate.Callback>(L, 2); EventDelegate __cl_gen_ret = new EventDelegate(call); translator.Push(L, __cl_gen_ret); return(1); } if (LuaAPI.lua_gettop(L) == 3 && translator.Assignable <UnityEngine.MonoBehaviour>(L, 2) && (LuaAPI.lua_isnil(L, 3) || LuaAPI.lua_type(L, 3) == LuaTypes.LUA_TSTRING)) { UnityEngine.MonoBehaviour target = (UnityEngine.MonoBehaviour)translator.GetObject(L, 2, typeof(UnityEngine.MonoBehaviour)); string methodName = LuaAPI.lua_tostring(L, 3); EventDelegate __cl_gen_ret = new EventDelegate(target, methodName); translator.Push(L, __cl_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 EventDelegate constructor!")); }
static int _m_AddMonoEnableOption(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); SkillBaseComponent __cl_gen_to_be_invoked = (SkillBaseComponent)translator.FastGetCSObj(L, 1); try { { UnityEngine.MonoBehaviour kTarget = (UnityEngine.MonoBehaviour)translator.GetObject(L, 2, typeof(UnityEngine.MonoBehaviour)); bool bEnable = LuaAPI.lua_toboolean(L, 3); float fDelayTime = (float)LuaAPI.lua_tonumber(L, 4); __cl_gen_to_be_invoked.AddMonoEnableOption(kTarget, bEnable, fDelayTime); return(0); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } }
static int _m_InvokeRepeating(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.MonoBehaviour __cl_gen_to_be_invoked = (UnityEngine.MonoBehaviour)translator.FastGetCSObj(L, 1); try { { string methodName = LuaAPI.lua_tostring(L, 2); float time = (float)LuaAPI.lua_tonumber(L, 3); float repeatRate = (float)LuaAPI.lua_tonumber(L, 4); __cl_gen_to_be_invoked.InvokeRepeating(methodName, time, repeatRate); return(0); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } }
static StackObject *InvokeRepeating_3(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 4); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Single @repeatRate = *(float *)&ptr_of_this_method->Value; ptr_of_this_method = ILIntepreter.Minus(__esp, 2); System.Single @time = *(float *)&ptr_of_this_method->Value; ptr_of_this_method = ILIntepreter.Minus(__esp, 3); System.String @methodName = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 4); UnityEngine.MonoBehaviour instance_of_this_method = (UnityEngine.MonoBehaviour) typeof(UnityEngine.MonoBehaviour).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); instance_of_this_method.InvokeRepeating(@methodName, @time, @repeatRate); return(__ret); }
static int _m_CancelInvoke(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.MonoBehaviour gen_to_be_invoked = (UnityEngine.MonoBehaviour)translator.FastGetCSObj(L, 1); int gen_param_count = LuaAPI.lua_gettop(L); if (gen_param_count == 1) { gen_to_be_invoked.CancelInvoke( ); return(0); } if (gen_param_count == 2 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING)) { string _methodName = LuaAPI.lua_tostring(L, 2); gen_to_be_invoked.CancelInvoke( _methodName); return(0); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.MonoBehaviour.CancelInvoke!")); }
static int _m_Invoke(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.MonoBehaviour gen_to_be_invoked = (UnityEngine.MonoBehaviour)translator.FastGetCSObj(L, 1); { string _methodName = LuaAPI.lua_tostring(L, 2); float _time = (float)LuaAPI.lua_tonumber(L, 3); gen_to_be_invoked.Invoke(_methodName, _time); return(0); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
static int _m_DelayCall(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.MonoBehaviour gen_to_be_invoked = (UnityEngine.MonoBehaviour)translator.FastGetCSObj(L, 1); { System.Action _action = translator.GetDelegate <System.Action>(L, 2); float _time = (float)LuaAPI.lua_tonumber(L, 3); gen_to_be_invoked.DelayCall(_action, _time); return(0); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
public IEnumerator CoroutineCompute(CQ_Content content, UnityEngine.MonoBehaviour coroutine) { #if CQUARK_DEBUG content.InStack(this); #endif if (__expressions != null && __expressions.Count > 0) { if (__expressions[0].hasCoroutine) { yield return(coroutine.StartCoroutine(CoroutineCompute(content, coroutine))); } else { CQ_Value v = __expressions[0].ComputeValue(content); //object val = v.GetValue(); //if((Type)value_type == typeof(Type_Var.var)) { // if(!v.TypeIsEmpty) // value_type = v.typeBridge; //} //else if(v.typeBridge != value_type) { // val = v.ConvertTo(value_type); //} content.DefineAndSet(value_name, value_type, v); } } else { content.Define(value_name, value_type); } #if CQUARK_DEBUG content.OutStack(this); #endif }
static int _m_Set(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); EventDelegate __cl_gen_to_be_invoked = (EventDelegate)translator.FastGetCSObj(L, 1); { UnityEngine.MonoBehaviour target = (UnityEngine.MonoBehaviour)translator.GetObject(L, 2, typeof(UnityEngine.MonoBehaviour)); string methodName = LuaAPI.lua_tostring(L, 3); __cl_gen_to_be_invoked.Set(target, methodName); return(0); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } }
static int _m_Register_xlua_st_(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); int gen_param_count = LuaAPI.lua_gettop(L); if (gen_param_count == 6 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 1) && translator.Assignable <System.Action>(L, 2) && translator.Assignable <System.Action <float> >(L, 3) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 4) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 5) && translator.Assignable <UnityEngine.MonoBehaviour>(L, 6)) { float _duration = (float)LuaAPI.lua_tonumber(L, 1); System.Action _onComplete = translator.GetDelegate <System.Action>(L, 2); System.Action <float> _onUpdate = translator.GetDelegate <System.Action <float> >(L, 3); bool _isLooped = LuaAPI.lua_toboolean(L, 4); bool _useRealTime = LuaAPI.lua_toboolean(L, 5); UnityEngine.MonoBehaviour _autoDestroyOwner = (UnityEngine.MonoBehaviour)translator.GetObject(L, 6, typeof(UnityEngine.MonoBehaviour)); UnityMMO.Timer gen_ret = UnityMMO.Timer.Register(_duration, _onComplete, _onUpdate, _isLooped, _useRealTime, _autoDestroyOwner); translator.Push(L, gen_ret); return(1); } if (gen_param_count == 5 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 1) && translator.Assignable <System.Action>(L, 2) && translator.Assignable <System.Action <float> >(L, 3) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 4) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 5)) { float _duration = (float)LuaAPI.lua_tonumber(L, 1); System.Action _onComplete = translator.GetDelegate <System.Action>(L, 2); System.Action <float> _onUpdate = translator.GetDelegate <System.Action <float> >(L, 3); bool _isLooped = LuaAPI.lua_toboolean(L, 4); bool _useRealTime = LuaAPI.lua_toboolean(L, 5); UnityMMO.Timer gen_ret = UnityMMO.Timer.Register(_duration, _onComplete, _onUpdate, _isLooped, _useRealTime); translator.Push(L, gen_ret); return(1); } if (gen_param_count == 4 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 1) && translator.Assignable <System.Action>(L, 2) && translator.Assignable <System.Action <float> >(L, 3) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 4)) { float _duration = (float)LuaAPI.lua_tonumber(L, 1); System.Action _onComplete = translator.GetDelegate <System.Action>(L, 2); System.Action <float> _onUpdate = translator.GetDelegate <System.Action <float> >(L, 3); bool _isLooped = LuaAPI.lua_toboolean(L, 4); UnityMMO.Timer gen_ret = UnityMMO.Timer.Register(_duration, _onComplete, _onUpdate, _isLooped); translator.Push(L, gen_ret); return(1); } if (gen_param_count == 3 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 1) && translator.Assignable <System.Action>(L, 2) && translator.Assignable <System.Action <float> >(L, 3)) { float _duration = (float)LuaAPI.lua_tonumber(L, 1); System.Action _onComplete = translator.GetDelegate <System.Action>(L, 2); System.Action <float> _onUpdate = translator.GetDelegate <System.Action <float> >(L, 3); UnityMMO.Timer gen_ret = UnityMMO.Timer.Register(_duration, _onComplete, _onUpdate); translator.Push(L, gen_ret); return(1); } if (gen_param_count == 2 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 1) && translator.Assignable <System.Action>(L, 2)) { float _duration = (float)LuaAPI.lua_tonumber(L, 1); System.Action _onComplete = translator.GetDelegate <System.Action>(L, 2); UnityMMO.Timer gen_ret = UnityMMO.Timer.Register(_duration, _onComplete); 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 UnityMMO.Timer.Register!")); }
/** MonoBehaviour。設定。 */ public static void SetMonoBehaviour(UnityEngine.MonoBehaviour a_monobehaviour) { s_monobehaviour = a_monobehaviour; }
public static void Register() { if (doNotModify) { return; } object o = null; { UnityEngine.MonoBehaviour v = (UnityEngine.MonoBehaviour)o; v = new UnityEngine.MonoBehaviour(); var p1 = v.tag; v.tag = (System.String)o; var p2 = v.name; v.name = (System.String)o; v.IsInvoking(); v.CancelInvoke(); v.Invoke((System.String)o, (System.Single)o); v.InvokeRepeating((System.String)o, (System.Single)o, (System.Single)o); v.CancelInvoke((System.String)o); v.IsInvoking((System.String)o); v.StartCoroutine((System.String)o); v.StartCoroutine((System.String)o, (System.Object)o); v.StartCoroutine((System.Collections.IEnumerator)o); v.StopCoroutine((System.Collections.IEnumerator)o); v.StopCoroutine((UnityEngine.Coroutine)o); UnityEngine.MonoBehaviour.print((System.Object)o); v.GetComponent((System.Type)o); UnityEngine.Component p3 = (UnityEngine.Component)o; v.TryGetComponent((System.Type)o, out p3); v.GetComponentInChildren((System.Type)o, (System.Boolean)o); v.GetComponentInChildren((System.Type)o); v.GetComponentsInChildren((System.Type)o, (System.Boolean)o); v.GetComponentsInChildren((System.Type)o); v.GetComponentInParent((System.Type)o); v.GetComponentsInParent((System.Type)o, (System.Boolean)o); v.GetComponentsInParent((System.Type)o); v.GetComponents((System.Type)o); v.GetComponents((System.Type)o, (System.Collections.Generic.List <UnityEngine.Component>)o); v.CompareTag((System.String)o); v.SendMessageUpwards((System.String)o, (System.Object)o); v.SendMessageUpwards((System.String)o); v.SendMessageUpwards((System.String)o, (UnityEngine.SendMessageOptions)o); v.SendMessage((System.String)o, (System.Object)o); v.SendMessage((System.String)o); v.SendMessage((System.String)o, (UnityEngine.SendMessageOptions)o); v.BroadcastMessage((System.String)o, (System.Object)o); v.BroadcastMessage((System.String)o); v.BroadcastMessage((System.String)o, (UnityEngine.SendMessageOptions)o); v.GetInstanceID(); v.GetHashCode(); v.Equals((System.Object)o); v.ToString(); } { UnityEngine.Transform v = (UnityEngine.Transform)o; var p4 = v.position; v.position = (UnityEngine.Vector3)o; var p5 = v.localPosition; v.localPosition = (UnityEngine.Vector3)o; var p6 = v.eulerAngles; v.eulerAngles = (UnityEngine.Vector3)o; var p7 = v.localEulerAngles; v.localEulerAngles = (UnityEngine.Vector3)o; var p8 = v.right; v.right = (UnityEngine.Vector3)o; var p9 = v.up; v.up = (UnityEngine.Vector3)o; var pA = v.forward; v.forward = (UnityEngine.Vector3)o; var pB = v.rotation; v.rotation = (UnityEngine.Quaternion)o; var pC = v.localRotation; v.localRotation = (UnityEngine.Quaternion)o; var pD = v.localScale; v.localScale = (UnityEngine.Vector3)o; var pE = v.parent; v.parent = (UnityEngine.Transform)o; var pF = v.worldToLocalMatrix; var p10 = v.localToWorldMatrix; var p11 = v.root; var p12 = v.lossyScale; var p13 = v.hierarchyCapacity; v.hierarchyCapacity = (System.Int32)o; var p14 = v.hierarchyCount; var p15 = v.tag; v.tag = (System.String)o; var p16 = v.name; v.name = (System.String)o; v.SetParent((UnityEngine.Transform)o); v.SetPositionAndRotation((UnityEngine.Vector3)o, (UnityEngine.Quaternion)o); v.Translate((UnityEngine.Vector3)o, (UnityEngine.Space)o); v.Translate((UnityEngine.Vector3)o); v.Translate((System.Single)o, (System.Single)o, (System.Single)o, (UnityEngine.Space)o); v.Translate((System.Single)o, (System.Single)o, (System.Single)o); v.Translate((UnityEngine.Vector3)o, (UnityEngine.Transform)o); v.Translate((System.Single)o, (System.Single)o, (System.Single)o, (UnityEngine.Transform)o); v.Rotate((UnityEngine.Vector3)o, (UnityEngine.Space)o); v.Rotate((UnityEngine.Vector3)o); v.Rotate((System.Single)o, (System.Single)o, (System.Single)o, (UnityEngine.Space)o); v.Rotate((System.Single)o, (System.Single)o, (System.Single)o); v.Rotate((UnityEngine.Vector3)o, (System.Single)o, (UnityEngine.Space)o); v.Rotate((UnityEngine.Vector3)o, (System.Single)o); v.RotateAround((UnityEngine.Vector3)o, (UnityEngine.Vector3)o, (System.Single)o); v.LookAt((UnityEngine.Transform)o, (UnityEngine.Vector3)o); v.LookAt((UnityEngine.Transform)o); v.LookAt((UnityEngine.Vector3)o, (UnityEngine.Vector3)o); v.LookAt((UnityEngine.Vector3)o); v.TransformDirection((UnityEngine.Vector3)o); v.TransformDirection((System.Single)o, (System.Single)o, (System.Single)o); v.InverseTransformDirection((UnityEngine.Vector3)o); v.InverseTransformDirection((System.Single)o, (System.Single)o, (System.Single)o); v.TransformVector((UnityEngine.Vector3)o); v.TransformVector((System.Single)o, (System.Single)o, (System.Single)o); v.InverseTransformVector((UnityEngine.Vector3)o); v.InverseTransformVector((System.Single)o, (System.Single)o, (System.Single)o); v.TransformPoint((UnityEngine.Vector3)o); v.TransformPoint((System.Single)o, (System.Single)o, (System.Single)o); v.InverseTransformPoint((UnityEngine.Vector3)o); v.InverseTransformPoint((System.Single)o, (System.Single)o, (System.Single)o); v.Find((System.String)o); v.GetEnumerator(); v.GetComponent((System.Type)o); UnityEngine.Component p17 = (UnityEngine.Component)o; v.TryGetComponent((System.Type)o, out p17); v.GetComponentInChildren((System.Type)o, (System.Boolean)o); v.GetComponentInChildren((System.Type)o); v.GetComponentsInChildren((System.Type)o, (System.Boolean)o); v.GetComponentsInChildren((System.Type)o); v.GetComponentInParent((System.Type)o); v.GetComponentsInParent((System.Type)o, (System.Boolean)o); v.GetComponentsInParent((System.Type)o); v.GetComponents((System.Type)o); v.GetComponents((System.Type)o, (System.Collections.Generic.List <UnityEngine.Component>)o); v.CompareTag((System.String)o); v.SendMessageUpwards((System.String)o, (System.Object)o); v.SendMessageUpwards((System.String)o); v.SendMessageUpwards((System.String)o, (UnityEngine.SendMessageOptions)o); v.SendMessage((System.String)o, (System.Object)o); v.SendMessage((System.String)o); v.SendMessage((System.String)o, (UnityEngine.SendMessageOptions)o); v.BroadcastMessage((System.String)o, (System.Object)o); v.BroadcastMessage((System.String)o); v.BroadcastMessage((System.String)o, (UnityEngine.SendMessageOptions)o); v.GetInstanceID(); v.GetHashCode(); v.Equals((System.Object)o); v.ToString(); } }
public IEnumerator CoroutineCompute(CQ_Content content, UnityEngine.MonoBehaviour coroutine) { #if CQUARK_DEBUG content.InStack(this); #endif ICQ_Expression expr_if = _expressions[0]; bool bif = expr_if.ComputeValue(content).GetBool(); //if (expr_init != null) expr_init.ComputeValue(content); ICQ_Expression expr_go1 = _expressions[1]; ICQ_Expression expr_go2 = null; if (_expressions.Count > 2) { expr_go2 = _expressions[2]; } // CQ_Content.Value value = null; if (bif && expr_go1 != null) { if (expr_go1 is CQ_Expression_Block) { if (expr_go1.hasCoroutine) { yield return(coroutine.StartCoroutine(expr_go1.CoroutineCompute(content, coroutine))); } else { expr_go1.ComputeValue(content); } } else { content.DepthAdd(); if (expr_go1.hasCoroutine) { yield return(coroutine.StartCoroutine(expr_go1.CoroutineCompute(content, coroutine))); } else { expr_go1.ComputeValue(content); } content.DepthRemove(); } } else if (!bif && expr_go2 != null) { if (expr_go2 is CQ_Expression_Block) { if (expr_go2.hasCoroutine) { yield return(coroutine.StartCoroutine(expr_go2.CoroutineCompute(content, coroutine))); } else { expr_go2.ComputeValue(content); } } else { content.DepthAdd(); if (expr_go2.hasCoroutine) { yield return(coroutine.StartCoroutine(expr_go2.CoroutineCompute(content, coroutine))); } else { expr_go2.ComputeValue(content); } content.DepthRemove(); } } #if CQUARK_DEBUG content.OutStack(this); #endif }
public static Dictionary <K, V> TestCommonToObject <K, V>(Stream stream, bool isLoadAll = false, UnityEngine.MonoBehaviour loadAllCortine = null, int maxAsyncReadCnt = 500) where V : class { if (stream == null) { return(null); } ConfigFileHeader header = new ConfigFileHeader(); if (!header.LoadFromStream(stream) || !header.IsVaild) { return(null); } // 读取索引 stream.Seek(header.indexOffset, SeekOrigin.Begin); // 读取类型(之前已经获取到了) ConfigValueType valueType = (ConfigValueType)stream.ReadByte(); Dictionary <K, V> maps = null; switch (valueType) { case ConfigValueType.cvObject: { for (uint i = 0; i < header.Count; ++i) { ConfigBase <K> config = Activator.CreateInstance <V>() as ConfigBase <K>; config.stream = stream; K key = config.ReadKey(); config.dataOffset = FilePathMgr.Instance.ReadLong(stream); if (maps == null) { maps = new Dictionary <K, V>((int)header.Count); } maps[key] = config as V; } break; } case ConfigValueType.cvList: { System.Type t = typeof(V); // 这里有数组分配,不要频繁使用TestCommonToObject var interfaces = t.GetInterfaces(); if (interfaces == null || interfaces.Length <= 0) { return(null); } var inter = interfaces[0]; if (inter == null) { return(null); } for (uint i = 0; i < header.Count; ++i) { ConfigBase <K> config = Activator.CreateInstance(inter) as ConfigBase <K>; config.stream = stream; K key = config.ReadKey(); long dataOffset = FilePathMgr.Instance.ReadLong(stream); config.dataOffset = dataOffset; int listCnt = FilePathMgr.Instance.ReadInt(stream); if (maps == null) { maps = new Dictionary <K, V>((int)header.Count); } V vs = Activator.CreateInstance <V>(); maps[key] = vs; IList list = vs as IList; list.Add(config); for (int j = 1; j < listCnt; ++j) { config = Activator.CreateInstance(inter) as ConfigBase <K>; config.stream = stream; config.dataOffset = dataOffset; list.Add(config); } } break; } default: return(null); } if (isLoadAll && maps != null && maps.Count > 0) { StartLoadAllCortine(maps, loadAllCortine, valueType, null, maxAsyncReadCnt); } return(maps); }
private static UnityEngine.Coroutine StartLoadAllCortine(IDictionary maps, UnityEngine.MonoBehaviour parent, ConfigValueType valueType, Action <float> onProcess, int maxAsyncReadCnt) { if (maps == null || maps.Count <= 0) { return(null); } if (parent != null) { return(parent.StartCoroutine(StartLoadCortine(maps, valueType, onProcess, maxAsyncReadCnt))); } else { if (valueType == ConfigValueType.cvObject) { var iter = maps.GetEnumerator(); while (iter.MoveNext()) { IConfigBase config = iter.Value as IConfigBase; Stream stream = config.stream; if (stream == null) { continue; } stream.Seek(config.dataOffset, SeekOrigin.Begin); config.ReadValue(); } iter.DisposeIter(); } else if (valueType == ConfigValueType.cvList) { var iter = maps.GetEnumerator(); while (iter.MoveNext()) { IList vs = iter.Value as IList; IConfigBase v = vs[0] as IConfigBase; Stream stream = v.stream; if (stream == null) { continue; } stream.Seek(v.dataOffset, SeekOrigin.Begin); for (int i = 0; i < vs.Count; ++i) { v = vs[i] as IConfigBase; v.ReadValue(); } } iter.DisposeIter(); } else if (valueType == ConfigValueType.cvMap) { // 字典类型 var iter = maps.GetEnumerator(); while (iter.MoveNext()) { IDictionary map = iter.Value as IDictionary; var subIter = map.GetEnumerator(); if (subIter.MoveNext()) { IConfigBase v = subIter.Value as IConfigBase; if (!v.StreamSeek()) { continue; } v.ReadValue(); while (subIter.MoveNext()) { v = subIter.Value as IConfigBase; v.ReadValue(); } } subIter.DisposeIter(); } iter.DisposeIter(); } } return(null); }
public IEnumerator CoroutineCompute(CQ_Content content, UnityEngine.MonoBehaviour coroutine) { #if CQUARK_DEBUG content.InStack(this); #endif content.DepthAdd(); CQ_Expression_Define define = _expressions[0] as CQ_Expression_Define; define.ComputeValue(content); System.Collections.IEnumerable emu = _expressions[1].ComputeValue(content).GetObject() as System.Collections.IEnumerable; ICQ_Expression expr_block = _expressions[2] as ICQ_Expression; var it = emu.GetEnumerator(); while (it.MoveNext()) { //content.Set(define.value_name, it.Current); CQ_Value val = new CQ_Value(); val.SetObject(define.value_type, it.Current); content.Set(define.value_name, val); if (expr_block != null) { if (expr_block is CQ_Expression_Block) { if (expr_block.hasCoroutine) { yield return(coroutine.StartCoroutine(expr_block.CoroutineCompute(content, coroutine))); } else { CQ_Value v = expr_block.ComputeValue(content); if (v.m_breakBlock == BreakType.Break || v.m_breakBlock == BreakType.Return) { break; } } } else { content.DepthAdd(); bool bbreak = false; if (expr_block.hasCoroutine) { yield return(coroutine.StartCoroutine(expr_block.CoroutineCompute(content, coroutine))); } else { CQ_Value v = expr_block.ComputeValue(content); if (v.m_breakBlock == BreakType.Return || v.m_breakBlock == BreakType.Break) { bbreak = true; } } content.DepthRemove(); if (bbreak) { break; } } } } content.DepthRemove(); #if CQUARK_DEBUG content.OutStack(this); #endif }
// 转换成字典类型 public static Dictionary <K1, Dictionary <K2, V> > ToObjectMap <K1, K2, V>(Stream stream, bool isLoadAll = false, UnityEngine.MonoBehaviour loadAllCortine = null, Action <float> onProcess = null, int maxAsyncReadCnt = 500) where V : ConfigBase <K2> { if (stream == null) { return(null); } ConfigFileHeader header = new ConfigFileHeader(); if (!header.LoadFromStream(stream) || !header.IsVaild) { return(null); } // 读取索引 stream.Seek(header.indexOffset, SeekOrigin.Begin); ConfigValueType valueType = (ConfigValueType)stream.ReadByte(); if (valueType != ConfigValueType.cvMap) { return(null); } Dictionary <K1, Dictionary <K2, V> > maps = null; System.Type keyType1 = typeof(K1); // System.Type keyType2 = typeof(K2); // System.Type subDictType = typeof(Dictionary<K2, V>); for (uint i = 0; i < header.Count; ++i) { System.Object key1 = FilePathMgr.Instance.ReadObject(stream, keyType1); long dataOffset = FilePathMgr.Instance.ReadLong(stream); int DictCnt = FilePathMgr.Instance.ReadInt(stream); if (DictCnt > 0) { if (maps == null) { maps = new Dictionary <K1, Dictionary <K2, V> >(); } Dictionary <K2, V> subMap = new Dictionary <K2, V>(); for (int j = 0; j < DictCnt; ++j) { V config = Activator.CreateInstance <V>(); config.stream = stream; config.dataOffset = dataOffset; K2 key2 = config.ReadKey(); subMap[(K2)key2] = config; } if (subMap != null && subMap.Count > 0) { maps[((K1)key1)] = subMap; } } } if (isLoadAll && maps != null && maps.Count > 0) { StartLoadAllCortine(maps, loadAllCortine, valueType, onProcess, maxAsyncReadCnt); } return(maps); }
public SyncTester(UnityEngine.MonoBehaviour mono) { m_mono = mono; }
public static IDictionary TestCommonToObject(Stream stream, System.Type configType, System.Type dictType, bool isLoadAll = false, UnityEngine.MonoBehaviour loadAllCortine = null, int maxAsyncReadCnt = 500) { if (stream == null || configType == null || dictType == null) { return(null); } ConfigFileHeader header = new ConfigFileHeader(); if (!header.LoadFromStream(stream) || !header.IsVaild) { return(null); } // 读取索引 stream.Seek(header.indexOffset, SeekOrigin.Begin); // 读取类型(之前已经获取到了) ConfigValueType valueType = (ConfigValueType)stream.ReadByte(); IDictionary maps = null; switch (valueType) { case ConfigValueType.cvObject: { for (uint i = 0; i < header.Count; ++i) { IConfigBase config = Activator.CreateInstance(configType) as IConfigBase; config.stream = stream; System.Object key = config.ReadKEY(); config.dataOffset = FilePathMgr.Instance.ReadLong(stream); if (maps == null) { maps = Activator.CreateInstance(dictType) as IDictionary; } maps[key] = config; } break; } case ConfigValueType.cvList: { var vsType = typeof(List <>).MakeGenericType(configType); for (uint i = 0; i < header.Count; ++i) { IConfigBase config = Activator.CreateInstance(configType) as IConfigBase; config.stream = stream; System.Object key = config.ReadKEY(); long dataOffset = FilePathMgr.Instance.ReadLong(stream); config.dataOffset = dataOffset; int listCnt = FilePathMgr.Instance.ReadInt(stream); if (maps == null) { maps = Activator.CreateInstance(dictType) as IDictionary; } IList list = Activator.CreateInstance(vsType) as IList; maps[key] = list; list.Add(config); for (int j = 1; j < listCnt; ++j) { config = Activator.CreateInstance(configType) as IConfigBase; config.stream = stream; config.dataOffset = dataOffset; list.Add(config); } } break; } // 有问题 case ConfigValueType.cvMap: { Type[] vTypes = dictType.GetInterfaces(); if (vTypes == null || vTypes.Length < 2) { return(null); } Type k1 = vTypes[0]; if (k1 == null) { return(null); } Type vType = vTypes[1]; if (vType == null) { return(null); } if (!vType.IsSubclassOf(typeof(IDictionary))) { return(null); } Type[] subTypes = vType.GetInterfaces(); if (subTypes == null || subTypes.Length < 2) { return(null); } Type k2 = subTypes[0]; Type v = subTypes[1]; if (k2 == null || v == null) { return(null); } var subDictType = typeof(Dictionary <System.Object, System.Object>).MakeGenericType(k2, v); if (subDictType == null) { return(null); } for (uint i = 0; i < header.Count; ++i) { } break; } default: return(null); } if (isLoadAll && maps != null && maps.Count > 0) { StartLoadAllCortine(maps, loadAllCortine, valueType, null, maxAsyncReadCnt); } return(maps); }
public CQ_Value ComputeValue(CQ_Content content) { #if CQUARK_DEBUG content.InStack(this); #endif CQ_Value parent = _expressions[0].ComputeValue(content); #if CQUARK_DEBUG if (parent == CQ_Value.Null) { throw new Exception("调用空对象的方法:" + _expressions[0].ToString() + ":" + ToString()); } #endif CQ_Value[] parameters = CQ_ObjPool.PopArray(_expressions.Count - 1); for (int i = 0; i < _expressions.Count - 1; i++) { parameters[i] = _expressions[i + 1].ComputeValue(content); } CQ_Value value = CQ_Value.Null; //这几行是为了快速获取Unity的静态变量,而不需要反射 object obj = parent.GetObject(); if (!Wrap.MemberCall(parent.m_type, obj, functionName, parameters, out value)) { //TODO 要么注册所有基本类型(bool,int,string...)要么这里特殊处理 if (functionName == "ToString" && parameters.Length == 0) { CQ_Value ret = new CQ_Value(); ret.SetObject(typeof(string), obj.ToString()); return(ret); } else if (obj is UnityEngine.MonoBehaviour && functionName == "StartCoroutine" && parameters.Length >= 1 && parameters[0].GetObject() is CQ_Expression_Block) { //从西瓜调用的ClassSystem.StartCoroutine(CquarkMethod());不需要走cache UnityEngine.MonoBehaviour mb = obj as UnityEngine.MonoBehaviour; CQ_Expression_Block call = parameters[0].GetObject() as CQ_Expression_Block; CQ_Value ret = new CQ_Value(); ret.SetObject(typeof(UnityEngine.Coroutine), mb.StartCoroutine(call.callObj.CallType.CoroutineCall(call, call.callObj, mb))); return(ret); } else { var iclass = CQuark.AppDomain.GetITypeByCQValue(parent)._class; if (cache == null || cache.cachefail) { cache = new MethodCache(); value = iclass.MemberCall(content, obj, functionName, parameters, cache); } else { value = iclass.MemberCallCache(content, obj, parameters, cache); } } } #if CQUARK_DEBUG content.OutStack(this); #endif CQ_ObjPool.PushArray(parameters); return(value); }
public static UnityEngine.Coroutine ToObjectMapAsync <K1, K2, V>(Stream stream, Dictionary <K1, Dictionary <K2, V> > maps, UnityEngine.MonoBehaviour mono, bool isLoadAll = false, Action <IDictionary> onOK = null, Action <float> onProcess = null, int maxAsyncReadCnt = 500) where V : ConfigBase <K2> { if (stream == null || maps == null || mono == null) { return(null); } return(mono.StartCoroutine(_ToObjectMapAsync <K1, K2, V>(stream, maps, isLoadAll, onOK, onProcess, maxAsyncReadCnt))); }
public virtual IEnumerator CoroutineCall(CQ_Content contentParent, object object_this, string func, CQ_Value[] _params, UnityEngine.MonoBehaviour coroutine) { Function funccache = null; if (this.functions.TryGetValue(func, out funccache)) { if (!funccache.bStatic) { CQ_Content content = CQ_ObjPool.PopContent(); content.CallType = this; content.CallThis = object_this as CQ_ClassInstance; #if CQUARK_DEBUG content.function = func; contentParent.InStack(content);//把这个上下文推给上层的上下文,这样如果崩溃是可以一层层找到原因的 #endif for (int i = 0; i < funccache._paramtypes.Count; i++) { content.DefineAndSet(funccache._paramnames[i], _params[i].typeBridge, _params[i]); } var funcobj = funccache; if (this.bInterface) { content.CallType = (object_this as CQ_ClassInstance).type; funcobj = (object_this as CQ_ClassInstance).type.functions[func]; } if (funcobj.expr_runtime != null) { yield return(coroutine.StartCoroutine(funcobj.expr_runtime.CoroutineCompute(content, coroutine))); } #if CQUARK_DEBUG contentParent.OutStack(content); #endif CQ_ObjPool.PushContent(content); } } else { yield return(MemberCall(contentParent, object_this, func, _params, null)); } }
public IEnumerator CoroutineCompute(CQ_Content content, UnityEngine.MonoBehaviour coroutine) { throw new Exception("StaticSet不支持套用协程"); }
public virtual IEnumerator CoroutineCall(ICQ_Expression expression, CQ_Content param, UnityEngine.MonoBehaviour coroutine) { yield return(coroutine.StartCoroutine(expression.CoroutineCompute(param, coroutine))); }
public static SwitchScript GetSwitch(this UnityEngine.MonoBehaviour mono) { return(mono.GetComponent <SwitchScript>()); }
public static void Inject(this UnityEngine.MonoBehaviour target) { InjectObject(target); }
public IEnumerator CoroutineCompute(CQ_Content content, UnityEngine.MonoBehaviour coroutine) { //可能以后需要支持。。。 throw new Exception("a.Method暂时不支持协程"); }
public IEnumerator CoroutineCompute(CQ_Content content, UnityEngine.MonoBehaviour coroutine) { throw new Exception("new params[]不支持协程"); }
internal void Start() { Logger = base.Logger; instance = this; CharacterApi.RegisterExtraBehaviour <AccStateSyncController>(GUID); MoreAccessories_Support.LoadAssembly(); CoroutineSlotChangeDelay = Config.Bind("Maker", "Slot Change Delay", 1f, new ConfigDescription("", null, new ConfigurationManagerAttributes { IsAdvanced = true, Order = 2 })); CoroutineCounterMax = Config.Bind("Maker", "Maximun Coroutine Counter", 30f, new ConfigDescription("", null, new ConfigurationManagerAttributes { IsAdvanced = true, Order = 1 })); CharaMakerPreview = Config.Bind("Maker", "CharaMaker Force Preview", true, new ConfigDescription("", null, new ConfigurationManagerAttributes { Order = 10 })); CharaMakerPreview.SettingChanged += (sender, args) => { if (MakerAPI.InsideMaker) { CharaMakerPreviewSidebarToggle.Value = CharaMakerPreview.Value; if (CharaMakerPreviewSidebarToggle.Value) { GetController(MakerAPI.GetCharacterControl()).SyncAllAccToggle(); } } }; // MakerAPI.MakerBaseLoaded += MakerAPI_MakerBaseLoaded; MakerAPI.MakerFinishedLoading += (object sender, EventArgs e) => CreateMakerInterface(); AccessoriesApi.SelectedMakerAccSlotChanged += (object sender, AccessorySlotEventArgs eventArgs) => GetController(MakerAPI.GetCharacterControl()).AccSlotChangedHandler(eventArgs.SlotIndex); AccessoriesApi.AccessoryTransferred += (object sender, AccessoryTransferEventArgs eventArgs) => GetController(MakerAPI.GetCharacterControl()).AccessoryTransferredHandler(eventArgs.SourceSlotIndex, eventArgs.DestinationSlotIndex); AccessoriesApi.AccessoriesCopied += (object sender, AccessoryCopyEventArgs eventArgs) => GetController(MakerAPI.GetCharacterControl()).AccessoriesCopiedHandler((int)eventArgs.CopySource, (int)eventArgs.CopyDestination, eventArgs.CopiedSlotIndexes.ToList()); MakerAPI.RegisterCustomSubCategories += (sender, e) => { CharaMakerPreviewSidebarToggle = e.AddSidebarControl(new SidebarToggle("Force Preview", CharaMakerPreview.Value, this)); CharaMakerPreviewSidebarToggle.ValueChanged.Subscribe(b => CharaMakerPreview.Value = b); }; MakerAPI.MakerExiting += (sender, e) => { CharaMakerPreviewSidebarToggle = null; }; StudioAPI.StudioLoadedChanged += (sender, e) => RegisterStudioControls(); GameAPI.StartH += (sender, e) => { InsideHScene = true; UpdateHUI(); }; GameAPI.EndH += (sender, e) => { InsideHScene = false; HSprites.Clear(); }; HarmonyWrapper.PatchAll(typeof(Hooks)); if (UnityEngine.Application.dataPath.EndsWith("KoikatuVR_Data")) { HarmonyWrapper.PatchAll(typeof(HooksVR)); } foreach (var key in System.Enum.GetValues(typeof(ChaAccessoryDefine.AccessoryParentKey))) { AccParentNames[key.ToString()] = ChaAccessoryDefine.dictAccessoryParent[(int)key]; } }
public IEnumerator CoroutineCompute(CQ_Content content, UnityEngine.MonoBehaviour coroutine) { throw new Exception("协程无法包含在try中"); }