chomp
6e4c7abf73
Co-authored-by: Alex <alex@dm-me-for-questions.com> Reviewed-on: SPT-AKI/LootDumpProcessor#6
42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
using System.Text.Json.Serialization;
|
|
using LootDumpProcessor.Model.Processing;
|
|
using LootDumpProcessor.Utils;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace LootDumpProcessor.Model;
|
|
|
|
public class ComposedKey
|
|
{
|
|
[JsonProperty("key")]
|
|
[JsonPropertyName("key")]
|
|
public string Key { get; init; }
|
|
|
|
[Newtonsoft.Json.JsonIgnore]
|
|
[System.Text.Json.Serialization.JsonIgnore]
|
|
public Item? FirstItem { get; }
|
|
|
|
public ComposedKey(Template template) : this(template.Items)
|
|
{
|
|
}
|
|
|
|
public ComposedKey(List<Item>? items)
|
|
{
|
|
Key = items?.Select(i => i.Tpl)
|
|
.Where(i => !string.IsNullOrEmpty(i) &&
|
|
!LootDumpProcessorContext.GetTarkovItems().IsBaseClass(i, BaseClasses.Ammo))
|
|
.Cast<string>()
|
|
.Select(i => (double)i.GetHashCode())
|
|
.Sum()
|
|
.ToString() ?? KeyGenerator.GetNextKey();
|
|
FirstItem = items?[0];
|
|
}
|
|
|
|
public override bool Equals(object? obj)
|
|
{
|
|
if (obj is not ComposedKey key)
|
|
return false;
|
|
return Key == key.Key;
|
|
}
|
|
|
|
public override int GetHashCode() => Key.GetHashCode();
|
|
} |