PKHeX/PKHeX.Core/Saves/Substructures/Gen3/PokeBlock3.cs
Kurt fc754b346b
File scoped namespaces (#3529)
[Language Reference](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-10.0/file-scoped-namespaces)

Updates all the files, one less level of indentation.

Some small changes were made to API surfaces, renaming `PKM pkm` -> `PKM pk`, and `LegalityAnalysis.pkm` -> `LegalityAnalysis.Entity`
2022-06-18 11:04:24 -07:00

40 lines
1.3 KiB
C#

using System;
namespace PKHeX.Core;
public sealed class PokeBlock3
{
public const int SIZE = 7;
private readonly byte[] Data;
public PokeBlock3(byte[] data) => Data = data;
public PokeBlock3Color Color { get => (PokeBlock3Color)Data[0]; set => Data[0] = (byte)value; }
public int Spicy { get => Data[1]; set => Data[1] = (byte)value; }
public int Dry { get => Data[2]; set => Data[2] = (byte)value; }
public int Sweet { get => Data[3]; set => Data[3] = (byte)value; }
public int Bitter { get => Data[4]; set => Data[4] = (byte)value; }
public int Sour { get => Data[5]; set => Data[5] = (byte)value; }
public int Feel { get => Data[6]; set => Data[6] = (byte)value; }
public void Delete()
{
for (int i = 0; i < Data.Length; i++)
Data[i] = 0;
}
public void Maximize(bool create = false)
{
if (Color == 0 && !create)
return;
Spicy = Dry = Sweet = Bitter = Sour = Feel = 255;
Color = PokeBlock3Color.Gold;
}
public void SetBlock(byte[] data, int offset) => Data.CopyTo(data, offset);
public static PokeBlock3 GetBlock(ReadOnlySpan<byte> data, int offset)
{
byte[] result = data.Slice(offset, SIZE).ToArray();
return new PokeBlock3(result);
}
}