NHSE/NHSE.Core/Structures/Map/Layers/LayerRoomItem.cs
Kurt 50ce05af6f stash
rewritten core side to include tons more metadata/structure
need to rewrite renderer to output full map image rather than skipping sea
2026-01-19 01:20:43 -06:00

33 lines
996 B
C#

using System;
using System.Collections.Generic;
namespace NHSE.Core;
public sealed record LayerRoomItem : LayerItem
{
public const int SIZE = Width * Height * Item.SIZE;
private const byte Width = 20;
private const byte Height = 20;
public LayerRoomItem(ReadOnlySpan<byte> data) : this(Item.GetArray(data)) { }
public LayerRoomItem(Item[] tiles) : base(tiles, Width, Height) { }
public static LayerRoomItem[] GetArray(ReadOnlySpan<byte> data)
{
var result = new LayerRoomItem[data.Length / SIZE];
for (int i = 0; i < result.Length; i++)
{
var slice = data.Slice(i * SIZE, SIZE);
result[i] = new LayerRoomItem(slice);
}
return result;
}
public static byte[] SetArray(IReadOnlyList<LayerRoomItem> data)
{
var result = new byte[data.Count * SIZE];
for (int i = 0; i < data.Count; i++)
data[i].DumpAll().CopyTo(result, i * SIZE);
return result;
}
}