0
0
mirror of https://github.com/sp-tarkov/loot-dump-processor.git synced 2025-02-13 07:10:45 -05:00

Added JSON property name attributes and fixed nullable handling in models

This commit is contained in:
bluextx 2025-01-12 22:13:30 +03:00
parent 5d2c0d04b1
commit 65724da100
3 changed files with 25 additions and 18 deletions

View File

@ -1,11 +1,13 @@
using System.Text.Json.Serialization;
namespace LootDumpProcessor.Model; namespace LootDumpProcessor.Model;
public class GroupPosition : ICloneable public class GroupPosition : ICloneable
{ {
public string Name { get; set; } [JsonPropertyName("Name")] public string Name { get; set; }
public int Weight { get; set; } [JsonPropertyName("Weight")] public int Weight { get; set; }
public Vector3 Position { get; set; } [JsonPropertyName("Position")] public Vector3 Position { get; set; }
public Vector3 Rotation { get; set; } [JsonPropertyName("Rotation")] public Vector3 Rotation { get; set; }
public object Clone() => new GroupPosition public object Clone() => new GroupPosition
{ {

View File

@ -7,24 +7,24 @@ namespace LootDumpProcessor.Model;
public class Template : IKeyable, ICloneable public class Template : IKeyable, ICloneable
{ {
[JsonIgnore] public string internalId { get; } [JsonIgnore] public string InternalId { get; }
public string Id { get; set; } [JsonPropertyName("Id")] public string Id { get; set; }
public bool IsContainer { get; set; } [JsonPropertyName("IsContainer")] public bool IsContainer { get; set; }
public bool UseGravity { get; set; } public bool UseGravity { get; set; }
public bool RandomRotation { get; set; } public bool RandomRotation { get; set; }
public Vector3 Position { get; set; } [JsonPropertyName("Position")] public Vector3 Position { get; set; }
public Vector3 Rotation { get; set; } [JsonPropertyName("Rotation")] public Vector3 Rotation { get; set; }
public bool IsGroupPosition { get; set; } [JsonPropertyName("IsGroupPosition")] public bool IsGroupPosition { get; set; }
public List<GroupPosition> GroupPositions { get; set; } [JsonPropertyName("GroupPositions")] public List<GroupPosition> GroupPositions { get; set; }
public bool IsAlwaysSpawn { get; set; } [JsonPropertyName("IsAlwaysSpawn")] public bool IsAlwaysSpawn { get; set; }
public string Root { get; set; } [JsonPropertyName("Root")] public string Root { get; set; }
public List<Item> Items { get; set; } [JsonPropertyName("Items")] public List<Item> Items { get; set; }
public Template(string internalId, string id, bool isContainer, bool useGravity, bool randomRotation, public Template(string internalId, string id, bool isContainer, bool useGravity, bool randomRotation,
Vector3 position, Vector3 rotation, bool isGroupPosition, List<GroupPosition> groupPositions, Vector3 position, Vector3 rotation, bool isGroupPosition, List<GroupPosition> groupPositions,
bool isAlwaysSpawn, string root, List<Item> items) bool isAlwaysSpawn, string root, List<Item> items)
{ {
this.internalId = internalId; this.InternalId = internalId;
Id = id; Id = id;
IsContainer = isContainer; IsContainer = isContainer;
UseGravity = useGravity; UseGravity = useGravity;
@ -49,11 +49,11 @@ public class Template : IKeyable, ICloneable
public override int GetHashCode() => Id != null ? Id.GetHashCode() : 0; public override int GetHashCode() => Id != null ? Id.GetHashCode() : 0;
public IKey GetKey() => new FlatUniqueKey([internalId]); public IKey GetKey() => new FlatUniqueKey([InternalId]);
public object Clone() => new Template public object Clone() => new Template
( (
internalId, InternalId,
Id, Id,
IsContainer, IsContainer,
UseGravity, UseGravity,

View File

@ -1,5 +1,10 @@
using System.Text.Json.Serialization;
namespace LootDumpProcessor.Model; namespace LootDumpProcessor.Model;
public readonly record struct Upd( public readonly record struct Upd(
object? StackObjectsCount, FireMode FireMode, Foldable Foldable, Repairable Repairable [property: JsonPropertyName("StackObjectsCount")] object? StackObjectsCount,
[property: JsonPropertyName("FireMode")] FireMode? FireMode,
[property: JsonPropertyName("Foldable")] Foldable? Foldable,
[property: JsonPropertyName("Repairable")] Repairable? Repairable
); );