Ejemplo n.º 1
0
        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));
            }
        }
Ejemplo n.º 2
0
        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));
            }
        }
Ejemplo n.º 3
0
 public void Reset()
 {
     _timer.Stop();
     MillisecondsLeft = 0;
     NextSensor       = 0;
     OnRunningChanged?.Invoke(false);
     OnCountdownChanged?.Invoke(MillisecondsLeft);
     OnNextSensorChanged?.Invoke(NextSensor);
 }
Ejemplo n.º 4
0
        public void Start()
        {
            OnRunningChanged?.Invoke(true);
            if (NextSensor == 0)
            {
                MillisecondsLeft = 0;
            }

            _timer.Start();
        }
Ejemplo n.º 5
0
 public void Stop()
 {
     OnRunningChanged?.Invoke(false);
     _timer.Stop();
 }