using DataServer.Data.Entities;
using Server.Game.Dungeon;
namespace Server.Game.Dungeon
{
///
/// Extended room with template info
///
public class DungeonRoomV2 : DungeonRoom
{
public int? TemplateId { get; set; }
public string? TemplateName { get; set; }
public HashSet TemplateTags { get; set; } = new(StringComparer.OrdinalIgnoreCase);
public new RoomType Type { get; set; } = RoomType.Normal;
/// Connection points parsed from template
public List ConnectionPoints { get; set; } = new();
public DungeonRoomV2(int x, int y, int width, int height) : base(x, y, width, height) { }
/// Get the best connection point for a given direction
public ConnectionPoint? GetConnectionPoint(string direction)
{
// First try exact match
var exact = ConnectionPoints.FirstOrDefault(c => c.Direction.Equals(direction, StringComparison.OrdinalIgnoreCase));
if (exact != null) return exact;
// No exact match - create a default one for this direction rather than using wrong direction
// This ensures the connection point is actually on the correct edge
return direction.ToLower() switch
{
"north" => new ConnectionPoint { X = Width / 2, Y = 0, Direction = "north", Width = 3 },
"south" => new ConnectionPoint { X = Width / 2, Y = Height - 1, Direction = "south", Width = 3 },
"east" => new ConnectionPoint { X = Width - 1, Y = Height / 2, Direction = "east", Width = 3 },
"west" => new ConnectionPoint { X = 0, Y = Height / 2, Direction = "west", Width = 3 },
_ => ConnectionPoints.FirstOrDefault() // Last resort fallback
};
}
/// Get world position of a connection point
public (int X, int Y) GetConnectionWorldPos(ConnectionPoint cp)
{
return (X + cp.X, Y + cp.Y);
}
}
}