2023-06-11 18:12:34 +00:00
|
|
|
using System;
|
|
|
|
using static System.Buffers.Binary.BinaryPrimitives;
|
|
|
|
|
2022-06-19 02:12:41 +00:00
|
|
|
namespace PKHeX.Core;
|
2022-06-18 18:04:24 +00:00
|
|
|
|
|
|
|
public abstract class Encount5 : SaveBlock<SAV5>
|
2021-08-21 02:52:31 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
protected Encount5(SAV5 SAV, int offset) : base(SAV) => Offset = offset;
|
2023-06-11 18:12:34 +00:00
|
|
|
public ushort LastLocation { get => ReadUInt16LittleEndian(Data); set => WriteUInt16LittleEndian(Data, value); }
|
|
|
|
public ushort CaptureUnknown { get => ReadUInt16LittleEndian(Data.AsSpan()[0x02..]); set => WriteUInt16LittleEndian(Data.AsSpan()[0x02..], value); }
|
2021-08-21 02:52:31 +00:00
|
|
|
|
2023-06-11 18:12:34 +00:00
|
|
|
public Roamer5 Roamer1 => new(Data, Offset + 4);
|
|
|
|
public Roamer5 Roamer2 => new(Data, Offset + 4 + Roamer5.SIZE);
|
2022-06-19 02:12:41 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public abstract byte SwarmSeed { get; set; }
|
|
|
|
public abstract uint SwarmMaxCountModulo { get; }
|
2021-08-21 02:52:31 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public uint SwarmIndex
|
|
|
|
{
|
|
|
|
get => SwarmSeed % SwarmMaxCountModulo;
|
|
|
|
set => SwarmSeed = (byte)(value % SwarmMaxCountModulo);
|
2021-08-21 02:52:31 +00:00
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
2021-08-21 02:52:31 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public sealed class Encount5BW : Encount5
|
|
|
|
{
|
|
|
|
public Encount5BW(SAV5BW SAV, int offset) : base(SAV, offset) { }
|
2021-08-21 02:52:31 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public override byte SwarmSeed { get => Data[Offset + 0x30]; set => Data[Offset + 0x30] = value; }
|
|
|
|
public override uint SwarmMaxCountModulo => 17;
|
|
|
|
}
|
2021-08-21 02:52:31 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public sealed class Encount5B2W2 : Encount5
|
|
|
|
{
|
|
|
|
public Encount5B2W2(SAV5B2W2 SAV, int offset) : base(SAV, offset) { }
|
2021-08-21 02:52:31 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public override byte SwarmSeed { get => Data[Offset + 0x2C]; set => Data[Offset + 0x2C] = value; }
|
|
|
|
public override uint SwarmMaxCountModulo => 19;
|
2021-08-21 02:52:31 +00:00
|
|
|
}
|