70 lines
1.5 KiB
C#
70 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace LLib.Gear;
|
|
|
|
public sealed record EquipmentStats(Dictionary<EBaseParam, StatInfo> Stats, byte MateriaCount)
|
|
{
|
|
public short Get(EBaseParam param)
|
|
{
|
|
return (short)(GetEquipment(param) + GetMateria(param));
|
|
}
|
|
|
|
public short GetEquipment(EBaseParam param)
|
|
{
|
|
Stats.TryGetValue(param, out StatInfo value);
|
|
return value?.EquipmentValue ?? 0;
|
|
}
|
|
|
|
public short GetMateria(EBaseParam param)
|
|
{
|
|
Stats.TryGetValue(param, out StatInfo value);
|
|
return value?.MateriaValue ?? 0;
|
|
}
|
|
|
|
public bool IsOvercapped(EBaseParam param)
|
|
{
|
|
Stats.TryGetValue(param, out StatInfo value);
|
|
return value?.Overcapped ?? false;
|
|
}
|
|
|
|
public bool Has(EBaseParam substat)
|
|
{
|
|
return Stats.ContainsKey(substat);
|
|
}
|
|
|
|
public bool HasMateria()
|
|
{
|
|
return Stats.Values.Any((StatInfo x) => x.MateriaValue > 0);
|
|
}
|
|
|
|
public bool Equals(EquipmentStats? other)
|
|
{
|
|
if (other == null || MateriaCount != other.MateriaCount || Stats.Count != other.Stats.Count)
|
|
{
|
|
return false;
|
|
}
|
|
foreach (var (key, objA) in Stats)
|
|
{
|
|
if (!other.Stats.TryGetValue(key, out StatInfo value) || !object.Equals(objA, value))
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
int num = MateriaCount.GetHashCode();
|
|
foreach (KeyValuePair<EBaseParam, StatInfo> stat in Stats)
|
|
{
|
|
stat.Deconstruct(out var key, out var value);
|
|
EBaseParam value2 = key;
|
|
StatInfo value3 = value;
|
|
num ^= HashCode.Combine(value2, value3);
|
|
}
|
|
return num;
|
|
}
|
|
}
|