public void SetCooldownTest() { ScheduledEvent evt = new ScheduledEvent( "test", callback, 3.0f, true, 1); Reset(); evt.Update(2f); evt.SetCooldown(2.5f); Assert.That(evt.TimeToWait, Is.EqualTo(.5f)); Assert.That(didRun, Is.False); evt.SetCooldown(1f); Assert.That(evt.TimeToWait, Is.EqualTo(0f)); evt.Update(.1f); Assert.That(didRun, Is.True); Assert.That(runCount, Is.EqualTo(1)); }
public void SetAutosaveInterval(int newInterval) { AutosaveInterval = newInterval; if (newInterval == 0) { scheduler.DeregisterEvent(autosaveEvent); return; } if (autosaveEvent == null) { autosaveEvent = new ScheduledEvent("autosave", DoAutosave, newInterval * 60.0f, true, 0); scheduler.RegisterEvent(autosaveEvent); } else { autosaveEvent.SetCooldown(newInterval * 60.0f); } }