PKHeX/PKHeX.Core/Legality/Evolutions/EvoCriteria.cs
Kurt ef3cb34387
Refactor EvoCriteria to be a struct, reduce allocation (#3483)
* Make EvolutionCriteria struct

8 bytes per object instead of 26
Unify LevelMin/LevelMax to match EncounterTemplate
bubble up precise array type for better iteration

* Inline queue operations, less allocation

* Inline some logic

* Update EvolutionChain.cs

* Improve clarity on duplicate move check

* Search reverse

For a dual stage chain, finds it first iteration rather than second.
2022-04-23 21:33:17 -07:00

16 lines
528 B
C#

namespace PKHeX.Core;
public readonly record struct EvoCriteria : IDexLevel
{
public ushort Species { get; init; }
public byte Form { get; init; }
public byte LevelUpRequired { get; init; }
public byte LevelMax { get; init; }
public byte LevelMin { get; init; }
public EvolutionType Method { get; init; }
public bool RequiresLvlUp => LevelUpRequired != 0;
public override string ToString() => $"{(Species) Species}{(Form != 0 ? $"-{Form}" : "")}}} [{LevelMin},{LevelMax}] via {Method}";
}