PKHeX/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot3Swarm.cs
Kurt 6441bdadd8
Add specialized struct for Moveset and IV specs (#3572)
`Moveset` struct stores 4 moves, and exposes methods to interact with a moveset.
`IndividualValueSet` stores a 6 IV template (signed).

Performance impact:
* Less allocating on the heap: Moves - (8 bytes member ptr, 20 bytes heap->8 bytes member)
* Less allocating on the heap: IVs - (8 bytes member ptr, 28 bytes heap->8 bytes member)
* No heap pointers, no need to jump to grab data.
* Easy to inline logic for checking if moves are present (no linq usage with temporary collections).

End result is faster ctor times, less memory used, faster program.
2022-08-21 17:34:32 -07:00

22 lines
756 B
C#

namespace PKHeX.Core;
/// <summary>
/// Encounter Slot found in <see cref="GameVersion.RSE"/>.
/// </summary>
/// <remarks>
/// Handled differently as these slots have fixed moves that are different from their normal level-up moves.
/// </remarks>
/// <inheritdoc cref="EncounterSlot"/>
internal sealed record EncounterSlot3Swarm : EncounterSlot3, IMoveset
{
public Moveset Moves { get; }
public EncounterSlot3Swarm(EncounterArea3 area, ushort species, byte min, byte max, byte slot,
Moveset moves) : base(area, species, 0, min, max, slot, 0, 0, 0, 0) => Moves = moves;
protected override void SetEncounterMoves(PKM pk, GameVersion version, int level)
{
pk.SetMoves(Moves);
pk.SetMaximumPPCurrent(Moves);
}
}