Advertisement
Guest User

savegamedata

a guest
Jul 2nd, 2015
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.21 KB | None | 0 0
  1. /// <summary>
  2. /// Represents a loadable save game in memory.
  3. /// </summary>
  4. [Serializable]
  5. public class SaveGameData
  6. {
  7.     /// <summary>
  8.     /// Initializes the arbitrary progression data.
  9.     /// </summary>
  10.     /// <param name="numVars">The number of persistent script variables that should be stored.</param>
  11.     /// <param name="numFlags">The number of persistent script flags that should be stored.</param>
  12.     public SaveGameData(int numVars = 0x800, int numFlags = 0x1000)
  13.     {
  14.         PersistentVars = new int[numVars];
  15.         Flags = new bool[numFlags];
  16.     }
  17.  
  18.     // TODO: Player position, inventory, etc.
  19.  
  20.     // Arbitrary progression data
  21.     public int[] PersistentVars;
  22.     public bool[] Flags;
  23.  
  24.     /// <summary>
  25.     /// Creates a new instance of SaveGameData that contains identical data.
  26.     /// </summary>
  27.     public SaveGameData Clone()
  28.     {
  29.         SaveGameData clone = new SaveGameData(PersistentVars.Length, Flags.Length);
  30.  
  31.         for (int var = 0; var < PersistentVars.Length; var++)
  32.             clone.PersistentVars[var] = PersistentVars[var];
  33.  
  34.         for (int flag = 0; flag < Flags.Length; flag++)
  35.             clone.Flags[flag] = Flags[flag];
  36.  
  37.         return clone;
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement