public void OnTick(object o, EventArgs e) { if (server.Poll(10, SelectMode.SelectRead) && connection == null) { connection = server.Accept(); UI.Notify("CONNECTED"); connection.Blocking = false; } handlePipeInput(); if (!enabled) { return; } //Array values = Enum.GetValues(typeof(Weather)); switch (checkStatus()) { case GameStatus.NeedReload: //TODO: need to get a new session and run? StopRun(); runTask?.Wait(); runTask = StartRun(); //StopSession(); //Autostart(); UI.Notify("need reload game"); Script.Wait(100); ReloadGame(); break; case GameStatus.NeedStart: //TODO do the autostart manually or automatically? //Autostart(); // use reloading temporarily StopRun(); ReloadGame(); Script.Wait(100); runTask?.Wait(); runTask = StartRun(); //Autostart(); break; case GameStatus.NoActionNeeded: break; } if (!runTask.IsCompleted) { return; } if (!postgresTask.IsCompleted) { return; } List <byte[]> colors = new List <byte[]>(); Game.Pause(true); Script.Wait(500); GTAData dat = GTAData.DumpData(Game.GameTime + ".tiff", new List <Weather>(wantedWeather)); if (dat == null) { return; } var thisframe = VisionNative.GetCurrentTime(); var depth = VisionNative.GetDepthBuffer(); var stencil = VisionNative.GetStencilBuffer(); colors.Add(VisionNative.GetColorBuffer()); /* * foreach (var wea in wantedWeather) { * World.TransitionToWeather(wea, 0.0f); * Script.Wait(1); * colors.Add(VisionNative.GetColorBuffer()); * }*/ Game.Pause(false); /* * if (World.Weather != Weather.Snowing) * { * World.TransitionToWeather(Weather.Snowing, 1); * * }*/ var colorframe = VisionNative.GetLastColorTime(); var depthframe = VisionNative.GetLastConstantTime(); var constantframe = VisionNative.GetLastConstantTime(); //UI.Notify("DIFF: " + (colorframe - depthframe) + " FRAMETIME: " + (1 / Game.FPS) * 1000); if (depth == null || stencil == null) { return; } /* * this code checks to see if there's drift * it's kinda pointless because we end up "straddling" a present call, * so the capture time difference can be ~1/4th of a frame but still the * depth/stencil and color buffers are one frame offset from each other * if (Math.Abs(thisframe - colorframe) < 60 && Math.Abs(colorframe - depthframe) < 60 && * Math.Abs(colorframe - constantframe) < 60) * { * * * * * * PostgresExport.SaveSnapshot(dat, run.guid); * } */ ImageUtils.WaitForProcessing(); ImageUtils.StartUploadTask(archive, Game.GameTime.ToString(), Game.ScreenResolution.Width, Game.ScreenResolution.Height, colors, depth, stencil); PostgresExport.SaveSnapshot(dat, run.guid); if (S3Stream.Length > 512 * 1024 * 1024) { ImageUtils.WaitForProcessing(); StopRun(); runTask?.Wait(); runTask = StartRun(); } }