PlayerInventorySaveData.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  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 PlayerInventorySaveData {
  9. public class DataObject {
  10. public string PlayerInventory { get; set; }
  11. }
  12. public string Version { get; set; }
  13. public DataObject Data { get; set; }
  14. protected PlayerInventory? _data = null;
  15. public PlayerInventory? PlayerInventory {
  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<PlayerInventory>(this.Data.PlayerInventory.Replace("\"NaN\"", "0"), options);
  25. }
  26. return this._data;
  27. }
  28. }
  29. }
  30. }