Dungeon simulation changes
This commit is contained in:
@@ -71,7 +71,11 @@ public class DungeonGeneratorV2
|
||||
|
||||
// Always place entrance first
|
||||
var entrance = await PlaceRoomAsync(layout, rooms, RoomType.Entrance, 5, 5);
|
||||
if (entrance != null) rooms.Add(entrance);
|
||||
if (entrance != null)
|
||||
{
|
||||
rooms.Add(entrance);
|
||||
Console.WriteLine($"[DungeonGenV2] Placed entrance room: {entrance.TemplateName ?? "fallback"} at ({entrance.X},{entrance.Y})");
|
||||
}
|
||||
|
||||
// Place other rooms
|
||||
while (rooms.Count < roomCount && attempts < maxAttempts)
|
||||
@@ -92,9 +96,12 @@ public class DungeonGeneratorV2
|
||||
if (newRoom != null)
|
||||
{
|
||||
rooms.Add(newRoom);
|
||||
Console.WriteLine($"[DungeonGenV2] Placed {type} room: {newRoom.TemplateName ?? "fallback"} at ({newRoom.X},{newRoom.Y})");
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine($"[DungeonGenV2] Placed {rooms.Count}/{roomCount} rooms after {attempts} attempts");
|
||||
|
||||
// Ensure we have an exit/boss room
|
||||
var bossRoom = rooms.FirstOrDefault(r => r.Type == RoomType.Boss);
|
||||
if (bossRoom == null && rooms.Count > 1)
|
||||
@@ -107,14 +114,17 @@ public class DungeonGeneratorV2
|
||||
var entranceRoom = rooms.FirstOrDefault(r => r.Type == RoomType.Entrance) ?? rooms[0];
|
||||
rooms = rooms.OrderBy(r => Distance(entranceRoom, r)).ToList();
|
||||
|
||||
// Connect rooms with corridors
|
||||
// Connect rooms with corridors - entrance MUST be connected
|
||||
var connected = new HashSet<int> { 0 };
|
||||
Console.WriteLine($"[DungeonGenV2] Connecting {rooms.Count} rooms...");
|
||||
|
||||
for (int i = 1; i < rooms.Count; i++)
|
||||
{
|
||||
// Find closest connected room
|
||||
int closestIdx = connected.OrderBy(c => Distance(rooms[c], rooms[i])).First();
|
||||
await ConnectRoomsAsync(layout, rooms[closestIdx], rooms[i]);
|
||||
connected.Add(i);
|
||||
Console.WriteLine($"[DungeonGenV2] Connected room {i} ({rooms[i].Type}) to room {closestIdx}");
|
||||
}
|
||||
|
||||
// Add some extra connections for loops
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,112 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SystemRevivalServer.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class DungeonSimulationchanges : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<float>(
|
||||
name: "AnimationFps",
|
||||
table: "tile_definitions",
|
||||
type: "float",
|
||||
nullable: false,
|
||||
defaultValue: 0f);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "AnimationFrameCount",
|
||||
table: "tile_definitions",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Biome",
|
||||
table: "tile_definitions",
|
||||
type: "varchar(32)",
|
||||
maxLength: 32,
|
||||
nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "IsAnimated",
|
||||
table: "tile_definitions",
|
||||
type: "tinyint(1)",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "dungeon_objects",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
Name = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Description = table.Column<string>(type: "varchar(512)", maxLength: 512, nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Type = table.Column<int>(type: "int", nullable: false),
|
||||
SpritePath = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
SpriteId = table.Column<int>(type: "int", nullable: true),
|
||||
InteractedSpritePath = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
BlocksMovement = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||
BlocksProjectiles = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||
BlocksLineOfSight = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||
IsInteractable = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||
IsDestructible = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||
Health = table.Column<int>(type: "int", nullable: false),
|
||||
InteractionType = table.Column<int>(type: "int", nullable: false),
|
||||
LootTableId = table.Column<int>(type: "int", nullable: true),
|
||||
Tags = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Biome = table.Column<string>(type: "varchar(32)", maxLength: 32, nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Width = table.Column<int>(type: "int", nullable: false),
|
||||
Height = table.Column<int>(type: "int", nullable: false),
|
||||
ZIndex = table.Column<int>(type: "int", nullable: false),
|
||||
IsAnimated = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||
AnimationFrameCount = table.Column<int>(type: "int", nullable: false),
|
||||
AnimationFps = table.Column<float>(type: "float", nullable: false),
|
||||
IsEnabled = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_dungeon_objects", x => x.Id);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "dungeon_objects");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "AnimationFps",
|
||||
table: "tile_definitions");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "AnimationFrameCount",
|
||||
table: "tile_definitions");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Biome",
|
||||
table: "tile_definitions");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IsAnimated",
|
||||
table: "tile_definitions");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1177,6 +1177,101 @@ namespace SystemRevivalServer.Migrations
|
||||
b.ToTable("dungeon_mob_loot_tables");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DataServer.Data.Entities.DungeonObjectDefinition", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<float>("AnimationFps")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("AnimationFrameCount")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Biome")
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("varchar(32)");
|
||||
|
||||
b.Property<bool>("BlocksLineOfSight")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<bool>("BlocksMovement")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<bool>("BlocksProjectiles")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasMaxLength(512)
|
||||
.HasColumnType("varchar(512)");
|
||||
|
||||
b.Property<int>("Health")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Height")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("InteractedSpritePath")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("varchar(256)");
|
||||
|
||||
b.Property<int>("InteractionType")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<bool>("IsAnimated")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<bool>("IsDestructible")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<bool>("IsEnabled")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<bool>("IsInteractable")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<int?>("LootTableId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("varchar(64)");
|
||||
|
||||
b.Property<int?>("SpriteId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("SpritePath")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("varchar(256)");
|
||||
|
||||
b.Property<string>("Tags")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("varchar(256)");
|
||||
|
||||
b.Property<int>("Type")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<int>("Width")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ZIndex")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("dungeon_objects");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DataServer.Data.Entities.DungeonPersistence", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
@@ -1830,6 +1925,16 @@ namespace SystemRevivalServer.Migrations
|
||||
|
||||
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<float>("AnimationFps")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("AnimationFrameCount")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Biome")
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("varchar(32)");
|
||||
|
||||
b.Property<bool>("BlocksLineOfSight")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
@@ -1839,6 +1944,9 @@ namespace SystemRevivalServer.Migrations
|
||||
b.Property<int>("FrameIndex")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<bool>("IsAnimated")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<bool>("IsEnabled")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ public sealed class GameDbContext : DbContext
|
||||
public DbSet<TileDefinition> TileDefinitions => Set<TileDefinition>();
|
||||
public DbSet<RoomTemplate> RoomTemplates => Set<RoomTemplate>();
|
||||
public DbSet<DungeonTemplate> DungeonTemplates => Set<DungeonTemplate>();
|
||||
public DbSet<DungeonObjectDefinition> DungeonObjects => Set<DungeonObjectDefinition>();
|
||||
|
||||
public DbSet<DungeonBeltItem> DungeonBeltItems => Set<DungeonBeltItem>();
|
||||
public DbSet<DeathChest> DeathChests => Set<DeathChest>();
|
||||
|
||||
+132
-1
@@ -80,7 +80,7 @@ public class TileDefinition
|
||||
/// <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")</summary>
|
||||
/// <summary>Tags for filtering/selection (e.g., "stone,cracked,corner_nw,biome:cave")</summary>
|
||||
[MaxLength(256)]
|
||||
public string? Tags { get; set; }
|
||||
|
||||
@@ -99,6 +99,19 @@ public class TileDefinition
|
||||
/// <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; }
|
||||
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
}
|
||||
|
||||
@@ -312,3 +325,121 @@ public class ConnectionPoint
|
||||
/// <summary>Width of the connection (for wider hallways)</summary>
|
||||
public int Width { get; set; } = 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Definition of a dungeon object (interactable, obstacle, container)
|
||||
/// </summary>
|
||||
[Table("dungeon_objects")]
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Types of dungeon objects
|
||||
/// </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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Types of object interactions
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user