// Stops replay and releases resources private static void Cleanup() { if (tx_sock != null) { tx_sock.Close(); } if (BinaryReader != null) { BinaryReader.Close(); } if (FileStream != null) { FileStream.Close(); } if (BinaryReader != null) { BinaryReader.Dispose(); } if (FileStream != null) { FileStream.Dispose(); } TotalFileSizeBytes = 0; Replay_Status = ReplayStatus.Disconnected; }
// Status change handler private static void SetStatus(ReplayStatus Status) { // If status desired is already reached do nothing if (Status != Replay_Status) { switch (Status) { case AsterixReplay.ReplayStatus.Disconnected: StopThread(); break; case AsterixReplay.ReplayStatus.Connected: KeepGoing = true; RequestStop = false; ReplayThread = new Thread(new ThreadStart(DOWork)); ReplayThread.Start(); Replay_Status = ReplayStatus.Connected; break; case AsterixReplay.ReplayStatus.Paused: Replay_Status = ReplayStatus.Paused; break; case AsterixReplay.ReplayStatus.Replaying: Replay_Status = ReplayStatus.Replaying; break; } } }
public static void BeginRecording() { Log.Unity("Replay recording started."); lastFrame = -1; replayStartFrame = null; recording = new List <FrameInput>(1000000); status = ReplayStatus.RECORDING; PostedReplay = null; }
/// <summary> /// Stop the recording and go to replay mode. After context is reseted and paused. /// </summary> public void Stop() { //Reset simulation context.ResetContext(); //set replay mode on mode = ReplayStatus.Replaying; replayPosition = 0; onEnterReplayMode.Invoke(); }
/// <summary> /// Go to Waiting Mode, does not record nor replay. /// </summary> public void Wait() { mode = ReplayStatus.Waiting; //Reset Simulation clear commands context.ResetContext(); replayPosition = 0; commands.Clear(); onEnterWaitMode.Invoke(); }
public static void Cancel() { Log.Unity("Cancelling in-progress replayer."); status = ReplayStatus.NONE; Achievement.ACHIEVEMENT_PROGRESS_ENABLED = true; recording = null; loadedFrames = null; replaying = null; PostedReplay = null; }
public static void BeginReplaying(ReplayerConfig data) { Log.Unity($"Replay playback started."); Achievement.ACHIEVEMENT_PROGRESS_ENABLED = false; lastFrame = -1; replayStartFrame = null; recording = null; //Minor optimization for replay restart if (!replaying.Try(out var r) || r != data) { Log.Unity($"Setting frames to lazy-load for replay."); loadedFrames = null; replaying = data; } status = ReplayStatus.REPLAYING; }
private void InvokeEventAndCleanup(ReplayStatus status, string replayPath = "", string gifPath = "", string outputPath = "", string errorMessage = "") { if (!String.IsNullOrEmpty(replayPath) && File.Exists(replayPath)) { File.Delete(replayPath); } if (!String.IsNullOrEmpty(gifPath) && File.Exists(gifPath)) { if (status != ReplayStatus.GameError) { File.Move(gifPath, outputPath, true); } File.Delete(gifPath); } Processed?.Invoke(this, new ReplayEventArgs(status, outputPath, errorMessage)); }
public static Replay?End(InstanceRecord?rec) { if (status == ReplayStatus.RECORDING) { Log.Unity($"Finished recording {recording?.Count ?? -1} frames."); } else if (status == ReplayStatus.REPLAYING) { Log.Unity($"Finished replaying {lastFrame - ReplayStartFrame + 1}/{LoadedFrames?.Length ?? 0} frames."); } status = ReplayStatus.NONE; Achievement.ACHIEVEMENT_PROGRESS_ENABLED = true; PostedReplay = (recording != null && rec != null) ? new Replay(recording.ToArray(), rec) : (Replay?)null; recording = null; loadedFrames = null; replaying = null; return(PostedReplay); }
public static async Task InvokeOnAggregateAsync <TAggregateKey, TEventKey>(this IEvent <AggregateRoot <TAggregateKey, TEventKey>, TAggregateKey, TEventKey> @event, AggregateRoot <TAggregateKey, TEventKey> aggregate, string methodName, ReplayStatus replayStatus) { var method = ReflectionHelper.GetMethod(aggregate.GetType(), methodName, new Type[] { @event.GetType() }); //Find the right method object[] args; if (method == null) { method = ReflectionHelper.GetMethod(aggregate.GetType(), methodName, new Type[] { @event.GetType(), typeof(ReplayStatus) }); // handler with replay status if (method == null) { throw new AggregateEventOnApplyMethodMissingException($"No event Apply method found on {aggregate.GetType()} for {@event.GetType()}"); } args = new object[] { @event, replayStatus }; } else { args = new object[] { @event }; } var task = method.Invoke(aggregate, args); //invoke with the event handler if (task != null && task.GetType() == typeof(Task)) { await(Task) task; } }
/// <summary> /// Go to record mode. Start the context and start to record. /// </summary> public void Record() { mode = ReplayStatus.Recording; onEnterRecordMode.Invoke(); context.StartContext(); }
public static bool IsReplay(this ReplayStatus replayStatus) { return(replayStatus == ReplayStatus.Replay); }
// Stops replay and releases resources private static void Cleanup() { if (tx_sock != null) tx_sock.Close(); if (BinaryReader != null) BinaryReader.Close(); if (FileStream != null) FileStream.Close(); if (BinaryReader != null) BinaryReader.Dispose(); if (FileStream != null) FileStream.Dispose(); TotalFileSizeBytes = 0; Replay_Status = ReplayStatus.Disconnected; }
public ReplayEventArgs(ReplayStatus status, string outputPath, string errorMessage) { Status = status; OutputPath = outputPath; ErrorMessage = errorMessage; }