0
0
mirror of https://github.com/sp-tarkov/assembly-tool.git synced 2025-02-12 14:50:44 -05:00

Fix item.json loading

This commit is contained in:
Cj 2025-01-11 13:11:07 -05:00
parent de0b632426
commit 2589d0d3bc
3 changed files with 20 additions and 7 deletions

View File

@ -1,9 +1,12 @@
namespace ReCodeItLib.Models;
using System.Text.Json.Serialization;
namespace ReCodeItLib.Models;
public class ItemTemplateModel
{
public string? _id;
public string? _name;
public string? _parent;
public string? _type;
[JsonPropertyName("_id")]
public string? Id { get; set; }
[JsonPropertyName("_name")]
public string? Name { get; set; }
}

View File

@ -274,10 +274,12 @@ public class ReMapper
var remap = new RemapModel
{
OriginalTypeName = type.Value.Name,
NewTypeName = $"{template._name}{extName}",
NewTypeName = $"{template.Name}{extName}",
UseForceRename = true
};
Logger.LogSync($"{type.Value.Name} -> {template.Name}{extName}");
_remaps.Add(remap);
}
}

View File

@ -1,7 +1,9 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using dnlib.DotNet;
using Newtonsoft.Json;
using ReCodeItLib.Models;
using JsonSerializer = System.Text.Json.JsonSerializer;
namespace ReCodeItLib.Utils;
@ -92,6 +94,12 @@ public static class DataProvider
var itemsPath = Path.Combine(DataPath, "items.json");
var jsonText = File.ReadAllText(itemsPath);
return JsonSerializer.Deserialize<Dictionary<string, ItemTemplateModel>>(jsonText)!;
JsonSerializerOptions settings = new()
{
RespectNullableAnnotations = true,
PropertyNameCaseInsensitive = true
};
return JsonSerializer.Deserialize<Dictionary<string, ItemTemplateModel>>(jsonText, settings)!;
}
}