public static ScriptPkg CreateSharp(MethodInfo method, string methodname, object instance = null) { ScriptPkg pkg = null; if (KObjectPool.mIns != null) { pkg = KObjectPool.mIns.Pop <ScriptPkg>(); } if (pkg == null) { pkg = new ScriptPkg(); } pkg._script = new SharpScriptLoader(); SimpleParams InitParams = SimpleParams.Create(4); if (instance != null) { InitParams.WriteObject(instance); ParameterInfo[] passes = method.GetParameters(); if (passes != null && passes.Length == 1 && passes[0].ParameterType.IsSubclassOf(typeof(AbstractParams))) { throw new FrameWorkException("method mismatching "); } InitParams.WriteObject(method); } else { Type RetTp = method.ReturnType; if (RetTp == typeof(void)) { InitParams.WriteObject(Delegate.CreateDelegate(typeof(Action <AbstractParams>), method)); } else { InitParams.WriteObject(Delegate.CreateDelegate(typeof(Func <AbstractParams, AbstractParams>), method)); } InitParams.WriteObject(RetTp); InitParams.WriteString(methodname); } pkg.Loader.Init(InitParams); pkg.Name = method.DeclaringType.Name; return(pkg); }
public static ScriptPkg CreateLua(object attvalue) { ScriptPkg pkg = null; if (KObjectPool.mIns != null) { pkg = KObjectPool.mIns.Pop <ScriptPkg>(); } if (pkg == null) { pkg = new ScriptPkg(); } pkg._script = new LuaScriptLoader(); if (LuaClient.Instance != null) { SimpleParams InitParams = SimpleParams.Create(1); Script_LuaLogicAttribute luaAttribute = attvalue as Script_LuaLogicAttribute; InitParams.WriteObject(luaAttribute); pkg.Name = luaAttribute.luapath; pkg.Loader.Init(InitParams); } else { LogMgr.Log("场景中未包含LuaClient,但是程序集中包含了带有lua目标的函数的注册"); } return(pkg); }