namespace PKHeX.Core
{
///
/// Generation 2 Wild Encounter Slot data
///
///
/// Contains Time data which is present in origin data.
///
public sealed class EncounterSlot2 : EncounterSlot, INumberedSlot
{
public override int Generation => 2;
public int SlotNumber { get; set; }
public int Rate;
internal EncounterTime Time;
public EncounterSlot2(int species, int min, int max, int rate, SlotType type, int slot)
{
Species = species;
LevelMin = min;
LevelMax = max;
Rate = rate;
Type = type;
SlotNumber = slot;
}
///
/// Deserializes Gen2 Encounter Slots from data.
///
/// Byte array containing complete slot data table.
/// Offset to start reading from.
/// Amount of slots to read.
/// Type of encounter slot table.
/// Slot type encounter rate.
/// Array of encounter slots.
public static EncounterSlot2[] ReadSlots(byte[] data, ref int ofs, int count, SlotType type, int rate)
{
var bump = type == SlotType.Surf ? 4 : 0;
var slots = new EncounterSlot2[count];
for (int slot = 0; slot < count; slot++)
{
int min = data[ofs++];
int species = data[ofs++];
int max = min + bump;
slots[slot] = new EncounterSlot2(species, min, max, rate, type, slot);
}
return slots;
}
protected override void ApplyDetails(ITrainerInfo sav, EncounterCriteria criteria, PKM pk)
{
base.ApplyDetails(sav, criteria, pk);
var pk2 = (PK2)pk;
if (Version == GameVersion.C)
pk2.Met_TimeOfDay = Time.RandomValidTime();
}
}
}