public static BlockingTriggerYieldInstruction Create() { var obj = _pool.GetInstance(); obj._count = 0; return(obj); }
public static UnityDataFormatter GetFormatter <T>() where T : IFormatter { if (_formatterPools == null) { _formatterPools = new Dictionary <System.Type, ObjectCachePool <UnityDataFormatter> >(); } var tp = typeof(T); UnityDataFormatter formatter; if (_formatterPools.ContainsKey(tp)) { formatter = _formatterPools[tp].GetInstance(); } else { var pool = new ObjectCachePool <UnityDataFormatter>(10, () => { var f = new UnityDataFormatter(System.Activator.CreateInstance <T>()); f._pooledTypeKey = typeof(T); return(f); }); _formatterPools.Add(tp, pool); formatter = pool.GetInstance(); } return(formatter); }
public static InvokeHandle Begin(UpdatePump pump, System.Action callback, float duration, ITimeSupplier time) { if (pump == null) { throw new System.ArgumentNullException("pump"); } var handle = _pool.GetInstance(); handle._callback = callback; handle._handle = WaitForDuration.Seconds(duration, time); handle._pump = pump; pump.Add(handle); return(handle); }
/// <summary> /// quickly generates a timer for a specific duration, when accessing the count event do NOT attempt to store /// a reference to the timer as it is a pooled asset and can quickly change to an unstable state. /// </summary> /// <param name="delay">Duration in seconds.</param> /// <param name="complete">Delegate fired when the timer completes.</param> /// <param name="count">Delegate fired when the time ticks.</param> public static void CreateGypsyTimer(float delay, System.Action <GameTimer> complete, System.Action <GameTimer> count) { var t = _timerPool.GetInstance(); t.Delay = delay; t.RepeatCount = 0; if (complete == null) { throw new System.ArgumentNullException("complete", "complete event handler must be non-null"); } t.TimerComplete += complete; if (count != null) { t.TimerCount += count; } t.Start(); }
public static StringBuilder GetTempStringBuilder() { return(_pool.GetInstance()); }
public static SPSerializer Create() { return(_pool.GetInstance()); }
public static UnityDataFormatter Create() { return(_pool.GetInstance()); }