private static void LoadProduct() { lock (Locker) { if (Product != null) { return; } Product = Load(); _loaded = true; if (Product == null) { return; } CombatProp = Product.GetType().GetProperty("CombatBehavior"); HealProp = Product.GetType().GetProperty("HealBehavior"); PullProp = Product.GetType().GetProperty("PullBehavior"); PreCombatProp = Product.GetType().GetProperty("PreCombatBuffBehavior"); PullBuffProp = Product.GetType().GetProperty("PullBuffBehavior"); CombatBuffProp = Product.GetType().GetProperty("CombatBuffBehavior"); RestProp = Product.GetType().GetProperty("RestBehavior"); PulseFunc = Product.GetType().GetMethod("Pulse"); InitFunc = Product.GetType().GetMethod("Initialize"); ShutdownFunc = Product.GetType().GetMethod("Shutdown"); ButtonFunc = Product.GetType().GetMethod("OnButtonPress"); if (InitFunc == null) { return; } InitFunc.Invoke(Product, null); } }
private static void LoadProduct() { lock (Locker) { if (Product != null) { return; } Product = Load(); _loaded = true; if (Product == null) { return; } PulseFunc = Product.GetType().GetMethod("OnPulse"); EnabledFunc = Product.GetType().GetMethod("OnEnabled"); DisabledFunc = Product.GetType().GetMethod("OnDisabled"); ShutDownFunc = Product.GetType().GetMethod("ShutDown"); ButtonFunc = Product.GetType().GetMethod("OnButtonPress"); InitFunc = Product.GetType().GetMethod("OnInitialize", new[] { typeof(int) }); if (InitFunc != null) { #if RB_CN Log($"{ProjectName} CN loaded."); InitFunc.Invoke(Product, new[] { (object)2 }); #else Log($"{ProjectName} 64 loaded."); InitFunc.Invoke(Product, new[] { (object)1 }); #endif } } }
private static void LoadProduct() { lock (locker) { if (Product != null) { return; } Product = Load(); loaded = true; if (Product == null) { return; } StartFunc = Product.GetType().GetMethod("Start"); StopFunc = Product.GetType().GetMethod("Stop"); ButtonFunc = Product.GetType().GetMethod("OnButtonPress"); RootFunc = Product.GetType().GetMethod("GetRoot"); InitFunc = Product.GetType().GetMethod("OnInitialize", new[] { typeof(int) }); if (InitFunc != null) { #if RB_CN Log($"{ProjectName}CN loaded."); InitFunc.Invoke(Product, new[] { (object)3 }); #elif RB_64 Log($"{ProjectName}64 loaded."); InitFunc.Invoke(Product, new[] { (object)2 }); #else Log($"{ProjectName}32 loaded."); InitFunc.Invoke(Product, new[] { (object)1 }); #endif } } }
public void Initialize(InitializationInput input) { if (InitFunc != null) { InitFunc.Invoke(input); } }
private static void LoadPlugin() { lock (ObjLock) { if (Plugin != null) { return; } Plugin = Load(); if (Plugin == null) { return; } StartFunc = Plugin.GetType().GetMethod("OnEnabled"); StopFunc = Plugin.GetType().GetMethod("OnDisabled"); ShutdownFunc = Plugin.GetType().GetMethod("OnShutdown"); ButtonFunc = Plugin.GetType().GetMethod("OnButtonPress"); InitFunc = Plugin.GetType().GetMethod("OnInitialize"); PulseFunc = Plugin.GetType().GetMethod("OnPulse"); if (InitFunc != null) { InitFunc.Invoke(Plugin, null); } } }
private static void LoadPlugin() { lock (ObjLock) { if (Plugin != null) { return; } Plugin = Load(); if (Plugin == null) { return; } StartFunc = Plugin.GetType().GetMethod("Start"); StopFunc = Plugin.GetType().GetMethod("Stop"); ButtonFunc = Plugin.GetType().GetMethod("OnButtonPress"); RootFunc = Plugin.GetType().GetMethod("get_Root"); InitFunc = Plugin.GetType().GetMethod("Initialize"); if (InitFunc != null) { InitFunc.Invoke(Plugin, null); } } }
public override void OnInitialize() { if (!_loaded && Product == null) { LoadProduct(); } if (Product != null) { InitFunc.Invoke(Product, null); } }
public override void Initialize() { if (Plugin == null) { LoadPlugin(); } if (Plugin != null) { InitFunc.Invoke(Plugin, null); } }
public Result Run(InitFunc initfunc, InitFunc postinitfunc, CyclicFunc cyclicfunc, QuitFunc quitfunc) { RefDelegate initfuncwrapper = delegate() { return(Result.getCPtr(initfunc()).Handle); }; RefDelegate postinitfuncwrapper = delegate() { return(Result.getCPtr(initfunc()).Handle); }; RefDelegate cyclicfuncwrapper = delegate() { return(System.IntPtr.Zero); }; RefDelegate quitfuncwrapper = delegate() { return(System.IntPtr.Zero); }; { Result ret = new Result(ISMathPINVOKE.Engine_Run(swigCPtr, initfuncwrapper, postinitfuncwrapper, cyclicfuncwrapper, quitfuncwrapper), true); return(ret); } }
public void TestComplexLoadLibrary() { IntPtr hModule = Win32.LoadLibrary("testCppDll.dll"); int error = Marshal.GetLastWin32Error(); //Console.WriteLine("The Last Win32 Error was: " + error); if (hModule == IntPtr.Zero) { return; } unsafe { InitFunc initFunc = (InitFunc)UseDllByLoadLibrary.GetFunctionAddress(hModule, "Initialize", typeof(InitFunc)); bool isInit = initFunc(""); if (isInit) { string text = ""; FindNames findNamesFunc = (FindNames)UseDllByLoadLibrary.GetFunctionAddress(hModule, "FindNames", typeof(FindNames)); IntPtr arrayPtr = IntPtr.Zero; uint arraySize; if (findNamesFunc(text, out arrayPtr, out arraySize)) { NameEntity[] names = new NameEntity[arraySize]; IntPtr cur = arrayPtr; for (int i = 0; i < arraySize; i++) { names[i] = new NameEntity(); Marshal.PtrToStructure(cur, names[i]); Marshal.DestroyStructure(cur, typeof(NameEntity)); cur = (IntPtr)((int)cur + Marshal.SizeOf(names[i])); } Assert.AreEqual(names.Count(), arraySize); } Assert.AreNotEqual(arrayPtr, IntPtr.Zero); Marshal.FreeCoTaskMem(arrayPtr); } } Win32.FreeLibrary(hModule); }
/// <summary> /// 实例化特效物体 /// </summary> public void CreateInstance(InitFunc callBack) { if (mIsDestroy) { return; } // 如果特效文件已经加载完成,则直接进行实例化 if (mEffectPrefab != null) { if (callBack != null) { var newEffect = ObjInstHelp.GetInstance().InstantiateReuse(mEffectPrefab, mInstMaxCount); callBack(newEffect); } } // 未加载完成则将初始化回调函数添加到列表中,等到加载完毕后再进行调用 else { mInitCallback.Add(callBack); } }
private static void LoadProduct() { lock (Locker) { if (Product != null) { return; } Product = Load(); _loaded = true; if (Product == null) { return; } CombatProp = Product.GetType().GetProperty("CombatBehavior"); HealProp = Product.GetType().GetProperty("HealBehavior"); PullProp = Product.GetType().GetProperty("PullBehavior"); PreCombatProp = Product.GetType().GetProperty("PreCombatBuffBehavior"); PullBuffProp = Product.GetType().GetProperty("PullBuffBehavior"); CombatBuffProp = Product.GetType().GetProperty("CombatBuffBehavior"); RestProp = Product.GetType().GetProperty("RestBehavior"); PulseFunc = Product.GetType().GetMethod("Pulse"); ShutDownFunc = Product.GetType().GetMethod("ShutDown"); ButtonFunc = Product.GetType().GetMethod("OnButtonPress"); InitFunc = Product.GetType().GetMethod("OnInitialize", new[] { typeof(int) }); if (InitFunc != null) { #if RB_CN Log($"{ProjectName} CN loaded."); InitFunc.Invoke(Product, new[] { (object)2 }); #else Log($"{ProjectName} 64 loaded."); InitFunc.Invoke(Product, new[] { (object)1 }); #endif } } }
public Result Run(InitFunc initfunc, InitFunc postinitfunc, CyclicFunc cyclicfunc, QuitFunc quitfunc) { RefDelegate initfuncwrapper = delegate() { return(Result.getCPtr(initfunc()).Handle); }; RefDelegate postinitfuncwrapper = delegate() { return(Result.getCPtr(initfunc()).Handle); }; RefDelegate cyclicfuncwrapper = delegate() { return(System.IntPtr.Zero); }; RefDelegate quitfuncwrapper = delegate() { return(System.IntPtr.Zero); }; { Result ret = new Result(IronSightEnginePINVOKE.Engine_Run(swigCPtr, initfuncwrapper, postinitfuncwrapper, cyclicfuncwrapper, quitfuncwrapper), true); // if (IronSightEnginePINVOKE.SWIGPendingException.Pending) { throw IronSightEnginePINVOKE.SWIGPendingException.Retrieve(); } return(ret); } }
public bool Equals(MetaInfo other) { return(true && Api.Equals(other.Api) && Type.Equals(other.Type) && Size.Equals(other.Size) && InitFunc.Equals(other.InitFunc) && FreeFunc.Equals(other.FreeFunc) && TransformFunc.Equals(other.TransformFunc)); }
void Start() { FSM.addState(init, null); FSM.addState(run, init); FSM.addState(end, null); init_func += randomInitFunction; run_func += RunControll; InvokeNextState(); }
public override int GetHashCode() { return(this.GetType().FullName.GetHashCode() ^ Api.GetHashCode() ^ Type.GetHashCode() ^ Size.GetHashCode() ^ InitFunc.GetHashCode() ^ FreeFunc.GetHashCode() ^ TransformFunc.GetHashCode()); }
public ComponentPool(InitFunc <T> initFunc, ResetFunc <T> resetFunc) { init = initFunc; reset = resetFunc; }
public override void Test() { RClay other = new RClay(); int Result = 0; int Inited = 0; ResponseFunc r = (RClay rc, object cp) => { int A = rc.GetSignals <int>("A"); int B = rc.GetSignals <int>("B"); Result = A + B; }; InitFunc i = (RClay rc) => { Inited++; }; RClay c = new RClay(new Dictionary <string, object> { { "P1", 1 }, { "P2", 2 }, { "ConnectPoints", new List <object> { "A", "B" } }, { "Response", r }, { "Init", i } }); c.onConnection(this, "A"); c.onConnection(this, "B"); c.onCommunication(this, "A", 1); //Make sure that if clay has not collected every signal //There will be no response Assert(Result, 0); c.onCommunication(this, "B", 2); Assert(Result, 3); //Randomly check Init already got called and got called once only Assert(Inited, 1); c.onCommunication(this, "A", 2); Assert(Result, 4); //Make sure signal from stranger does not count c.onCommunication(other, "A", 6); Assert(Result, 4); c.Stage = true; c.onCommunication(this, "B", 4); Assert(Result, 6); //Randomly check Init already got called and got called once only Assert(Inited, 1); c.onCommunication(this, "B", 7); //Make sure that Stage did clear all signals //And result should be the same as the previous Assert(Result, 6); //Assign information to B again c.onCommunication(this, "B", 8); // Make sure no change //And result should be the same as the previous Assert(Result, 6); c.onCommunication(this, "A", 8); Assert(Result, 16); c.onCommunication(this, "B", 1); //Make sure that all signals got cleared again //And the result is still the same because response has not been called Assert(Result, 16); }