private void StartPersistentScanning() { PersistentScanningTask = new Task(() => { try { GameOverScan gameOverData = new GameOverScan(); RoundOverScan roundOverData = new RoundOverScan(); while (PersistentScan) { SpinWait.SpinUntil(() => { return(OnGameOver != null || OnRoundOver != null || OnDisconnect != null); }); using (LockHandler.Passive) { UpdateScreen(); ScanGameOver(gameOverData); ScanRoundOver(roundOverData); InvokeOnDisconnect(); } Thread.Sleep(10); // End } } catch (OverwatchClosedException) { } }); PersistentScanningTask.Start(); }
private void ScanGameOver(GameOverScan data) { // The blue team must have "\" on the start of their name. // The red team must have "*" on the start of their name. if (OnGameOver != null) { Team?thisCheck = null; for (int x = 110; x < 450; x++) { // Test for a straight line '|' if (Capture.CompareColor(x, 295, new int[] { 132, 117, 87 }, 7) && Capture.CompareColor(x, 267, new int[] { 132, 117, 87 }, 7)) { thisCheck = Team.Blue; break; } // Test for just the top '*' else if (Capture.CompareColor(x, 267, new int[] { 132, 117, 87 }, 7)) { thisCheck = Team.Red; break; } } if (thisCheck == null) { data.Executed = false; data.CurrentWinningTeamCheck = null; data.CheckTime.Reset(); } else if (data.CurrentWinningTeamCheck != thisCheck) { data.Executed = false; data.CurrentWinningTeamCheck = thisCheck; data.CheckTime.Restart(); } else if (data.CurrentWinningTeamCheck == thisCheck) { if (!data.Executed && data.CheckTime.ElapsedMilliseconds >= GameOverScan.CheckLength) { OnGameOver(this, new GameOverArgs((Team)thisCheck)); data.Executed = true; } } } else { data.Executed = false; data.CurrentWinningTeamCheck = null; data.CheckTime.Reset(); } }