Tile changes
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
using DataServer.Data.Entities;
|
||||
using Server.Game.Dungeon;
|
||||
|
||||
namespace Server.Game.Dungeon
|
||||
{
|
||||
/// <summary>
|
||||
/// Extended room with template info
|
||||
/// </summary>
|
||||
public class DungeonRoomV2 : DungeonRoom
|
||||
{
|
||||
public int? TemplateId { get; set; }
|
||||
public string? TemplateName { get; set; }
|
||||
public HashSet<string> TemplateTags { get; set; } = new(StringComparer.OrdinalIgnoreCase);
|
||||
public new RoomType Type { get; set; } = RoomType.Normal;
|
||||
|
||||
/// <summary>Connection points parsed from template</summary>
|
||||
public List<ConnectionPoint> ConnectionPoints { get; set; } = new();
|
||||
|
||||
public DungeonRoomV2(int x, int y, int width, int height) : base(x, y, width, height) { }
|
||||
|
||||
/// <summary>Get the best connection point for a given direction</summary>
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>Get world position of a connection point</summary>
|
||||
public (int X, int Y) GetConnectionWorldPos(ConnectionPoint cp)
|
||||
{
|
||||
return (X + cp.X, Y + cp.Y);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user