using System;
namespace PKHeX.Core;
///
/// Tuple containing data for a and the originating
///
///
public sealed class SlotViewInfo : IEquatable
{
public readonly ISlotInfo Slot;
public readonly ISlotViewer View;
public PKM ReadCurrent() => Slot.Read(View.SAV);
public bool CanWriteTo() => Slot.CanWriteTo(View.SAV);
public WriteBlockedMessage CanWriteTo(PKM pk) => Slot.CanWriteTo(View.SAV, pk);
public SlotViewInfo(ISlotInfo slot, ISlotViewer view)
{
Slot = slot;
View = view;
}
private bool Equals(SlotViewInfo other)
{
if (other.View.SAV != View.SAV)
return false;
if (other.View.ViewIndex != View.ViewIndex)
return false;
if (other.Slot.Slot != Slot.Slot)
return false;
return other.Slot.GetType() == Slot.GetType();
}
public override bool Equals(object obj) => ReferenceEquals(this, obj) || (obj is SlotViewInfo other && Equals(other));
public override int GetHashCode() => (Slot.GetHashCode() * 397) ^ View.GetHashCode();
bool IEquatable.Equals(T other) => other != null && Equals(other);
}