2018-05-27 21:19:19 +00:00
|
|
|
using System;
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
|
|
|
{
|
2019-10-04 02:09:02 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Generation 5 <see cref="EntreeForest"/> slot
|
|
|
|
/// </summary>
|
|
|
|
public sealed class EntreeSlot
|
2018-05-27 21:19:19 +00:00
|
|
|
{
|
2018-05-28 19:49:41 +00:00
|
|
|
/// <summary>
|
|
|
|
/// <see cref="PKM.Species"/> index
|
|
|
|
/// </summary>
|
2018-05-27 21:19:19 +00:00
|
|
|
public int Species // bits 0-10
|
|
|
|
{
|
2018-05-28 15:26:52 +00:00
|
|
|
get => (int)(RawValue & 0x3FF) >> 0;
|
|
|
|
set => RawValue = (RawValue & 0xFFFF_F800) | ((uint)(value & 0x3FF) << 0);
|
2018-05-27 21:19:19 +00:00
|
|
|
}
|
2018-05-28 19:49:41 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Special Move
|
|
|
|
/// </summary>
|
2018-05-27 21:19:19 +00:00
|
|
|
public int Move // bits 11-20
|
|
|
|
{
|
2018-05-28 15:26:52 +00:00
|
|
|
get => (int)(RawValue & 0x001F_F800) >> 11;
|
2018-05-28 19:49:41 +00:00
|
|
|
set => RawValue = (RawValue & 0xFFE0_07FF) | ((uint)(value & 0x3FF) << 11);
|
2018-05-27 21:19:19 +00:00
|
|
|
}
|
2018-05-28 19:49:41 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <see cref="PKM.Gender"/> index
|
|
|
|
/// </summary>
|
2018-05-27 21:19:19 +00:00
|
|
|
public int Gender // bits 21-22
|
|
|
|
{
|
2018-05-28 15:26:52 +00:00
|
|
|
get => (int)(RawValue & 0x0060_0000) >> 21;
|
|
|
|
set => RawValue = (RawValue & 0xFF9F_FFFF) | ((uint)(value & 0x3) << 21);
|
2018-05-27 21:19:19 +00:00
|
|
|
}
|
2018-05-28 19:49:41 +00:00
|
|
|
|
|
|
|
/// <summary>
|
2020-12-11 04:42:30 +00:00
|
|
|
/// <see cref="PKM.Form"/> index
|
2018-05-28 19:49:41 +00:00
|
|
|
/// </summary>
|
2018-05-27 21:19:19 +00:00
|
|
|
public int Form // bits 23-27
|
|
|
|
{
|
|
|
|
get => (int)(RawValue & 0x0F80_0000) >> 23;
|
2018-05-28 15:26:52 +00:00
|
|
|
set => RawValue = (RawValue & 0xF07F_FFFF) | ((uint)(value & 0x1F) << 23);
|
2018-05-27 21:19:19 +00:00
|
|
|
}
|
2018-05-28 19:49:41 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Visibility Flag
|
|
|
|
/// </summary>
|
2018-05-27 21:19:19 +00:00
|
|
|
public bool Invisible // bit 28
|
|
|
|
{
|
|
|
|
get => ((RawValue >> 28) & 1) == 1;
|
|
|
|
set => RawValue = (RawValue & 0xEFFFFFFF) | (value ? 0 : 1u << 28);
|
|
|
|
}
|
2018-05-28 19:49:41 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Animation Leash (How many steps it can deviate from its spawn location).
|
|
|
|
/// </summary>
|
2018-05-27 21:19:19 +00:00
|
|
|
public int Animation // bits 29-31
|
|
|
|
{
|
|
|
|
get => (int)(RawValue >> 29);
|
2018-05-28 15:26:52 +00:00
|
|
|
set => RawValue = (RawValue << 3) >> 3 | (uint)((value & 0x7) << 29);
|
2018-05-27 21:19:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private readonly byte[] Data;
|
|
|
|
private readonly int Offset;
|
|
|
|
|
2018-05-28 19:49:41 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Raw Data Value
|
|
|
|
/// </summary>
|
2018-05-27 21:19:19 +00:00
|
|
|
public uint RawValue
|
|
|
|
{
|
|
|
|
get => BitConverter.ToUInt32(Data, Offset);
|
|
|
|
set => BitConverter.GetBytes(value).CopyTo(Data, Offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Delete() => RawValue = 0;
|
|
|
|
|
2020-12-22 01:48:08 +00:00
|
|
|
public EntreeForestArea Area { get; init; }
|
2018-05-27 21:19:19 +00:00
|
|
|
|
|
|
|
public EntreeSlot(byte[] data, int ofs)
|
|
|
|
{
|
|
|
|
Data = data;
|
|
|
|
Offset = ofs;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|