/// Handler追加(削除用のCancelKeyが返る) public CancelKey Add(TFunc func, PosInfos addPos) { GearDispatcherHandler <TFunc> handler = new GearDispatcherHandler <TFunc>(func, addPos); AddBehavior.Execute(_addBehavior, _list, handler); return(handler); }
/// クラス名で指定したインスタンスを取得(初期ステップ) public T Get <T>(PosInfos pos) { Type clazz = typeof(T); string className = clazz.ToString(); return(GetWithClassName <T>(className, this, pos)); }
/// absorb。Diffuserから該当クラスのインスタンスを取得 public T Absorb <T>(PosInfos pos) { if (_holder == null) { return(default(T)); } return(_diffuser.Get <T>(pos)); }
public CancelKey AddEndProcess(Action func, PosInfos pos) { if (!CheckPhaseBeforeDispose()) { throw new Exception("既に消去処理が開始されているため、消去時のハンドラを登録できません" + _phase); } return(_endDispatcher.Add(func, pos)); }
/// 初期化 public GenericGearDispatcher(AddBehavior.MethodType addBehavior, bool once, PosInfos dispatcherPos) { _addBehavior = addBehavior; _once = once; _dispatcherPos = dispatcherPos; _executeLock = false; _list = new List <GearDispatcherHandler <TFunc> >(); }
private static void ShowMessage(string message, uint level) { if (!CanShowLogLevel(level)) { return; } PosInfos posInfoCallLog = new PosInfos(3); UnityEngine.Debug.Log(prefixDict[level] + message + "\n " + posInfoCallLog.ToString() + " \n\n"); }
/// クラス名で指定したインスタンスを取得(親にさかのぼりながら探索する) private T GetWithClassName <T>(string className, Diffuser startDiffuser, PosInfos pos) { if (_instanceClassDictionary.ContainsKey(className)) { /// 自分がそのクラスのインスタンスを保持していれば返す return((T)_instanceClassDictionary[className]); } else { /// ないので親に聞いてみる if (_parent == null) { /// 親なしなので見つからない throw new Exception(string.Format("指定されたクラス{0}は{1}のDiffuserに登録されていません。;pos={2}", className, startDiffuser._holder, pos)); } return(_parent.GetWithClassName <T>(className, startDiffuser, pos)); } }
/// 実行 /// 同時実行されたときにおかしくならないようにいったんローカルに対比してから実行している public void Execute(Action <GearDispatcherHandler <TFunc> > treat, PosInfos executePos) { if (_executeLock) { throw new Exception("実行関数が入れ子になっています"); } _executeLock = true; List <GearDispatcherHandler <TFunc> > tmpHandlerList = new List <GearDispatcherHandler <TFunc> >(_list); if (_once) { Clear(); } for (int i = 0; i < tmpHandlerList.Count; i++) { treat(tmpHandlerList[i]); } tmpHandlerList.Clear(); tmpHandlerList = null; _executeLock = false; }
/// 実行 public void Execute(PosInfos executePos) { GenericGearDispatcher.Execute(Trat, executePos); }
/// 追加(削除用のCancelKeyが返る) public CancelKey Add(Action func, PosInfos addPos) { return(GenericGearDispatcher.Add(func, addPos)); }
/// 初期化 public GearDispatcher(AddBehavior.MethodType addBehavior, bool once, PosInfos pos) { GenericGearDispatcher = new GenericGearDispatcher <Action>(addBehavior, once, pos); }
public void AddStartProcess(Action func, PosInfos pos) { _startDispatcher.Add(func, pos); }
// ==== 以下、handlerへの追加処理 ==== public void AddPreparationProcess(Action func, PosInfos pos) { _preparationDispatcher.Add(func, pos); }
public GearDispatcherHandler(TFunc func, PosInfos addPos) { _func = func; _addPos = addPos; }