mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-23 20:43:07 +00:00
fc754b346b
[Language Reference](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-10.0/file-scoped-namespaces) Updates all the files, one less level of indentation. Some small changes were made to API surfaces, renaming `PKM pkm` -> `PKM pk`, and `LegalityAnalysis.pkm` -> `LegalityAnalysis.Entity`
38 lines
1.2 KiB
C#
38 lines
1.2 KiB
C#
using System;
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
/// <summary>
|
|
/// Tuple containing data for a <see cref="Slot"/> and the originating <see cref="View"/>
|
|
/// </summary>
|
|
/// <typeparam name="T"></typeparam>
|
|
public sealed class SlotViewInfo<T> : IEquatable<T>
|
|
{
|
|
public readonly ISlotInfo Slot;
|
|
public readonly ISlotViewer<T> 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<T> view)
|
|
{
|
|
Slot = slot;
|
|
View = view;
|
|
}
|
|
|
|
private bool Equals(SlotViewInfo<T> 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<T> other && Equals(other));
|
|
public override int GetHashCode() => (Slot.GetHashCode() * 397) ^ View.GetHashCode();
|
|
bool IEquatable<T>.Equals(T other) => other != null && Equals(other);
|
|
}
|