/// <summary> /// Recall a snapshot from the replay target based on the specified replay offset. /// </summary> /// <param name="offset">The offset pointing to the individual snapshot to recall</param> /// <returns>The replay snapshot at the specified offset</returns> public override ReplaySnapshot RestoreSnapshot(float offset) { // Check for no replay data if (states.Count == 0) { return(null); } // Check for past clip end if (offset > Duration) { return(null); } // Default to first frame ReplaySnapshot current = states[0]; // Check all states to find the best matching snapshot that has a time stamp greater than the specified offset (Always snap to newer frame) foreach (ReplaySnapshot snapshot in states) { // Store the current snapshot current = snapshot; // Check if the timestamp is passed the offset if (snapshot.TimeStamp >= offset) { break; } } return(current); }
// Methods /// <summary> /// Store a replay snapshot in the replay target. /// If the new snapshot causes the internal buffer to 'overflow' then the recoding clip will be wrapped so that the recording duration is no more than <see cref="recordSeconds"/>. /// </summary> /// <param name="state">The snapshot to store</param> public override void RecordSnapshot(ReplaySnapshot state) { // Register the state states.Add(state); // Create a fixed size wrap around buffer if possible ConstrainBuffer(); }
// Methods /// <summary> /// Store a replay snapshot in the replay target. /// </summary> /// <param name="state">The snapshot to store</param> public abstract void RecordSnapshot(ReplaySnapshot state);