0
0
mirror of https://github.com/sp-tarkov/loot-dump-processor.git synced 2025-02-13 09:50:44 -05:00
bluextx 465ad95cb5 Refactored code to use System.Text.Json and improved code style
The changes include:
- Replaced Newtonsoft.Json with System.Text.Json for serialization
- Removed redundant JsonProperty attributes and simplified model classes
- Converted static fields to constants where appropriate
- Improved code formatting and readability
- Simplified method bodies and expressions
- Removed unused imports and cleaned up namespaces
2025-01-11 10:52:23 +03:00

76 lines
1.7 KiB
C#

using System.Text.Json.Serialization;
using LootDumpProcessor.Storage;
using LootDumpProcessor.Utils;
namespace LootDumpProcessor.Model;
public class Template : IKeyable, ICloneable
{
[JsonIgnore] public string __ID { get; } = KeyGenerator.GetNextKey();
public string? Id { get; set; }
public bool? IsContainer { get; set; }
public bool? UseGravity { get; set; }
public bool? RandomRotation { get; set; }
public Vector3? Position { get; set; }
public Vector3? Rotation { get; set; }
public bool? IsGroupPosition { get; set; }
public List<GroupPosition>? GroupPositions { get; set; }
public bool? IsAlwaysSpawn { get; set; }
public string? Root { get; set; }
public required List<Item> Items { get; set; }
protected bool Equals(Template other) => Id == other.Id;
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != GetType()) return false;
return Equals((Template)obj);
}
public override int GetHashCode() => Id != null ? Id.GetHashCode() : 0;
public IKey GetKey()
{
return new FlatUniqueKey(new[] { __ID });
}
public object Clone() => new Template
{
Id = Id,
IsContainer = IsContainer,
UseGravity = UseGravity,
RandomRotation = RandomRotation,
Position = ProcessorUtil.Copy(Position),
Rotation = ProcessorUtil.Copy(Rotation),
IsGroupPosition = IsGroupPosition,
GroupPositions = ProcessorUtil.Copy(GroupPositions),
IsAlwaysSpawn = IsAlwaysSpawn,
Root = Root,
Items = ProcessorUtil.Copy(Items)
};
}