NHSE/NHSE.Core/Structures/Building/Building.cs
Kurt b88c518d5c
Update FieldItemEditor for 3.0.0 (#716)
Updates the Field Item Editor to render layers based on the entire map, and the per-patch positioning of each layer.
Import/export will gracefully handle upgrade/downgrade, and viewport import/export will gracefully update tiles rather than a per-acre basis.

Performance has also been slightly improved; no allocation is done anymore when updating the image.
2026-01-25 16:55:38 -06:00

54 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace NHSE.Core;
/// <summary>
/// Interact-able structure that can be entered by the player.
/// </summary>
[StructLayout(LayoutKind.Explicit, Size = SIZE, Pack = 1)]
public sealed class Building
{
public const int SIZE = 0x14;
[field: FieldOffset(0x00)] public BuildingType BuildingType { get; set; }
[field: FieldOffset(0x02)] public ushort X { get; set; }
[field: FieldOffset(0x04)] public ushort Y { get; set; }
[field: FieldOffset(0x06)] public byte Angle { get; set; }
[field: FieldOffset(0x07)] public sbyte Bit { get; set; }
[field: FieldOffset(0x08)] public ushort Type { get; set; }
[field: FieldOffset(0x0A)] public byte TypeArg { get; set; }
[field: FieldOffset(0x0C)] public ushort UniqueID { get; set; }
[field: FieldOffset(0x10)] public uint Unused { get; set; }
public void Clear()
{
BuildingType = 0;
X = Y = Angle = 0;
Bit = 0;
Type = TypeArg = 0;
UniqueID = 0;
Unused = 0;
}
public void CopyFrom(Building building)
{
BuildingType = building.BuildingType;
X = building.X;
Y = building.Y;
Angle = building.Angle;
Bit = building.Bit;
Type = building.Type;
TypeArg = building.TypeArg;
UniqueID = building.UniqueID;
Unused = building.Unused;
}
public static Building[] GetArray(ReadOnlySpan<byte> data) => data.GetArray<Building>(SIZE);
public static byte[] SetArray(IReadOnlyList<Building> data) => data.SetArray(SIZE);
public override string ToString() => $"{X:000},{Y:000} - {BuildingType}";
}