private void Update() { if (IsRunning != (Runner != null)) { IsRunning = Runner != null; OnRunningChanged?.Invoke(IsRunning); if (IsRunning) { OnInit?.Invoke(); start = next = Utils.TimeGetTime(); } } if (IsRunning) { updateWatch.Start(); if (useNewUpdate) { NewUpdate(); } else { OriginalUpdate(); } updateWatch.Stop(); OnStatus?.Invoke(Runner.GetStatus(updateWatch)); } }
private void Update() { if (IsRunning != (Runner != null)) { IsRunning = Runner != null; OnRunningChanged?.Invoke(IsRunning); if (IsRunning) { OnInit?.Invoke(); } } if (Runner != null) { updateWatch.Start(); var now = Time.time; var extraMs = Mathf.Max(0, (int)((next - now) * 1000f) - 1); Runner.Idle(extraMs); Thread.Sleep(extraMs); if (now >= next) { OnPreRunFrame(); Runner.RunFrame(); next = now + 1f / 60f; OnStateChanged?.Invoke(); } updateWatch.Stop(); string status = Runner.GetStatus(updateWatch); OnStatus?.Invoke(status); OnChecksum?.Invoke(RenderChecksum(Runner.GameInfo.periodic) + RenderChecksum(Runner.GameInfo.now)); } }
public void Reset() { _timer.Stop(); MillisecondsLeft = 0; NextSensor = 0; OnRunningChanged?.Invoke(false); OnCountdownChanged?.Invoke(MillisecondsLeft); OnNextSensorChanged?.Invoke(NextSensor); }
public void Start() { OnRunningChanged?.Invoke(true); if (NextSensor == 0) { MillisecondsLeft = 0; } _timer.Start(); }
public void Stop() { OnRunningChanged?.Invoke(false); _timer.Stop(); }