private void AutoSplitterLogic() { while (!AutoSplitterCancellationToken.IsCancellationRequested) { while ((Game.GameProcess = Shrek2Utils.GetGameProcess()) == null) { Task.Delay(250); if (AutoSplitterCancellationToken.IsCancellationRequested) { return; } } if (Game.GameProcess == null || Game.GameProcess.HasExited) { Task.Delay(Shrek2Variables.SleepTime); continue; } var gameState = Game.GetGameState(); if (gameState == Shrek2Game.GameState.NewGame) { IsTimerGoing = true; UIThread.Post(d => { OnNewGame(); }, null); } else if (gameState == Shrek2Game.GameState.Reset) { IsTimerGoing = false; UIThread.Post(d => { OnMainMenuLoad(); }, null); } else if (gameState == Shrek2Game.GameState.Split) { UIThread.Post(d => { OnSplit(); }, null); } if (!IsTimerGoing) { continue; } var logLines = Game.GetCurrentCutLogLines(); if (logLines == null || logLines.Count <= 0) { Task.Delay(Shrek2Variables.SleepTime); continue; } foreach (var line in logLines) { var loadlessState = Game.GetLoadlessState(line); if (loadlessState == Shrek2Game.GameState.Pause) { UIThread.Post(d => { OnPause(); }, null); } else if (loadlessState == Shrek2Game.GameState.Resume) { UIThread.Post(d => { OnResume(); }, null); } else if (loadlessState == Shrek2Game.GameState.Split) { UIThread.Post(d => { OnSplit(); }, null); } } Task.Delay(Shrek2Variables.SleepTime); } }