private IEnumerator DelayHelper(DelayedFunc f, float p_delay) { //Debug.Log("Delay start"); yield return(new WaitForSeconds(p_delay)); f(); }
protected override void OnCollision(EntityId targetEntityId, Vec3 hitPos, Vec3 dir, short materialId, Vec3 contactNormal) { // Hit something, reset last event time. if(state == BoidState.Launched) { if(postFire == null) postFire = new DelayedFunc(OnStoppedMoving, 4000); else postFire.Reset(); } }
void OnStoppedMoving() { if(Launcher.Instance != null) { postFire = null; ReceiveUpdates = false; state = BoidState.Dead; Launcher.Instance.PostFire(); } }
protected override void OnCollision(EntityId targetEntityId, Vec3 hitPos, Vec3 dir, short materialId, Vec3 contactNormal) { // Hit something, reset last event time. if (state == BoidState.Launched) { if (postFire == null) { postFire = new DelayedFunc(OnStoppedMoving, 4000); } else { postFire.Reset(); } } }
public async Task RunWithoutParamTest() { var called = false; var sw = new Stopwatch(); Func <string> fun = new Func <string>(() => { called = true; sw.Stop(); return("Received!"); }); var delayedFunc = new DelayedFunc <string>(fun); sw.Start(); var result = await delayedFunc.RunWithDelayAsync(2000); Assert.IsTrue(called); Assert.AreEqual("Received!", result); Assert.IsTrue(sw.Elapsed.TotalMilliseconds > 2000); }
private IEnumerator DelayHelper(DelayedFunc f, float p_delay) { //Debug.Log("Delay start"); yield return new WaitForSeconds(p_delay); f(); }
public void Delay(DelayedFunc f, float p_delay) { StartCoroutine(DelayHelper(f, p_delay)); }
public TestEntity() { delayedFunc = new DelayedFunc(MyDelayedFunc, 1337); }
IEnumerator DelayFunc_(DelayedFunc func, float time) { yield return(new WaitForSeconds(time)); func.Invoke(); }
public void DelayFunc(DelayedFunc func, float time) { StartCoroutine(DelayFunc_(func, time)); }