using System; namespace V3.Data.Internal { // TODO: once the game state is getting larger, we have to separate the // save game metadata from the game state. /// /// A save game that has a timestamp and a title, and that can store /// the game state. /// [Serializable] public sealed class SaveGame : ISaveGame { /// /// The creation time of this save game in local time. /// public DateTime Timestamp { get; set; } /// /// The compability version of this save game. /// public int Version { get; set; } /// /// The data stored in this save game. /// public GameState GameState { get; set; } /// /// Empty constructor for serialization. /// private SaveGame() { } /// /// Creates a new save game from the given data. /// /// the creation time of the save game /// the compability version of the save game /// the game state to store in the save game internal SaveGame(DateTime timestamp, int version, GameState gameState) { Timestamp = timestamp; Version = version; GameState = gameState; } /// /// Compares this save game object to another save game object based /// on the creation time. /// /// the save game to compare this save game /// with /// a value less than zero if this save game has been saved /// before the given save game, zero if they have been saved at the /// same time and a value greater than zero if the given save game has /// been saved before the given one public int CompareTo(ISaveGame saveGame) { return Timestamp.CompareTo(saveGame.Timestamp); } } }