67 lines
2.6 KiB
C#
67 lines
2.6 KiB
C#
using DataServer.Data.Entities;
|
|
|
|
namespace GameServer.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();
|
|
|
|
/// <summary>Mob spawns from template (intermediate storage before conversion)</summary>
|
|
public List<RoomMobSpawn> MobSpawns { get; set; } = new();
|
|
|
|
/// <summary>Player spawn position (for entrance rooms)</summary>
|
|
public int? PlayerSpawnX { get; set; }
|
|
public int? PlayerSpawnY { get; set; }
|
|
|
|
/// <summary>Exit position (for exit rooms)</summary>
|
|
public int? ExitX { get; set; }
|
|
public int? ExitY { get; set; }
|
|
|
|
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
|
|
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()
|
|
};
|
|
}
|
|
|
|
/// <summary>Get world position of a connection point</summary>
|
|
public (int X, int Y) GetConnectionWorldPos(ConnectionPoint cp)
|
|
{
|
|
return (X + cp.X, Y + cp.Y);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Mob spawn point within a room (intermediate type for template data)
|
|
/// </summary>
|
|
public class RoomMobSpawn
|
|
{
|
|
public int X { get; set; }
|
|
public int Y { get; set; }
|
|
public string Type { get; set; } = "normal";
|
|
public int? MobDefinitionId { get; set; } // Specific mob, or null for random from pool
|
|
public int Count { get; set; } = 1;
|
|
}
|