// Use this for initialization public static DeferredActing Create(float wait, GameObject provider, TheDelegater func, ActionMode mode = default(ActionMode), string actionName = "", WaiterType type = WaiterType.Inovker, bool isFrame = false) { DeferredActing delayer = null; switch (mode) { case ActionMode.Ascending: delayer = provider.AddComponent <DeferredActing>(); break; case ActionMode.Require: DeferredActing[] deferrers = provider.GetComponents <DeferredActing>(); bool has = false; foreach (var deferrer in deferrers) { if (deferrer.DelegaterName == actionName) { delayer = deferrer; has = true; break; } } if (!has) { delayer = provider.AddComponent <DeferredActing>(); } break; case ActionMode.Replace: DeferredActing[] _deferrers = provider.GetComponents <DeferredActing>(); foreach (var deferrer in _deferrers) { if (deferrer.DelegaterName == actionName) { Destroy(deferrer); } } delayer = provider.AddComponent <DeferredActing>(); break; } delayer.SetDelegater(func); switch (type) { case WaiterType.Coroutine: delayer.IsWaitFrame = isFrame; delayer.Coroutine = delayer.StartCoroutine(delayer.CoroutineCallback(wait)); break; case WaiterType.Inovker: delayer.Invoke("InvokeCallback", wait); break; case WaiterType.AsyncAwait: delayer.AsyncCall(wait, delayer.TokenSource); break; } delayer.DelegaterName = actionName; return(delayer); }
public Waiter(DrinkingBout drinkingBout, WaiterType type) { this.drinkingBout = drinkingBout; this.type = type; }