private void SaveSnapshot() { Snapshot newSnapshot = new Snapshot (currentTime); bool appendSnapshot = currentSnapshotIndex + 1 < Snapshots.Count; if (appendSnapshot) newSnapshot = Snapshots[currentSnapshotIndex]; Snapshot fullSnapshot = new Snapshot (currentTime); foreach (GameObject gameObject in Input) { fullSnapshot.GameObjects.Add (gameObject.ID, gameObject.HardCopy()); if (HasObjectChanged (gameObject, lastFull)) { newSnapshot.GameObjects.Add (gameObject.ID, fullSnapshot.GameObjects[gameObject.ID]); } } // Save the snapshots this.lastFull = fullSnapshot; if (newSnapshot.GameObjects.Count > 0 && !appendSnapshot) { Snapshots.Add (newSnapshot); } }
private bool HasObjectChanged(GameObject gameObject, Snapshot full) { // No previous snapshot so it obviously changed if (full == null || !full.GameObjects.ContainsKey(gameObject.ID)) return true; var oldObject = full.GameObjects[gameObject.ID]; if (gameObject.Translation != oldObject.Translation) return true; return false; }