GameStateSaveData.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using SOTF_Struct.Data;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace SOTF_Savegame_Editor.SOTFSave {
  8. public class GameStateSaveData {
  9. public class DataObject {
  10. public string GameState { get; set; }
  11. }
  12. public string Version { get; set; }
  13. public DataObject Data { get; set; }
  14. protected GameState? _data = null;
  15. public GameState? GameState {
  16. get {
  17. if (this._data == null) {
  18. System.Text.Json.JsonSerializerOptions options = new() {
  19. NumberHandling = System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString | System.Text.Json.Serialization.JsonNumberHandling.AllowNamedFloatingPointLiterals,
  20. AllowTrailingCommas = true,
  21. IgnoreReadOnlyFields = true,
  22. IgnoreReadOnlyProperties = true
  23. };
  24. this._data = System.Text.Json.JsonSerializer.Deserialize<GameState>(this.Data.GameState.Replace("\"NaN\"", "0"), options);
  25. }
  26. return this._data;
  27. }
  28. }
  29. }
  30. }