2018-07-08 07:26:31 +00:00
|
|
|
|
using System;
|
2022-01-03 05:35:59 +00:00
|
|
|
|
using static System.Buffers.Binary.BinaryPrimitives;
|
2018-07-08 07:26:31 +00:00
|
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
|
|
|
|
{
|
2019-10-04 02:09:02 +00:00
|
|
|
|
public sealed class SecretBase3
|
2018-07-08 07:26:31 +00:00
|
|
|
|
{
|
|
|
|
|
private readonly byte[] Data;
|
|
|
|
|
private readonly int Offset;
|
|
|
|
|
private bool Japanese => Language == (int) LanguageID.Japanese;
|
|
|
|
|
|
|
|
|
|
public SecretBase3(byte[] data, int offset)
|
|
|
|
|
{
|
|
|
|
|
Data = data;
|
|
|
|
|
Offset = offset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int SecretBaseLocation { get => Data[Offset + 0]; set => Data[Offset + 0] = (byte) value; }
|
2018-09-15 05:37:47 +00:00
|
|
|
|
|
2018-07-08 07:26:31 +00:00
|
|
|
|
public int OT_Gender
|
|
|
|
|
{
|
|
|
|
|
get => (Data[Offset + 1] >> 4) & 1;
|
|
|
|
|
set => Data[Offset + 1] = (byte) ((Data[Offset + 1] & 0xEF) | (value & 1) << 4);
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-06 17:53:13 +00:00
|
|
|
|
public bool BattledToday
|
|
|
|
|
{
|
|
|
|
|
get => ((Data[Offset + 1] >> 5) & 1) == 1;
|
|
|
|
|
set => Data[Offset + 1] = (byte)((Data[Offset + 1] & 0xDF) | (value ? 1 : 0) << 5);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int RegistryStatus
|
|
|
|
|
{
|
|
|
|
|
get => (Data[Offset + 1] >> 6) & 3;
|
|
|
|
|
set => Data[Offset + 1] = (byte)((Data[Offset + 1] & 0x3F) | (value & 3) << 6);
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-08 07:26:31 +00:00
|
|
|
|
public string OT_Name
|
|
|
|
|
{
|
2022-01-03 05:35:59 +00:00
|
|
|
|
get => StringConverter3.GetString(Data.AsSpan(Offset + 2, 7), Japanese);
|
|
|
|
|
set => StringConverter3.SetString(Data.AsSpan(Offset + 2, 7), value.AsSpan(), 7, Japanese, StringConverterOption.ClearFF);
|
2018-07-08 07:26:31 +00:00
|
|
|
|
}
|
2018-09-15 05:37:47 +00:00
|
|
|
|
|
2018-07-08 07:26:31 +00:00
|
|
|
|
public uint OT_ID
|
|
|
|
|
{
|
2022-01-03 05:35:59 +00:00
|
|
|
|
get => ReadUInt32LittleEndian(Data.AsSpan(Offset + 9));
|
|
|
|
|
set => WriteUInt32LittleEndian(Data.AsSpan(Offset + 9), value);
|
2018-07-08 07:26:31 +00:00
|
|
|
|
}
|
2018-09-15 05:37:47 +00:00
|
|
|
|
|
2020-03-13 17:28:50 +00:00
|
|
|
|
public int OT_Class => Data[Offset + 9] % 5;
|
2018-07-08 07:26:31 +00:00
|
|
|
|
public int Language { get => Data[Offset + 0x0D]; set => Data[Offset + 0x0D] = (byte)value; }
|
2020-09-06 17:53:13 +00:00
|
|
|
|
|
|
|
|
|
public ushort SecretBasesReceived
|
|
|
|
|
{
|
2022-01-03 05:35:59 +00:00
|
|
|
|
get => ReadUInt16LittleEndian(Data.AsSpan(Offset + 0x0E));
|
|
|
|
|
set => WriteUInt16LittleEndian(Data.AsSpan(Offset + 0x0E), value);
|
2020-09-06 17:53:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public byte TimesEntered { get => Data[Offset + 0x10]; set => Data[Offset + 0x10] = value; }
|
|
|
|
|
public int Unused11 { get => Data[Offset + 0x11]; set => Data[Offset + 0x11] = (byte)value; } // alignment padding
|
2018-07-08 07:26:31 +00:00
|
|
|
|
|
2020-12-05 14:09:33 +00:00
|
|
|
|
public byte[] GetDecorations() => Data.Slice(Offset + 0x12, 0x10);
|
|
|
|
|
public void SetDecorations(byte[] value) => value.CopyTo(Data, Offset + 0x12);
|
2018-09-15 05:37:47 +00:00
|
|
|
|
|
2020-12-05 14:09:33 +00:00
|
|
|
|
public byte[] GetDecorationCoordinates() => Data.Slice(Offset + 0x22, 0x10);
|
|
|
|
|
public void SetDecorationCoordinates(byte[] value) => value.CopyTo(Data, Offset + 0x22);
|
2018-07-08 07:26:31 +00:00
|
|
|
|
|
|
|
|
|
public SecretBase3Team Team
|
|
|
|
|
{
|
2020-12-22 01:17:56 +00:00
|
|
|
|
get => new(Data.Slice(Offset + 50, 72));
|
2018-07-08 07:26:31 +00:00
|
|
|
|
set => value.Write().CopyTo(Data, Offset + 50);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int TID
|
|
|
|
|
{
|
|
|
|
|
get => (ushort)OT_ID;
|
|
|
|
|
set => OT_ID = (ushort)(SID | (ushort)value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int SID
|
|
|
|
|
{
|
|
|
|
|
get => (ushort)OT_ID >> 8;
|
|
|
|
|
set => OT_ID = (ushort)(((ushort)value << 16) | TID);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|