mirror of
https://github.com/kwsch/PKHeX
synced 2024-12-22 18:33:14 +00:00
950ddcf9fd
24 bytes per object -> 16 bytes 2,624 objects are made for legality checking; reduces from 73KB to 41KB removing unnecessary clone recreation -> count from 2624 -> 414 (41KB to 6.6KB) yay 10x reduction; not huge in the big picture but a fun exercise
44 lines
No EOL
1.1 KiB
C#
44 lines
No EOL
1.1 KiB
C#
namespace PKHeX.Core
|
|
{
|
|
/// <summary>
|
|
/// Locks associated to a given NPC PKM that appears before a <see cref="EncounterStaticShadow"/>.
|
|
/// </summary>
|
|
public sealed class NPCLock
|
|
{
|
|
public readonly short Species;
|
|
public readonly byte Nature;
|
|
public readonly byte Gender;
|
|
public readonly byte Ratio;
|
|
public readonly bool Shadow;
|
|
public readonly bool Seen;
|
|
|
|
public NPCLock(short s, byte n, byte g, byte r)
|
|
{
|
|
Species = s;
|
|
Nature = n;
|
|
Gender = g;
|
|
Ratio = r;
|
|
}
|
|
|
|
public NPCLock(short s, bool seen = false)
|
|
{
|
|
Species = s;
|
|
Nature = 25;
|
|
Shadow = true;
|
|
Seen = seen;
|
|
}
|
|
|
|
public bool MatchesLock(uint PID)
|
|
{
|
|
if (Shadow)
|
|
return true;
|
|
if (Gender != 2 && Gender != ((PID & 0xFF) < Ratio ? 1 : 0))
|
|
return false;
|
|
if (Nature != PID % 25)
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
internal NPCLock Clone() => (NPCLock)MemberwiseClone();
|
|
}
|
|
} |