public NativeDll(string path) { _dllHandle = Kernel32Dll.LoadLibrary(path); if (_dllHandle == IntPtr.Zero) { throw new InteropException("LoadLibrary failed to load native.dll"); } IntPtr procAddress = IntPtr.Zero; if ((procAddress = Kernel32Dll.GetProcAddress(_dllHandle, "SetupSubclass")) == IntPtr.Zero) { throw new InteropException("SetupSubclass function is not present in native.dll"); } _setupSubclassFunc = (BoolActionOnIntPtr)Marshal.GetDelegateForFunctionPointer(procAddress, typeof(BoolActionOnIntPtr)); if ((procAddress = Kernel32Dll.GetProcAddress(_dllHandle, "TearDownSubclass")) == IntPtr.Zero) { throw new InteropException("TearDownSubclass function is not present in native.dll"); } _tearDownFunc = (BoolAction)Marshal.GetDelegateForFunctionPointer(procAddress, typeof(BoolAction)); if ((procAddress = Kernel32Dll.GetProcAddress(_dllHandle, "IsSubclassed")) == IntPtr.Zero) { throw new InteropException("TearDownSubclass function is not present in native.dll"); } _isSubclassedFunc = (BoolAction)Marshal.GetDelegateForFunctionPointer(procAddress, typeof(BoolAction)); }
/// <summary> /// Check each of the booleans in a BoolAction. If any of the returns are false, /// return false. If none of them are false, we can return true. /// </summary> /// <param name="actions">Event storage of methods.</param> private static bool DoesBoolExist(BoolAction actions, GameObject g) { foreach(BoolAction bAction in actions.GetInvocationList()) { //If the return value of the action is ever false, return value must be false if(bAction(g) == false) { return false; } } return true; }
/// <summary> /// Enumerate all FileCalls from all the different methods with where filter. /// </summary> public static IEnumerable<FileCall> Enumerate(BoolAction<FileCall> where) { var methods = GetNativeStartupMethods(); return methods.SelectMany(m => m.Attached).Where(fc=>where(fc)); }
/// <summary> /// Subscribe the specified key with the given method /// </summary> /// <param name="key">Key to subscribe to</param> /// <param name="d">boolean action to run on publish</param> public static void Subscribe(string key, BoolAction d) { //If the subscription already contains the key, //add this delegate to the existing delegate under the given key if(boolSubscriptions.ContainsKey(key)) { //Add delegate to existing delegate boolSubscriptions[key] += d; } else { //Create a new entry in the subscription dictonary boolSubscriptions.Add(key, d); } }
public void ActivateTimeScaler(BoolAction checkBool) { TimeAdjuster adjuster = new TimeAdjuster(1f, checkBool); activatedTimeScaler = TimeScaleManager.Instance.AdjustTimeScale(adjuster); }
public override IEnumerator DoPutMultiple(IDictionary <string, object> keyValuePairs, BoolAction <Exception> action, Action <float> progess) { try { progess(0); foreach (KeyValuePair <string, object> kv in keyValuePairs) { Map[kv.Key] = kv.Value; } progess(1); action?.Invoke(true, null); }catch (Exception e) { action?.Invoke(false, e); } yield return(null); }
protected MonitorSingleBase(DynamicEqualityComparer <T> comparer, BoolAction <T> isblacklisted) { this.comparer = comparer; this.isblacklisted = isblacklisted; }
/// <summary> /// Enumerate all FileCalls from all the different methods with where filter. /// </summary> public static IEnumerable <FileCall> Enumerate(BoolAction <FileCall> where) { var methods = GetNativeStartupMethods(); return(methods.SelectMany(m => m.Attached).Where(fc => where (fc))); }
public void SpawnMonster (MonsterConfig monster, int level, int HP, int armor, int maxArmor, Vector3 pos, float dir, BoolAction<GameObject> Cb = null) { }
public void Show(BoolAction whenDone) { callback = whenDone; Show(true); }
protected virtual IEnumerator DoSetDataMultiple(IDictionary <string, object> keyValuePairs, MonoBehaviour context, BoolAction <Exception> action) { foreach (KeyValuePair <string, object> kv in keyValuePairs) { bool t1 = false; Exception t2 = null; Coroutine c; try { c = context.StartCoroutine(DoSetData(kv.Key, kv.Value, context, (s, e) => { t1 = s; t2 = e; })); } catch (Exception e) { action?.Invoke(false, e); yield break; } yield return(c); if (!t1) { action?.Invoke(false, t2); yield break; } } }
protected abstract IEnumerator DoSetData(string key, object value, MonoBehaviour context, BoolAction <Exception> action);
/// <summary> /// Subscribe to an event in the pub sub dictionaries. This will attach /// to the dictionary containing only BoolActions, which return bool values /// on execution. /// </summary> /// <param name="key">Name of Value in Dictionary</param> /// <param name="sub">Subscription of methods to Key</param> public void Subscribe(string key, BoolAction b) { EventDispatcher.Subscribe(key, b); }
/// <summary> /// Show alert in console with question. /// </summary> /// <param name="message">Question text.</param> /// <param name="action">Action with return type of bool that would be executed if answer will 'y'.</param> /// <returns></returns> public static bool ShowAlert(string message, BoolAction action) { Console.Write(message); return Console.ReadLine() == "y" && action(); }