TigerEmu/Game/Rooms/RoomModel.cs

41 lines
1.2 KiB
C#

using Tiger.Game.Rooms.Mapping.Tiles;
namespace Tiger.Game.Rooms;
public class RoomModel
{
public virtual int Id { get; set; }
public virtual string Name { get; set; } = null!;
public virtual int DoorX { get; set; }
public virtual int DoorY { get; set; }
public virtual int DoorDirection { get; set; }
public virtual string Heightmap { get; set; } = null!;
public virtual (int X, int Y) MapSize { get; set; }
public virtual RoomTile[,] RoomTiles { get; set; }
public virtual void Parse()
{
var raw = Heightmap.Replace("\r\n", "\r").Split('\r');
MapSize = (raw[0].Length, raw.Length);
RoomTiles = new RoomTile[MapSize.X, MapSize.Y];
for (var y = 0; y < MapSize.Y; y++)
{
for (var x = 0; x < MapSize.X; x++)
{
if (double.TryParse(raw[y][x].ToString(), out var height))
{
RoomTiles[x, y] = new RoomTile(x, y, height, RoomTileState.Empty);
}
else
{
RoomTiles[x, y] = new RoomTile(x, y, 0, RoomTileState.Unavailable);
}
}
}
}
}