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

56 lines
2.1 KiB
C#
Raw Permalink Normal View History

using System.Text.Json.Serialization;
2023-08-12 19:08:38 +01:00
using LootDumpProcessor.Storage;
using LootDumpProcessor.Utils;
2023-08-12 19:08:38 +01:00
namespace LootDumpProcessor.Model;
public class Template(
string internalId, string? id, bool isContainer, bool? useGravity, bool? randomRotation,
Vector3? position, Vector3? rotation, bool? isGroupPosition, List<GroupPosition>? groupPositions,
bool? isAlwaysSpawn, string? root, List<Item> items
)
: IKeyable, ICloneable
2023-08-12 19:08:38 +01:00
{
[JsonIgnore] public string InternalId { get; } = internalId;
[JsonPropertyName("Id")] public string? Id { get; set; } = id;
[JsonPropertyName("IsContainer")] public bool IsContainer { get; set; } = isContainer;
public bool? UseGravity { get; set; } = useGravity;
public bool? RandomRotation { get; set; } = randomRotation;
[JsonPropertyName("Position")] public Vector3? Position { get; set; } = position;
[JsonPropertyName("Rotation")] public Vector3? Rotation { get; set; } = rotation;
[JsonPropertyName("IsGroupPosition")] public bool? IsGroupPosition { get; set; } = isGroupPosition;
[JsonPropertyName("GroupPositions")] public List<GroupPosition>? GroupPositions { get; set; } = groupPositions;
[JsonPropertyName("IsAlwaysSpawn")] public bool? IsAlwaysSpawn { get; set; } = isAlwaysSpawn;
[JsonPropertyName("Root")] public string? Root { get; set; } = root;
[JsonPropertyName("Items")] public List<Item> Items { get; set; } = items;
private 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;
return obj.GetType() == GetType() && Equals((Template)obj);
}
public override int GetHashCode() => Id != null ? Id.GetHashCode() : 0;
public IKey GetKey() => new FlatUniqueKey([InternalId]);
public object Clone() => new Template
(
InternalId,
Id,
IsContainer,
UseGravity,
RandomRotation,
Position,
Rotation,
IsGroupPosition,
ProcessorUtil.Copy(GroupPositions),
IsAlwaysSpawn,
Root,
ProcessorUtil.Copy(Items)
);
2023-08-12 19:08:38 +01:00
}