/// <summary> /// 注销现有的信号处理机并依照字典重绑定信号与处理机 /// </summary> /// <param name="scene">当前场景</param> /// <param name="bindingDict">重绑定字典</param> public static void ReBinding(Scene scene, Dictionary <string, List <Tuple <string, string> > > bindingDict) { SemaphoreDispatcher.UnregisterSemaphoreService(true); foreach (var sema in bindingDict) { foreach (var tp in sema.Value) { var activator = scene.FuncContainer.Find(t => t.Callname == tp.Item1); var deactivator = scene.FuncContainer.Find(t => t.Callname == tp.Item2); SemaphoreDispatcher.RegisterSemaphoreService(sema.Key, activator, deactivator, null, "", true); } } }
/// <summary> /// 初始化系统默认信号量 /// </summary> public static void InitSystemSemaphore() { // 键盘IO信号量 foreach (var t in Enum.GetNames(typeof(Key))) { SemaphoreDispatcher.SetSemaphore($"System_Key_{t}"); } // 鼠标IO信号量 foreach (var t in Enum.GetNames(typeof(MouseButton))) { SemaphoreDispatcher.SetSemaphore($"System_Mouse_{t}"); } // 按钮信号量 for (int i = 0; i < GlobalConfigContext.GAME_BUTTON_COUNT; i++) { SemaphoreDispatcher.SetSemaphore($"System_Button_Over_{i}"); } // 窗口关闭信号量 SemaphoreDispatcher.SetSemaphore("System_PreviewShutdown"); }
/// <summary> /// 接受信号变更通知并执行处理函数 /// </summary> /// <param name="notifier">通知者</param> public override void Notified(YuriObservable notifier) { SemaphoreDispatcher.Schedule(notifier as YuriSemaphore, this); }