2017-04-23 16:18:42 +00:00
|
|
|
|
namespace PKHeX.Core
|
|
|
|
|
{
|
2021-03-14 18:28:46 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Stores details about a <see cref="PKM.EncryptionConstant"/> (PID) and any associated details being traced to a known correlation.
|
|
|
|
|
/// </summary>
|
2021-08-22 01:24:38 +00:00
|
|
|
|
public readonly struct PIDIV
|
2017-04-23 16:18:42 +00:00
|
|
|
|
{
|
2021-01-28 00:52:04 +00:00
|
|
|
|
internal static readonly PIDIV None = new();
|
|
|
|
|
internal static readonly PIDIV CuteCharm = new(PIDType.CuteCharm);
|
|
|
|
|
internal static readonly PIDIV Pokewalker = new(PIDType.Pokewalker);
|
|
|
|
|
internal static readonly PIDIV G5MGShiny = new(PIDType.G5MGShiny);
|
2017-04-23 16:18:42 +00:00
|
|
|
|
|
|
|
|
|
/// <summary> The RNG seed which immediately generates the PIDIV (starting with PID or IVs, whichever comes first). </summary>
|
2021-01-28 00:52:04 +00:00
|
|
|
|
public readonly uint OriginSeed;
|
2017-04-29 23:22:32 +00:00
|
|
|
|
|
2017-06-30 02:32:29 +00:00
|
|
|
|
/// <summary> Indicates that there is no <see cref="OriginSeed"/> to refer to. </summary>
|
|
|
|
|
/// <remarks> Some PIDIVs may be generated without a single seed, but may follow a traceable pattern. </remarks>
|
2021-08-22 01:24:38 +00:00
|
|
|
|
public bool NoSeed => Type is PIDType.None or PIDType.CuteCharm or PIDType.Pokewalker or PIDType.G5MGShiny;
|
2017-04-30 03:04:54 +00:00
|
|
|
|
|
2017-04-29 23:22:32 +00:00
|
|
|
|
/// <summary> Type of PIDIV correlation </summary>
|
2021-01-28 00:52:04 +00:00
|
|
|
|
public readonly PIDType Type;
|
|
|
|
|
|
2021-08-22 01:24:38 +00:00
|
|
|
|
private PIDIV(PIDType type)
|
2021-01-28 00:52:04 +00:00
|
|
|
|
{
|
2021-08-22 01:24:38 +00:00
|
|
|
|
OriginSeed = 0;
|
2021-01-28 00:52:04 +00:00
|
|
|
|
Type = type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public PIDIV(PIDType type, uint seed)
|
|
|
|
|
{
|
|
|
|
|
OriginSeed = seed;
|
|
|
|
|
Type = type;
|
|
|
|
|
}
|
2021-08-22 01:24:38 +00:00
|
|
|
|
|
|
|
|
|
public bool Equals(PIDIV pid) => pid.Type == Type && pid.OriginSeed == OriginSeed;
|
|
|
|
|
public override bool Equals(object pid) => pid is PIDIV p && Equals(p);
|
|
|
|
|
public override int GetHashCode() => 0;
|
|
|
|
|
public static bool operator ==(PIDIV left, PIDIV right) => left.Equals(right);
|
|
|
|
|
public static bool operator !=(PIDIV left, PIDIV right) => !(left == right);
|
|
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
|
public override string ToString() => NoSeed ? Type.ToString() : $"{Type} - 0x{OriginSeed:X8}";
|
|
|
|
|
#endif
|
2017-04-23 16:18:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|