private void InitializeTimelines() { _replayReader.GetStream().Position = 0; // First of all, the header must be read, to get the timelinecounts and meta informations ReplayMetaHeader = new ReplayMetaHeader(); ReplayMetaHeader.ReadFrame(_replayReader); _playRate = ReplayMetaHeader.Hz; if (ReplayManager.Instance.version != ReplayMetaHeader.Version) { Debug.LogWarning("Version of Replay not equal"); } // Timelines init and assign the timelines headers to them Timelines = new ReplayTimeline[ReplayMetaHeader.TimelineCount]; var sizeOfPreviousContent = 0; for (var i = 0; i < Timelines.Length; i++) { var replayTimelineHeader = new ReplayMetaTimelineHeader(); // Read Headerdata from Replay replayTimelineHeader.ReadFrame(_replayReader); // Read Snapshot/Delta Positions in Stream with Offset sizeOfPreviousContent replayTimelineHeader.ReadSnapshotPointers(_replayReader, ReplayMetaHeader.SizeInBytes + replayTimelineHeader.SizeInBytes + sizeOfPreviousContent); // Dont add Timelineparent to 255 byte number == no timeline if (replayTimelineHeader.TimelineInheritance < 255) { replayTimelineHeader.ReplayPointer.AddParentFrames(Timelines[replayTimelineHeader.TimelineInheritance], replayTimelineHeader.StartFromFrame); } // Initialize Timelines Timelines[i] = new ReplayTimeline(ReplayMetaHeader, replayTimelineHeader, _replayReader, i); _replayReader.GetStream().Position = replayTimelineHeader.ReplayPointer.GetLastEndingPosition.Index; sizeOfPreviousContent = replayTimelineHeader.ReplayPointer.GetLastEndingPosition.Index - ReplayMetaHeader.SizeInBytes; } CurrentReplayTimeline = Timelines[0]; CurrentReplayTimeline.CurrentFramePlayer = CurrentReplayTimeline.ReplaySnapshotPlayer; _replayReader.GetStream().Position = CurrentReplayTimeline.MetaTimelineHeader.ReplayPointer.GetFirstStartingPosition.Index; }
public void AddParentFrames(ReplayTimeline parentTimeline, int fromFrame) { _replayPositionsInStream.InsertRange(0, parentTimeline.MetaTimelineHeader.ReplayPointer.GetEntries().GetRange(0, fromFrame)); }