mirror of
https://github.com/kwsch/PKHeX
synced 2025-02-17 05:48:44 +00:00
In addition to the Method 1 (and other sibling PIDIV types) correlation, an encounter can only be triggered if the calls prior land on the Method {1} seed. The RNG community has dubbed these patterns as "Method J" (D/P/Pt), "Method K" (HG/SS), and "Method H" (Gen3, coined by yours truly). The basic gist of these is that they are pre-requisites, like the Shadow locks of Colosseum/XD. Rename/re-type a bunch of properties to get the codebase more in line with correct property names & more obvious underlying types.
62 lines
1.6 KiB
C#
62 lines
1.6 KiB
C#
namespace PKHeX.Core;
|
|
|
|
/// <summary>
|
|
/// Locks associated to a given NPC PKM that appears before a <see cref="IShadow3"/>.
|
|
/// </summary>
|
|
public readonly record struct NPCLock
|
|
{
|
|
private readonly byte Nature;
|
|
private readonly byte Gender;
|
|
private readonly byte Ratio;
|
|
private readonly byte State;
|
|
private readonly ushort Species;
|
|
|
|
public int FramesConsumed => Seen ? 5 : 7;
|
|
public bool Seen => State > 1;
|
|
public bool Shadow => State != 0;
|
|
public (Nature Nature, byte Gender) GetLock => ((Nature)Nature, Gender);
|
|
|
|
// Not-Shadow
|
|
public NPCLock(ushort s, byte n, byte g, byte r)
|
|
{
|
|
Species = s;
|
|
Nature = n;
|
|
Gender = g;
|
|
Ratio = r;
|
|
}
|
|
|
|
// Shadow
|
|
public NPCLock(ushort s, bool seen = false)
|
|
{
|
|
Species = s;
|
|
State = seen ? (byte)2 : (byte)1;
|
|
}
|
|
|
|
public bool MatchesLock(uint PID)
|
|
{
|
|
if (Shadow && Nature == 0) // Non-locked shadow
|
|
return true;
|
|
if (Gender != 2 && Gender != ((PID & 0xFF) < Ratio ? 1 : 0))
|
|
return false;
|
|
if (Nature != PID % 25)
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
#if DEBUG
|
|
public override string ToString()
|
|
{
|
|
var sb = new System.Text.StringBuilder(64);
|
|
sb.Append((Species)Species);
|
|
if (State != 0)
|
|
sb.Append(" (Shadow)");
|
|
if (Seen)
|
|
sb.Append(" [Seen]");
|
|
sb.Append(" - ");
|
|
sb.Append("Nature: ").Append((Nature)Nature);
|
|
if (Gender != 2)
|
|
sb.Append(", ").Append("Gender: ").Append(Gender);
|
|
return sb.ToString();
|
|
}
|
|
#endif
|
|
}
|