Tile changes
This commit is contained in:
+223
-105
@@ -11,51 +11,66 @@ public class TileMapSheet
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
|
||||
/// <summary>Friendly name (e.g., "Dungeon Stone Set", "Cave Tiles")</summary>
|
||||
[Required, MaxLength(64)]
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
|
||||
/// <summary>CDN path (e.g., "textures/tilemaps/dungeon_stone.png")</summary>
|
||||
[Required, MaxLength(256)]
|
||||
public string CdnPath { get; set; } = "";
|
||||
|
||||
|
||||
/// <summary>Tags for categorization (e.g., "dungeon,stone,dark")</summary>
|
||||
[MaxLength(256)]
|
||||
public string? Tags { get; set; }
|
||||
|
||||
|
||||
/// <summary>Total width of sprite sheet in pixels</summary>
|
||||
public int SheetWidth { get; set; } = 512;
|
||||
|
||||
|
||||
/// <summary>Total height of sprite sheet in pixels</summary>
|
||||
public int SheetHeight { get; set; } = 512;
|
||||
|
||||
|
||||
/// <summary>Width of each tile in pixels</summary>
|
||||
public int TileWidth { get; set; } = 32;
|
||||
|
||||
|
||||
/// <summary>Height of each tile in pixels (for isometric, often 16 or TileWidth/2)</summary>
|
||||
public int TileHeight { get; set; } = 32;
|
||||
|
||||
|
||||
/// <summary>Number of columns in sheet</summary>
|
||||
[NotMapped]
|
||||
public int Columns => TileWidth > 0 ? SheetWidth / TileWidth : 1;
|
||||
|
||||
|
||||
/// <summary>Number of rows in sheet</summary>
|
||||
[NotMapped]
|
||||
public int Rows => TileHeight > 0 ? SheetHeight / TileHeight : 1;
|
||||
|
||||
|
||||
/// <summary>Total tile count</summary>
|
||||
[NotMapped]
|
||||
public int TotalTiles => Columns * Rows;
|
||||
|
||||
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
|
||||
// Navigation
|
||||
public ICollection<TileDefinition>? Tiles { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Socket type for tile edge connections
|
||||
/// </summary>
|
||||
public enum SocketType
|
||||
{
|
||||
/// <summary>Closed edge - only connects to other Closed edges (walls, void borders)</summary>
|
||||
Closed = 0,
|
||||
|
||||
/// <summary>Open edge - only connects to other Open edges (interior floors)</summary>
|
||||
Open = 1,
|
||||
|
||||
/// <summary>Custom type - must match exact custom string in SocketCustom field</summary>
|
||||
Custom = 2
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Definition of a single tile within a tilemap sheet
|
||||
/// </summary>
|
||||
@@ -64,55 +79,158 @@ public class TileDefinition
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
|
||||
public int TileMapSheetId { get; set; }
|
||||
|
||||
|
||||
[ForeignKey(nameof(TileMapSheetId))]
|
||||
public TileMapSheet? TileMapSheet { get; set; }
|
||||
|
||||
|
||||
/// <summary>Frame index in the sheet (0-based, left-to-right, top-to-bottom)</summary>
|
||||
public int FrameIndex { get; set; }
|
||||
|
||||
|
||||
/// <summary>Optional name for this specific tile</summary>
|
||||
[MaxLength(64)]
|
||||
public string? Name { get; set; }
|
||||
|
||||
|
||||
/// <summary>Tile type for game logic</summary>
|
||||
public TileType Type { get; set; } = TileType.Floor;
|
||||
|
||||
/// <summary>Tags for filtering/selection (e.g., "stone,cracked,corner_nw,biome:cave")</summary>
|
||||
|
||||
/// <summary>Tags for filtering/selection (e.g., "stone,cracked,biome:cave")</summary>
|
||||
[MaxLength(256)]
|
||||
public string? Tags { get; set; }
|
||||
|
||||
|
||||
/// <summary>Whether entities can walk on this tile</summary>
|
||||
public bool IsWalkable { get; set; } = true;
|
||||
|
||||
|
||||
/// <summary>Whether projectiles can pass through</summary>
|
||||
public bool BlocksProjectiles { get; set; } = false;
|
||||
|
||||
|
||||
/// <summary>Whether this blocks line of sight</summary>
|
||||
public bool BlocksLineOfSight { get; set; } = false;
|
||||
|
||||
|
||||
/// <summary>Layer for rendering order (0=ground, 1=floor decor, 2=walls, 3=ceiling)</summary>
|
||||
public int RenderLayer { get; set; } = 0;
|
||||
|
||||
|
||||
/// <summary>Z-index within the layer</summary>
|
||||
public int ZIndex { get; set; } = 0;
|
||||
|
||||
|
||||
/// <summary>Whether this tile is animated</summary>
|
||||
public bool IsAnimated { get; set; } = false;
|
||||
|
||||
|
||||
/// <summary>Number of animation frames (consecutive frames starting at FrameIndex)</summary>
|
||||
public int AnimationFrameCount { get; set; } = 1;
|
||||
|
||||
|
||||
/// <summary>Animation speed in frames per second</summary>
|
||||
public float AnimationFps { get; set; } = 8.0f;
|
||||
|
||||
|
||||
/// <summary>Biome this tile belongs to (e.g., "cave", "dungeon", "forest")</summary>
|
||||
[MaxLength(32)]
|
||||
public string? Biome { get; set; }
|
||||
|
||||
|
||||
// =========================================================================
|
||||
// SOCKET SYSTEM - Controls how tiles connect to neighbors
|
||||
// =========================================================================
|
||||
|
||||
/// <summary>North edge socket type</summary>
|
||||
public SocketType SocketN { get; set; } = SocketType.Closed;
|
||||
|
||||
/// <summary>East edge socket type</summary>
|
||||
public SocketType SocketE { get; set; } = SocketType.Closed;
|
||||
|
||||
/// <summary>South edge socket type</summary>
|
||||
public SocketType SocketS { get; set; } = SocketType.Closed;
|
||||
|
||||
/// <summary>West edge socket type</summary>
|
||||
public SocketType SocketW { get; set; } = SocketType.Closed;
|
||||
|
||||
/// <summary>Custom socket type name for North (only used when SocketN = Custom)</summary>
|
||||
[MaxLength(32)]
|
||||
public string? SocketNCustom { get; set; }
|
||||
|
||||
/// <summary>Custom socket type name for East (only used when SocketE = Custom)</summary>
|
||||
[MaxLength(32)]
|
||||
public string? SocketECustom { get; set; }
|
||||
|
||||
/// <summary>Custom socket type name for South (only used when SocketS = Custom)</summary>
|
||||
[MaxLength(32)]
|
||||
public string? SocketSCustom { get; set; }
|
||||
|
||||
/// <summary>Custom socket type name for West (only used when SocketW = Custom)</summary>
|
||||
[MaxLength(32)]
|
||||
public string? SocketWCustom { get; set; }
|
||||
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
|
||||
// =========================================================================
|
||||
// HELPER METHODS
|
||||
// =========================================================================
|
||||
|
||||
/// <summary>Get the effective socket identifier for a direction</summary>
|
||||
public string GetSocketId(string direction)
|
||||
{
|
||||
return direction.ToUpperInvariant() switch
|
||||
{
|
||||
"N" or "NORTH" => SocketN == SocketType.Custom ? $"Custom:{SocketNCustom}" : SocketN.ToString(),
|
||||
"E" or "EAST" => SocketE == SocketType.Custom ? $"Custom:{SocketECustom}" : SocketE.ToString(),
|
||||
"S" or "SOUTH" => SocketS == SocketType.Custom ? $"Custom:{SocketSCustom}" : SocketS.ToString(),
|
||||
"W" or "WEST" => SocketW == SocketType.Custom ? $"Custom:{SocketWCustom}" : SocketW.ToString(),
|
||||
_ => "Closed"
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>Check if this tile's edge is compatible with another tile's edge</summary>
|
||||
public bool IsEdgeCompatible(string thisEdge, TileDefinition other, string otherEdge)
|
||||
{
|
||||
var thisSocket = GetSocketId(thisEdge);
|
||||
var otherSocket = other.GetSocketId(otherEdge);
|
||||
|
||||
// Exact match required
|
||||
return thisSocket.Equals(otherSocket, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
/// <summary>Set all sockets to a given type (useful for bulk operations)</summary>
|
||||
public void SetAllSockets(SocketType type, string? customName = null)
|
||||
{
|
||||
SocketN = SocketE = SocketS = SocketW = type;
|
||||
if (type == SocketType.Custom)
|
||||
{
|
||||
SocketNCustom = SocketECustom = SocketSCustom = SocketWCustom = customName;
|
||||
}
|
||||
else
|
||||
{
|
||||
SocketNCustom = SocketECustom = SocketSCustom = SocketWCustom = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Auto-configure sockets based on tile type</summary>
|
||||
public void AutoConfigureSockets()
|
||||
{
|
||||
switch (Type)
|
||||
{
|
||||
case TileType.Floor:
|
||||
case TileType.FloorDecor:
|
||||
SetAllSockets(SocketType.Open);
|
||||
break;
|
||||
|
||||
case TileType.Wall:
|
||||
case TileType.WallDecor:
|
||||
SetAllSockets(SocketType.Closed);
|
||||
break;
|
||||
|
||||
case TileType.Door:
|
||||
// Doors typically open on two sides
|
||||
// Default to vertical door (open N/S, closed E/W)
|
||||
SocketN = SocketType.Open;
|
||||
SocketS = SocketType.Open;
|
||||
SocketE = SocketType.Closed;
|
||||
SocketW = SocketType.Closed;
|
||||
break;
|
||||
|
||||
default:
|
||||
SetAllSockets(SocketType.Closed);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -127,19 +245,19 @@ public enum TileType
|
||||
Lava = 4,
|
||||
Pit = 5,
|
||||
Stairs = 6,
|
||||
|
||||
|
||||
// Spawn points
|
||||
PlayerSpawn = 10,
|
||||
MobSpawn = 11,
|
||||
BossSpawn = 12,
|
||||
ChestSpawn = 13,
|
||||
|
||||
|
||||
// Special
|
||||
Trigger = 20,
|
||||
Transition = 21,
|
||||
Secret = 22,
|
||||
Trap = 23,
|
||||
|
||||
|
||||
// Decorative (walkable but with visual interest)
|
||||
FloorDecor = 30,
|
||||
WallDecor = 31
|
||||
@@ -153,49 +271,49 @@ public class RoomTemplate
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
|
||||
/// <summary>Name of this room template</summary>
|
||||
[Required, MaxLength(64)]
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
|
||||
/// <summary>Description of the room</summary>
|
||||
[MaxLength(512)]
|
||||
public string? Description { get; set; }
|
||||
|
||||
|
||||
/// <summary>Tags for categorization (e.g., "entrance,large,treasure")</summary>
|
||||
[MaxLength(256)]
|
||||
public string? Tags { get; set; }
|
||||
|
||||
|
||||
/// <summary>Room type for generation logic</summary>
|
||||
public RoomType Type { get; set; } = RoomType.Normal;
|
||||
|
||||
|
||||
/// <summary>Width in tiles</summary>
|
||||
public int Width { get; set; } = 10;
|
||||
|
||||
|
||||
/// <summary>Height in tiles</summary>
|
||||
public int Height { get; set; } = 10;
|
||||
|
||||
|
||||
/// <summary>Minimum dungeon tier this room can appear in</summary>
|
||||
public int MinTier { get; set; } = 1;
|
||||
|
||||
|
||||
/// <summary>Maximum dungeon tier (0 = no max)</summary>
|
||||
public int MaxTier { get; set; } = 0;
|
||||
|
||||
|
||||
/// <summary>Spawn weight for random selection (higher = more common)</summary>
|
||||
public int Weight { get; set; } = 100;
|
||||
|
||||
|
||||
/// <summary>JSON data containing tile placements</summary>
|
||||
[Column(TypeName = "json")]
|
||||
public string? TileDataJson { get; set; }
|
||||
|
||||
|
||||
/// <summary>JSON data containing spawn points</summary>
|
||||
[Column(TypeName = "json")]
|
||||
public string? SpawnPointsJson { get; set; }
|
||||
|
||||
|
||||
/// <summary>JSON data for connection points (where hallways can attach)</summary>
|
||||
[Column(TypeName = "json")]
|
||||
public string? ConnectionPointsJson { get; set; }
|
||||
|
||||
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
|
||||
@@ -227,49 +345,49 @@ public class DungeonTemplate
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
|
||||
/// <summary>Name of this dungeon</summary>
|
||||
[Required, MaxLength(64)]
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
|
||||
/// <summary>Description</summary>
|
||||
[MaxLength(512)]
|
||||
public string? Description { get; set; }
|
||||
|
||||
|
||||
/// <summary>Tags for categorization</summary>
|
||||
[MaxLength(256)]
|
||||
public string? Tags { get; set; }
|
||||
|
||||
|
||||
/// <summary>Dungeon tier (difficulty)</summary>
|
||||
public int Tier { get; set; } = 1;
|
||||
|
||||
|
||||
/// <summary>Total width in tiles</summary>
|
||||
public int Width { get; set; } = 100;
|
||||
|
||||
|
||||
/// <summary>Total height in tiles</summary>
|
||||
public int Height { get; set; } = 100;
|
||||
|
||||
|
||||
/// <summary>If true, this is a complete hand-crafted dungeon. If false, it's generation parameters.</summary>
|
||||
public bool IsHandCrafted { get; set; } = false;
|
||||
|
||||
|
||||
/// <summary>JSON containing full tile data (for hand-crafted)</summary>
|
||||
[Column(TypeName = "json")]
|
||||
public string? TileDataJson { get; set; }
|
||||
|
||||
|
||||
/// <summary>JSON containing room placements (for hand-crafted or as hints for generation)</summary>
|
||||
[Column(TypeName = "json")]
|
||||
public string? RoomPlacementsJson { get; set; }
|
||||
|
||||
|
||||
/// <summary>JSON containing generation parameters (room counts, weights, etc.)</summary>
|
||||
[Column(TypeName = "json")]
|
||||
public string? GenerationParamsJson { get; set; }
|
||||
|
||||
|
||||
/// <summary>Default tilemap sheet to use</summary>
|
||||
public int? DefaultTileMapSheetId { get; set; }
|
||||
|
||||
|
||||
[ForeignKey(nameof(DefaultTileMapSheetId))]
|
||||
public TileMapSheet? DefaultTileMapSheet { get; set; }
|
||||
|
||||
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
|
||||
@@ -284,13 +402,13 @@ public class TilePlacement
|
||||
public int Y { get; set; }
|
||||
public int TileDefinitionId { get; set; }
|
||||
public int Layer { get; set; } = 0;
|
||||
|
||||
|
||||
/// <summary>Optional rotation (0, 90, 180, 270)</summary>
|
||||
public int Rotation { get; set; } = 0;
|
||||
|
||||
|
||||
/// <summary>Optional flip X</summary>
|
||||
public bool FlipX { get; set; } = false;
|
||||
|
||||
|
||||
/// <summary>Optional flip Y</summary>
|
||||
public bool FlipY { get; set; } = false;
|
||||
}
|
||||
@@ -303,10 +421,10 @@ public class SpawnPoint
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
public TileType Type { get; set; }
|
||||
|
||||
|
||||
/// <summary>Optional specific mob/item ID to spawn</summary>
|
||||
public int? EntityId { get; set; }
|
||||
|
||||
|
||||
/// <summary>Tags for filtering what can spawn here</summary>
|
||||
public string? Tags { get; set; }
|
||||
}
|
||||
@@ -318,10 +436,10 @@ public class ConnectionPoint
|
||||
{
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
|
||||
|
||||
/// <summary>Direction this connection faces (north, south, east, west)</summary>
|
||||
public string Direction { get; set; } = "north";
|
||||
|
||||
|
||||
/// <summary>Width of the connection (for wider hallways)</summary>
|
||||
public int Width { get; set; } = 1;
|
||||
}
|
||||
@@ -334,79 +452,79 @@ public class DungeonObjectDefinition
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
|
||||
/// <summary>Name of this object</summary>
|
||||
[Required, MaxLength(64)]
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
|
||||
/// <summary>Description</summary>
|
||||
[MaxLength(512)]
|
||||
public string? Description { get; set; }
|
||||
|
||||
|
||||
/// <summary>Object type</summary>
|
||||
public DungeonObjectType Type { get; set; } = DungeonObjectType.Decoration;
|
||||
|
||||
|
||||
/// <summary>Sprite path on CDN</summary>
|
||||
[MaxLength(256)]
|
||||
public string? SpritePath { get; set; }
|
||||
|
||||
|
||||
/// <summary>Sprite ID for shared sprites</summary>
|
||||
public int? SpriteId { get; set; }
|
||||
|
||||
|
||||
/// <summary>Alternative sprite when interacted (e.g., opened chest)</summary>
|
||||
[MaxLength(256)]
|
||||
public string? InteractedSpritePath { get; set; }
|
||||
|
||||
|
||||
/// <summary>Whether this object blocks movement</summary>
|
||||
public bool BlocksMovement { get; set; } = false;
|
||||
|
||||
|
||||
/// <summary>Whether this object blocks projectiles</summary>
|
||||
public bool BlocksProjectiles { get; set; } = false;
|
||||
|
||||
|
||||
/// <summary>Whether this object blocks line of sight</summary>
|
||||
public bool BlocksLineOfSight { get; set; } = false;
|
||||
|
||||
|
||||
/// <summary>Whether this object can be interacted with</summary>
|
||||
public bool IsInteractable { get; set; } = false;
|
||||
|
||||
|
||||
/// <summary>Whether this object can be destroyed</summary>
|
||||
public bool IsDestructible { get; set; } = false;
|
||||
|
||||
|
||||
/// <summary>Health if destructible (0 = instant destroy)</summary>
|
||||
public int Health { get; set; } = 0;
|
||||
|
||||
|
||||
/// <summary>Interaction type (what happens when player interacts)</summary>
|
||||
public ObjectInteractionType InteractionType { get; set; } = ObjectInteractionType.None;
|
||||
|
||||
|
||||
/// <summary>Loot table ID for containers</summary>
|
||||
public int? LootTableId { get; set; }
|
||||
|
||||
|
||||
/// <summary>Tags for filtering/categorization</summary>
|
||||
[MaxLength(256)]
|
||||
public string? Tags { get; set; }
|
||||
|
||||
|
||||
/// <summary>Biome this object belongs to</summary>
|
||||
[MaxLength(32)]
|
||||
public string? Biome { get; set; }
|
||||
|
||||
|
||||
/// <summary>Size in tiles (width)</summary>
|
||||
public int Width { get; set; } = 1;
|
||||
|
||||
|
||||
/// <summary>Size in tiles (height)</summary>
|
||||
public int Height { get; set; } = 1;
|
||||
|
||||
|
||||
/// <summary>Z-index for rendering order</summary>
|
||||
public int ZIndex { get; set; } = 0;
|
||||
|
||||
|
||||
/// <summary>Whether this object is animated</summary>
|
||||
public bool IsAnimated { get; set; } = false;
|
||||
|
||||
|
||||
/// <summary>Animation frame count</summary>
|
||||
public int AnimationFrameCount { get; set; } = 1;
|
||||
|
||||
|
||||
/// <summary>Animation FPS</summary>
|
||||
public float AnimationFps { get; set; } = 8.0f;
|
||||
|
||||
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
|
||||
@@ -417,15 +535,15 @@ public class DungeonObjectDefinition
|
||||
/// </summary>
|
||||
public enum DungeonObjectType
|
||||
{
|
||||
Decoration = 0, // Visual only, no collision
|
||||
Obstacle = 1, // Blocks movement
|
||||
Container = 2, // Can be opened for loot (chest, barrel, etc.)
|
||||
Interactable = 3, // Triggers an action (lever, button, etc.)
|
||||
Destructible = 4, // Can be destroyed (crate, pot, etc.)
|
||||
Door = 5, // Openable door
|
||||
Trap = 6, // Damages player
|
||||
Shrine = 7, // Gives buff/heals
|
||||
Vendor = 8 // Shop NPC placeholder
|
||||
Decoration = 0,
|
||||
Obstacle = 1,
|
||||
Container = 2,
|
||||
Interactable = 3,
|
||||
Destructible = 4,
|
||||
Door = 5,
|
||||
Trap = 6,
|
||||
Shrine = 7,
|
||||
Vendor = 8
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -434,12 +552,12 @@ public enum DungeonObjectType
|
||||
public enum ObjectInteractionType
|
||||
{
|
||||
None = 0,
|
||||
OpenContainer = 1, // Opens loot UI
|
||||
Toggle = 2, // Toggle on/off state
|
||||
Trigger = 3, // Triggers an event
|
||||
Teleport = 4, // Teleports player
|
||||
Heal = 5, // Heals player
|
||||
Buff = 6, // Gives buff
|
||||
Dialogue = 7, // Shows dialogue
|
||||
Shop = 8 // Opens shop UI
|
||||
OpenContainer = 1,
|
||||
Toggle = 2,
|
||||
Trigger = 3,
|
||||
Teleport = 4,
|
||||
Heal = 5,
|
||||
Buff = 6,
|
||||
Dialogue = 7,
|
||||
Shop = 8
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user