PKHeX/PKHeX.Core/Legality/Areas/EncounterArea32.cs
Kurt 734aa33898 Split encounter areas, relocate slot finding to obj
Now logic is reasonably split, and each format of area has its own way
of yielding slots

Too much junk with checking flute boosts or catch combo applicability;
just let the area dictate how slots match.
2019-09-12 23:20:52 -07:00

43 lines
No EOL
1.4 KiB
C#

using System;
namespace PKHeX.Core
{
/// <inheritdoc />
/// <summary>
/// Base encounter class for manually repacked areas
/// </summary>
/// <remarks>
/// Encounter Data is stored in the following format: (u16 Location, n*[u16 Species/Form, u8 Min, u8 Max]), hence the 32bit name
/// </remarks>
public abstract class EncounterArea32 : EncounterArea
{
protected internal void LoadSlots(byte[] areaData)
{
var count = (areaData.Length - 2) / 4;
Location = BitConverter.ToUInt16(areaData, 0);
Slots = new EncounterSlot[count];
for (int i = 0; i < Slots.Length; i++)
{
int ofs = 2 + (i * 4);
ushort SpecForm = BitConverter.ToUInt16(areaData, ofs);
Slots[i] = new EncounterSlot
{
Species = SpecForm & 0x7FF,
Form = SpecForm >> 11,
LevelMin = areaData[ofs + 2],
LevelMax = areaData[ofs + 3],
};
}
foreach (var slot in Slots)
slot.Area = this;
}
protected static EncounterSlot GetPressureSlot(EncounterSlot s, PKM pkm)
{
var max = s.Clone();
max.Permissions.Pressure = true;
max.Form = pkm.AltForm;
return max;
}
}
}