2019-06-09 02:56:11 +00:00
|
|
|
|
using System;
|
2022-01-03 05:35:59 +00:00
|
|
|
|
using static System.Buffers.Binary.BinaryPrimitives;
|
2019-06-09 02:56:11 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
|
|
|
|
|
|
public sealed class PWTBlock5 : SaveBlock<SAV5B2W2>
|
2019-06-09 02:56:11 +00:00
|
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public PWTBlock5(SAV5B2W2 sav, int offset) : base(sav) => Offset = offset;
|
2019-06-09 02:56:11 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public ushort GetPWTRecord(int id) => GetPWTRecord((PWTRecordID)id);
|
2019-06-09 02:56:11 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public ushort GetPWTRecord(PWTRecordID id)
|
|
|
|
|
{
|
|
|
|
|
if (id is < PWTRecordID.Normal or > PWTRecordID.MixMaster)
|
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(id));
|
|
|
|
|
int ofs = Offset + 0x5C + ((int)id * 2);
|
|
|
|
|
return ReadUInt16LittleEndian(Data.AsSpan(ofs));
|
|
|
|
|
}
|
2019-06-09 02:56:11 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public void SetPWTRecord(int id, ushort value) => SetPWTRecord((PWTRecordID)id, value);
|
2019-06-09 02:56:11 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public void SetPWTRecord(PWTRecordID id, ushort value)
|
|
|
|
|
{
|
|
|
|
|
if (id is < PWTRecordID.Normal or > PWTRecordID.MixMaster)
|
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(id));
|
|
|
|
|
int ofs = Offset + 0x5C + ((int)id * 2);
|
|
|
|
|
WriteUInt16LittleEndian(Data.AsSpan(ofs), value);
|
2019-06-09 02:56:11 +00:00
|
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
|
}
|