botw-toolset/IO/EXTM/Grass.cs
Chev a1a83285f8 Migrate from .NET Framework 4.8 to .NET 5
Also compress Resources/Icons image files, and remove unused entry in App.xaml
2021-01-18 23:33:46 -08:00

51 lines
1.6 KiB
C#

using System.IO;
namespace BOTWToolset.IO.EXTM
{
/// <summary>
/// Interacts with grass data in an .extm file, used in conjunction with <see cref="TSCB.TSCB"/>.
/// More info found on the <see href="https://zeldamods.org/wiki/Grass.extm">ZeldaMods wiki</see>.
/// </summary>
class Grass
{
public byte Height { get => _height; set => _height = value; }
private byte _height;
public byte R { get => _r; set => _r = value; }
private byte _r;
public byte G { get => _g; set => _g = value; }
private byte _g;
public byte B { get => _b; set => _b = value; }
private byte _b;
/// <summary>
/// Gets an array of <see cref="Grass"/> from an array of bytes.
/// </summary>
/// <param name="bytes">The array of bytes to retrieve <see cref="Grass"/> data from.</param>
/// <returns><see cref="Grass"/>[] data.</returns>
public static Grass[] FromBytes(byte[] bytes)
{
using (var r = new BinaryReaderBig(new MemoryStream(bytes)))
{
Grass[] grasses = new Grass[r.BaseStream.Length / 4];
for (int i = 0; i < grasses.Length; i++)
{
Grass g = new Grass
{
Height = r.ReadByte(),
R = r.ReadByte(),
G = r.ReadByte(),
B = r.ReadByte()
};
grasses[i] = g;
}
return grasses;
}
}
}
}