DungeonBuilder UI Attempt
This commit is contained in:
@@ -0,0 +1,208 @@
|
||||
@page "/admin/dungeonbuilder"
|
||||
@model DungeonBuilder.IndexModel
|
||||
@{
|
||||
ViewData["Title"] = "Dungeon Builder";
|
||||
}
|
||||
|
||||
<div class="mb-6">
|
||||
<h1 class="text-2xl font-bold text-white">Dungeon Builder</h1>
|
||||
<p class="text-gray-400 mt-1">Visual tools for creating dungeon content</p>
|
||||
</div>
|
||||
|
||||
@if (!string.IsNullOrEmpty(Model.Message))
|
||||
{
|
||||
<div class="mb-4 p-3 rounded @(Model.IsError ? "bg-red-900/50 text-red-300" : "bg-green-900/50 text-green-300")">
|
||||
@Model.Message
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- Quick Stats -->
|
||||
<div class="grid grid-cols-2 md:grid-cols-4 gap-4 mb-6">
|
||||
<div class="card p-4">
|
||||
<div class="text-3xl font-bold text-blue-400">@Model.TileTemplateCount</div>
|
||||
<div class="text-gray-400 text-sm">Tile Templates</div>
|
||||
</div>
|
||||
<div class="card p-4">
|
||||
<div class="text-3xl font-bold text-purple-400">@Model.ObjectTemplateCount</div>
|
||||
<div class="text-gray-400 text-sm">Object Templates</div>
|
||||
</div>
|
||||
<div class="card p-4">
|
||||
<div class="text-3xl font-bold text-green-400">@Model.RoomTemplateCount</div>
|
||||
<div class="text-gray-400 text-sm">Room Templates</div>
|
||||
</div>
|
||||
<div class="card p-4">
|
||||
<div class="text-3xl font-bold text-yellow-400">@Model.PaletteCount</div>
|
||||
<div class="text-gray-400 text-sm">Dungeon Palettes</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Builder Tools Grid -->
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
|
||||
<!-- Tile Templates -->
|
||||
<a href="/admin/dungeonbuilder/tiles" class="card p-6 hover:border-blue-500 transition-colors group">
|
||||
<div class="flex items-start gap-4">
|
||||
<div class="w-12 h-12 rounded-lg bg-blue-500/20 flex items-center justify-center text-blue-400 text-2xl">
|
||||
🧱
|
||||
</div>
|
||||
<div class="flex-1">
|
||||
<h3 class="text-lg font-semibold text-white group-hover:text-blue-400">Tile Templates</h3>
|
||||
<p class="text-gray-400 text-sm mt-1">Create reusable floor, wall, and door patterns</p>
|
||||
<div class="mt-3 text-xs text-gray-500">
|
||||
• Single tiles or multi-tile patterns<br>
|
||||
• Socket configuration for matching<br>
|
||||
• Walkability and blocking settings
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
|
||||
<!-- Object Templates -->
|
||||
<a href="/admin/dungeonbuilder/objects" class="card p-6 hover:border-purple-500 transition-colors group">
|
||||
<div class="flex items-start gap-4">
|
||||
<div class="w-12 h-12 rounded-lg bg-purple-500/20 flex items-center justify-center text-purple-400 text-2xl">
|
||||
🏺
|
||||
</div>
|
||||
<div class="flex-1">
|
||||
<h3 class="text-lg font-semibold text-white group-hover:text-purple-400">Object Templates</h3>
|
||||
<p class="text-gray-400 text-sm mt-1">Design furniture, containers, traps, and decorations</p>
|
||||
<div class="mt-3 text-xs text-gray-500">
|
||||
• Animation states<br>
|
||||
• Interaction settings<br>
|
||||
• Loot and rewards
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
|
||||
<!-- Room Templates -->
|
||||
<a href="/admin/dungeonbuilder/rooms" class="card p-6 hover:border-green-500 transition-colors group">
|
||||
<div class="flex items-start gap-4">
|
||||
<div class="w-12 h-12 rounded-lg bg-green-500/20 flex items-center justify-center text-green-400 text-2xl">
|
||||
🗺️
|
||||
</div>
|
||||
<div class="flex-1">
|
||||
<h3 class="text-lg font-semibold text-white group-hover:text-green-400">Room Templates</h3>
|
||||
<p class="text-gray-400 text-sm mt-1">Build complete rooms with tiles, objects, and spawns</p>
|
||||
<div class="mt-3 text-xs text-gray-500">
|
||||
• Visual room editor<br>
|
||||
• Connection points<br>
|
||||
• Mob and item spawns
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
|
||||
<!-- Dungeon Palettes -->
|
||||
<a href="/admin/dungeonbuilder/palettes" class="card p-6 hover:border-yellow-500 transition-colors group">
|
||||
<div class="flex items-start gap-4">
|
||||
<div class="w-12 h-12 rounded-lg bg-yellow-500/20 flex items-center justify-center text-yellow-400 text-2xl">
|
||||
🎨
|
||||
</div>
|
||||
<div class="flex-1">
|
||||
<h3 class="text-lg font-semibold text-white group-hover:text-yellow-400">Dungeon Palettes</h3>
|
||||
<p class="text-gray-400 text-sm mt-1">Combine templates into themed dungeon sets</p>
|
||||
<div class="mt-3 text-xs text-gray-500">
|
||||
• Template collections<br>
|
||||
• Generation parameters<br>
|
||||
• Biome configuration
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
|
||||
<!-- Sprite Sheet Manager -->
|
||||
<a href="/admin/tilemaps" class="card p-6 hover:border-cyan-500 transition-colors group">
|
||||
<div class="flex items-start gap-4">
|
||||
<div class="w-12 h-12 rounded-lg bg-cyan-500/20 flex items-center justify-center text-cyan-400 text-2xl">
|
||||
🖼️
|
||||
</div>
|
||||
<div class="flex-1">
|
||||
<h3 class="text-lg font-semibold text-white group-hover:text-cyan-400">Sprite Sheets</h3>
|
||||
<p class="text-gray-400 text-sm mt-1">Manage tilemap sprite sheets and tile definitions</p>
|
||||
<div class="mt-3 text-xs text-gray-500">
|
||||
• Upload sprite sheets<br>
|
||||
• Tag individual tiles<br>
|
||||
• Define tile properties
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
|
||||
<!-- Test Generator -->
|
||||
<a href="/admin/dungeonbuilder/test" class="card p-6 hover:border-orange-500 transition-colors group">
|
||||
<div class="flex items-start gap-4">
|
||||
<div class="w-12 h-12 rounded-lg bg-orange-500/20 flex items-center justify-center text-orange-400 text-2xl">
|
||||
🧪
|
||||
</div>
|
||||
<div class="flex-1">
|
||||
<h3 class="text-lg font-semibold text-white group-hover:text-orange-400">Test Generator</h3>
|
||||
<p class="text-gray-400 text-sm mt-1">Preview dungeon generation with your templates</p>
|
||||
<div class="mt-3 text-xs text-gray-500">
|
||||
• Generate test dungeons<br>
|
||||
• Visual preview<br>
|
||||
• Adjust parameters
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- Recent Activity -->
|
||||
<div class="card p-6 mt-6">
|
||||
<h3 class="text-lg font-semibold text-white mb-4">Recent Templates</h3>
|
||||
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full text-sm">
|
||||
<thead>
|
||||
<tr class="text-left text-gray-400 border-b border-gray-700">
|
||||
<th class="pb-2 pr-4">Type</th>
|
||||
<th class="pb-2 pr-4">Name</th>
|
||||
<th class="pb-2 pr-4">Biome</th>
|
||||
<th class="pb-2 pr-4">Updated</th>
|
||||
<th class="pb-2">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-700/50">
|
||||
@foreach (var item in Model.RecentItems)
|
||||
{
|
||||
<tr class="hover:bg-gray-800/50">
|
||||
<td class="py-2 pr-4">
|
||||
<span class="px-2 py-0.5 rounded text-xs @GetTypeColor(item.Type)">
|
||||
@item.Type
|
||||
</span>
|
||||
</td>
|
||||
<td class="py-2 pr-4 text-white">@item.Name</td>
|
||||
<td class="py-2 pr-4 text-gray-400">@(item.Biome ?? "-")</td>
|
||||
<td class="py-2 pr-4 text-gray-500">@item.UpdatedAt.ToString("MMM d, HH:mm")</td>
|
||||
<td class="py-2">
|
||||
<a href="@item.EditUrl" class="text-blue-400 hover:text-blue-300">Edit</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
@if (!Model.RecentItems.Any())
|
||||
{
|
||||
<tr>
|
||||
<td colspan="5" class="py-8 text-center text-gray-500">
|
||||
No templates created yet. Start by creating a tile or object template!
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@functions {
|
||||
string GetTypeColor(string type)
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
"Tile" => "bg-blue-500/20 text-blue-400",
|
||||
"Object" => "bg-purple-500/20 text-purple-400",
|
||||
"Room" => "bg-green-500/20 text-green-400",
|
||||
"Palette" => "bg-yellow-500/20 text-yellow-400",
|
||||
_ => "bg-gray-500/20 text-gray-400"
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
using DataServer.Data;
|
||||
using DataServer.Data.Entities;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Server.Services.Admin.Pages.DungeonBuilder;
|
||||
|
||||
public class IndexModel : AdminPageModel
|
||||
{
|
||||
private readonly GameDbContext _db;
|
||||
|
||||
public IndexModel(GameDbContext db)
|
||||
{
|
||||
_db = db;
|
||||
}
|
||||
|
||||
public int TileTemplateCount { get; set; }
|
||||
public int ObjectTemplateCount { get; set; }
|
||||
public int RoomTemplateCount { get; set; }
|
||||
public int PaletteCount { get; set; }
|
||||
|
||||
public List<RecentItem> RecentItems { get; set; } = new();
|
||||
|
||||
public string? Message { get; set; }
|
||||
public bool IsError { get; set; }
|
||||
|
||||
public async Task OnGetAsync()
|
||||
{
|
||||
// Get counts
|
||||
TileTemplateCount = await _db.TileTemplates.CountAsync();
|
||||
ObjectTemplateCount = await _db.ObjectTemplates.CountAsync();
|
||||
RoomTemplateCount = await _db.BuilderRoomTemplates.CountAsync();
|
||||
PaletteCount = await _db.DungeonPalettes.CountAsync();
|
||||
|
||||
// Get recent items (combined from all types)
|
||||
var recentTiles = await _db.TileTemplates
|
||||
.OrderByDescending(t => t.UpdatedAt)
|
||||
.Take(3)
|
||||
.Select(t => new RecentItem
|
||||
{
|
||||
Type = "Tile",
|
||||
Name = t.Name,
|
||||
Biome = t.Biome,
|
||||
UpdatedAt = t.UpdatedAt,
|
||||
EditUrl = $"/admin/dungeonbuilder/tiles/edit?id={t.Id}"
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
var recentObjects = await _db.ObjectTemplates
|
||||
.OrderByDescending(t => t.UpdatedAt)
|
||||
.Take(3)
|
||||
.Select(t => new RecentItem
|
||||
{
|
||||
Type = "Object",
|
||||
Name = t.Name,
|
||||
Biome = t.Biome,
|
||||
UpdatedAt = t.UpdatedAt,
|
||||
EditUrl = $"/admin/dungeonbuilder/objects/edit?id={t.Id}"
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
var recentRooms = await _db.BuilderRoomTemplates
|
||||
.OrderByDescending(t => t.UpdatedAt)
|
||||
.Take(3)
|
||||
.Select(t => new RecentItem
|
||||
{
|
||||
Type = "Room",
|
||||
Name = t.Name,
|
||||
Biome = t.Biome,
|
||||
UpdatedAt = t.UpdatedAt,
|
||||
EditUrl = $"/admin/dungeonbuilder/rooms/edit?id={t.Id}"
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
var recentPalettes = await _db.DungeonPalettes
|
||||
.OrderByDescending(t => t.UpdatedAt)
|
||||
.Take(2)
|
||||
.Select(t => new RecentItem
|
||||
{
|
||||
Type = "Palette",
|
||||
Name = t.Name,
|
||||
Biome = t.Biome,
|
||||
UpdatedAt = t.UpdatedAt,
|
||||
EditUrl = $"/admin/dungeonbuilder/palettes/edit?id={t.Id}"
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
RecentItems = recentTiles
|
||||
.Concat(recentObjects)
|
||||
.Concat(recentRooms)
|
||||
.Concat(recentPalettes)
|
||||
.OrderByDescending(x => x.UpdatedAt)
|
||||
.Take(10)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public class RecentItem
|
||||
{
|
||||
public string Type { get; set; } = "";
|
||||
public string Name { get; set; } = "";
|
||||
public string? Biome { get; set; }
|
||||
public DateTime UpdatedAt { get; set; }
|
||||
public string EditUrl { get; set; } = "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,385 @@
|
||||
@page "/admin/dungeonbuilder/objects/edit"
|
||||
@model DungeonBuilder.ObjectEditModel
|
||||
@using DataServer.Data.Entities
|
||||
@{
|
||||
ViewData["Title"] = Model.Object.Id == 0 ? "New Object Template" : $"Edit: {Model.Object.Name}";
|
||||
var types = Enum.GetValues<ObjectTemplateType>();
|
||||
var interactionTypes = Enum.GetValues<ObjectInteractionType>();
|
||||
var placementTypes = Enum.GetValues<ObjectPlacement>();
|
||||
}
|
||||
|
||||
<div class="mb-4">
|
||||
<a href="/admin/dungeonbuilder/objects" class="text-blue-400 hover:text-blue-300 text-sm">← Back to Objects</a>
|
||||
</div>
|
||||
|
||||
<h1 class="text-2xl font-bold text-white mb-6">@ViewData["Title"]</h1>
|
||||
|
||||
@if (!string.IsNullOrEmpty(Model.Message))
|
||||
{
|
||||
<div class="mb-4 p-3 rounded @(Model.IsError ? "bg-red-900/50 text-red-300" : "bg-green-900/50 text-green-300")">
|
||||
@Model.Message
|
||||
</div>
|
||||
}
|
||||
|
||||
<form method="post">
|
||||
@Html.AntiForgeryToken()
|
||||
<input type="hidden" asp-for="Object.Id" />
|
||||
|
||||
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
||||
|
||||
<!-- Left Column: Basic Info -->
|
||||
<div class="space-y-6">
|
||||
<div class="card p-6">
|
||||
<h2 class="text-lg font-semibold text-white mb-4">Basic Settings</h2>
|
||||
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-300 mb-1">Name *</label>
|
||||
<input type="text" asp-for="Object.Name" class="input w-full" required />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-300 mb-1">Description</label>
|
||||
<textarea asp-for="Object.Description" rows="2" class="input w-full"></textarea>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-300 mb-1">Type</label>
|
||||
<select asp-for="Object.Type" class="input w-full">
|
||||
@foreach (var t in types)
|
||||
{
|
||||
<option value="@t">@t</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-300 mb-1">Biome</label>
|
||||
<input type="text" asp-for="Object.Biome" class="input w-full" placeholder="dungeon" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-300 mb-1">Tags</label>
|
||||
<input type="text" asp-for="Object.Tags" class="input w-full" placeholder="stone,dark" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-2">
|
||||
<input type="checkbox" asp-for="Object.IsEnabled" class="rounded" />
|
||||
<label asp-for="Object.IsEnabled" class="text-gray-300">Enabled</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card p-6">
|
||||
<h2 class="text-lg font-semibold text-white mb-4">Size & Blocking</h2>
|
||||
|
||||
<div class="grid grid-cols-2 gap-4 mb-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-300 mb-1">Width (tiles)</label>
|
||||
<input type="number" asp-for="Object.Width" class="input w-full" min="1" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-300 mb-1">Height (tiles)</label>
|
||||
<input type="number" asp-for="Object.Height" class="input w-full" min="1" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-3">
|
||||
<div class="flex items-center gap-2">
|
||||
<input type="checkbox" asp-for="Object.BlocksMovement" class="rounded" />
|
||||
<label asp-for="Object.BlocksMovement" class="text-gray-300">Blocks Movement</label>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<input type="checkbox" asp-for="Object.BlocksProjectiles" class="rounded" />
|
||||
<label asp-for="Object.BlocksProjectiles" class="text-gray-300">Blocks Projectiles</label>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<input type="checkbox" asp-for="Object.BlocksLineOfSight" class="rounded" />
|
||||
<label asp-for="Object.BlocksLineOfSight" class="text-gray-300">Blocks Line of Sight</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Middle Column: Sprite & Animation -->
|
||||
<div class="space-y-6">
|
||||
<div class="card p-6">
|
||||
<h2 class="text-lg font-semibold text-white mb-4">Sprite</h2>
|
||||
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-300 mb-1">Sprite Sheet</label>
|
||||
<select asp-for="Object.SpriteSheetId" class="input w-full" id="spriteSheetSelect">
|
||||
<option value="">-- Use CDN Path Instead --</option>
|
||||
@foreach (var sheet in Model.SpriteSheets)
|
||||
{
|
||||
<option value="@sheet.Id"
|
||||
data-cdn="@sheet.CdnPath"
|
||||
data-cols="@sheet.Columns"
|
||||
data-tw="@sheet.TileWidth"
|
||||
data-th="@sheet.TileHeight"
|
||||
data-sw="@sheet.SheetWidth"
|
||||
data-sh="@sheet.SheetHeight">
|
||||
@sheet.Name (@sheet.TotalTiles tiles)
|
||||
</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-300 mb-1">Frame Index</label>
|
||||
<input type="number" asp-for="Object.FrameIndex" class="input w-full" min="0" id="frameIndexInput" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-300 mb-1">Or CDN Path</label>
|
||||
<input type="text" asp-for="Object.SpritePath" class="input w-full" placeholder="objects/chest.png" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Preview -->
|
||||
<div class="mt-4 bg-gray-900 rounded-lg p-4 min-h-[100px] flex items-center justify-center" id="spritePreview">
|
||||
<span class="text-gray-600">Select a sprite to preview</span>
|
||||
</div>
|
||||
|
||||
<!-- Frame Picker -->
|
||||
<div id="framePicker" class="mt-4 hidden">
|
||||
<label class="block text-sm font-medium text-gray-300 mb-2">Click to select frame:</label>
|
||||
<div class="bg-gray-900 rounded-lg p-2 overflow-auto max-h-[250px]">
|
||||
<div id="frameGrid" class="relative inline-block" style="image-rendering: pixelated;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card p-6">
|
||||
<h2 class="text-lg font-semibold text-white mb-4">Animation</h2>
|
||||
|
||||
<div class="space-y-4">
|
||||
<div class="flex items-center gap-2">
|
||||
<input type="checkbox" asp-for="Object.IsAnimated" class="rounded" id="isAnimatedCheck" />
|
||||
<label asp-for="Object.IsAnimated" class="text-gray-300">Is Animated</label>
|
||||
</div>
|
||||
|
||||
<div id="animationSettings" class="space-y-4">
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-300 mb-1">Frame Count</label>
|
||||
<input type="number" asp-for="Object.AnimationFrameCount" class="input w-full" min="1" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-300 mb-1">FPS</label>
|
||||
<input type="number" asp-for="Object.AnimationFps" class="input w-full" min="1" step="0.1" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-2">
|
||||
<input type="checkbox" asp-for="Object.AnimationLoops" class="rounded" />
|
||||
<label asp-for="Object.AnimationLoops" class="text-gray-300">Loops</label>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-300 mb-1">Animation States (JSON)</label>
|
||||
<textarea asp-for="Object.AnimationStatesJson" rows="3" class="input w-full font-mono text-xs"
|
||||
placeholder='{"idle":{"startFrame":0,"frameCount":4,"fps":8}}'></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Right Column: Interaction & Rewards -->
|
||||
<div class="space-y-6">
|
||||
<div class="card p-6">
|
||||
<h2 class="text-lg font-semibold text-white mb-4">Interaction</h2>
|
||||
|
||||
<div class="space-y-4">
|
||||
<div class="flex items-center gap-2">
|
||||
<input type="checkbox" asp-for="Object.IsInteractable" class="rounded" />
|
||||
<label asp-for="Object.IsInteractable" class="text-gray-300">Is Interactable (Click)</label>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-2">
|
||||
<input type="checkbox" asp-for="Object.TriggeredByWalk" class="rounded" />
|
||||
<label asp-for="Object.TriggeredByWalk" class="text-gray-300">Triggered by Walking</label>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-300 mb-1">Interaction Type</label>
|
||||
<select asp-for="Object.InteractionType" class="input w-full">
|
||||
@foreach (var t in interactionTypes)
|
||||
{
|
||||
<option value="@t">@t</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-300 mb-1">Interaction State</label>
|
||||
<input type="text" asp-for="Object.InteractionState" class="input w-full" placeholder="open" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-300 mb-1">Cooldown (seconds)</label>
|
||||
<input type="number" asp-for="Object.InteractionCooldown" class="input w-full" min="0" step="0.1" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card p-6">
|
||||
<h2 class="text-lg font-semibold text-white mb-4">Loot & Rewards</h2>
|
||||
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-300 mb-1">Loot Table</label>
|
||||
<select asp-for="Object.LootTableId" class="input w-full">
|
||||
<option value="">-- None --</option>
|
||||
@foreach (var lt in Model.LootTables)
|
||||
{
|
||||
<option value="@lt.Id">@lt.Name</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-300 mb-1">Gold</label>
|
||||
<input type="number" asp-for="Object.GoldAmount" class="input w-full" min="0" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-300 mb-1">XP</label>
|
||||
<input type="number" asp-for="Object.XpReward" class="input w-full" min="0" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card p-6">
|
||||
<h2 class="text-lg font-semibold text-white mb-4">Trap / Hazard</h2>
|
||||
|
||||
<div class="space-y-4">
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-300 mb-1">Damage</label>
|
||||
<input type="number" asp-for="Object.Damage" class="input w-full" min="0" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-300 mb-1">Damage Type</label>
|
||||
<select asp-for="Object.DamageTypeKey" class="input w-full">
|
||||
<option value="">-- None --</option>
|
||||
@foreach (var dt in Model.DamageTypes)
|
||||
{
|
||||
<option value="@dt.Key">@dt.Name</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-300 mb-1">Trigger Delay</label>
|
||||
<input type="number" asp-for="Object.TriggerDelay" class="input w-full" min="0" step="0.1" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-300 mb-1">Reset Time</label>
|
||||
<input type="number" asp-for="Object.ResetTime" class="input w-full" min="0" step="0.1" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card p-6">
|
||||
<h2 class="text-lg font-semibold text-white mb-4">Generation</h2>
|
||||
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-300 mb-1">Weight</label>
|
||||
<input type="number" asp-for="Object.Weight" class="input w-full" min="1" />
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-300 mb-1">Min Tier</label>
|
||||
<input type="number" asp-for="Object.MinTier" class="input w-full" min="1" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-300 mb-1">Max Tier</label>
|
||||
<input type="number" asp-for="Object.MaxTier" class="input w-full" min="0" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end gap-4 mt-6">
|
||||
<a href="/admin/dungeonbuilder/objects" class="btn btn-ghost">Cancel</a>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
@(Model.Object.Id == 0 ? "Create Object" : "Save Changes")
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
const cdnBaseUrl = '@Model.CdnBaseUrl';
|
||||
const sheetSelect = document.getElementById('spriteSheetSelect');
|
||||
const frameIndexInput = document.getElementById('frameIndexInput');
|
||||
const spritePreview = document.getElementById('spritePreview');
|
||||
const framePicker = document.getElementById('framePicker');
|
||||
const frameGrid = document.getElementById('frameGrid');
|
||||
|
||||
function updateSpritePreview() {
|
||||
const option = sheetSelect.selectedOptions[0];
|
||||
|
||||
if (!option || !option.value) {
|
||||
framePicker.classList.add('hidden');
|
||||
spritePreview.innerHTML = '<span class="text-gray-600">Select a sprite sheet</span>';
|
||||
return;
|
||||
}
|
||||
|
||||
const cdn = option.dataset.cdn;
|
||||
const cols = parseInt(option.dataset.cols);
|
||||
const tw = parseInt(option.dataset.tw);
|
||||
const th = parseInt(option.dataset.th);
|
||||
const sw = parseInt(option.dataset.sw);
|
||||
const sh = parseInt(option.dataset.sh);
|
||||
const frameIndex = parseInt(frameIndexInput.value) || 0;
|
||||
|
||||
const col = frameIndex % cols;
|
||||
const row = Math.floor(frameIndex / cols);
|
||||
const bgX = -col * tw;
|
||||
const bgY = -row * th;
|
||||
const imgUrl = `${cdnBaseUrl}/downloads/${cdn}`;
|
||||
|
||||
spritePreview.innerHTML = `
|
||||
<div style="width: ${tw}px; height: ${th}px;
|
||||
background: url('${imgUrl}') ${bgX}px ${bgY}px no-repeat;
|
||||
background-size: ${sw}px ${sh}px;
|
||||
image-rendering: pixelated;
|
||||
transform: scale(2);"></div>
|
||||
`;
|
||||
|
||||
framePicker.classList.remove('hidden');
|
||||
const rows = Math.ceil((cols * Math.ceil(sh / th)) / cols);
|
||||
frameGrid.innerHTML = `
|
||||
<img src="${imgUrl}" style="display: block;" />
|
||||
<div class="absolute inset-0" style="display: grid; grid-template-columns: repeat(${cols}, ${tw}px);">
|
||||
${Array.from({length: cols * rows}, (_, i) => {
|
||||
const selected = i === frameIndex;
|
||||
return `<div class="border border-white/20 hover:bg-blue-500/30 cursor-pointer ${selected ? 'ring-2 ring-yellow-400' : ''}"
|
||||
style="width: ${tw}px; height: ${th}px;"
|
||||
onclick="selectFrame(${i})"></div>`;
|
||||
}).join('')}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
function selectFrame(index) {
|
||||
frameIndexInput.value = index;
|
||||
updateSpritePreview();
|
||||
}
|
||||
|
||||
sheetSelect.addEventListener('change', updateSpritePreview);
|
||||
frameIndexInput.addEventListener('change', updateSpritePreview);
|
||||
updateSpritePreview();
|
||||
</script>
|
||||
@@ -0,0 +1,170 @@
|
||||
using DataServer.Data;
|
||||
using DataServer.Data.Entities;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Server.Services.Admin.Pages.DungeonBuilder;
|
||||
|
||||
public class ObjectEditModel : AdminPageModel
|
||||
{
|
||||
private readonly GameDbContext _db;
|
||||
private readonly IConfiguration _config;
|
||||
|
||||
public ObjectEditModel(GameDbContext db, IConfiguration config)
|
||||
{
|
||||
_db = db;
|
||||
_config = config;
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public ObjectTemplate Object { get; set; } = new();
|
||||
|
||||
public List<TileMapSheet> SpriteSheets { get; set; } = new();
|
||||
public List<DungeonLootTable> LootTables { get; set; } = new();
|
||||
public List<DamageResistanceType> DamageTypes { get; set; } = new();
|
||||
public List<string> CdnImages { get; set; } = new();
|
||||
|
||||
public string CdnBaseUrl => _config["Cdn:BaseUrl"]?.TrimEnd('/') ?? "";
|
||||
|
||||
public string? Message { get; set; }
|
||||
public bool IsError { get; set; }
|
||||
|
||||
public async Task OnGetAsync(int? id)
|
||||
{
|
||||
await LoadReferenceData();
|
||||
|
||||
if (id.HasValue)
|
||||
{
|
||||
var obj = await _db.ObjectTemplates
|
||||
.Include(o => o.SpriteSheet)
|
||||
.FirstOrDefaultAsync(o => o.Id == id.Value);
|
||||
|
||||
if (obj != null)
|
||||
{
|
||||
Object = obj;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Defaults for new object
|
||||
Object.IsEnabled = true;
|
||||
Object.Weight = 100;
|
||||
Object.Width = 1;
|
||||
Object.Height = 1;
|
||||
Object.AnimationFps = 8.0f;
|
||||
Object.AnimationFrameCount = 1;
|
||||
Object.AnimationLoops = true;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
await LoadReferenceData();
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
IsError = true;
|
||||
Message = "Please fix validation errors.";
|
||||
return Page();
|
||||
}
|
||||
|
||||
Object.UpdatedAt = DateTime.UtcNow;
|
||||
|
||||
if (Object.Id == 0)
|
||||
{
|
||||
Object.CreatedAt = DateTime.UtcNow;
|
||||
_db.ObjectTemplates.Add(Object);
|
||||
Message = "Object template created!";
|
||||
}
|
||||
else
|
||||
{
|
||||
var existing = await _db.ObjectTemplates.FindAsync(Object.Id);
|
||||
if (existing == null)
|
||||
{
|
||||
IsError = true;
|
||||
Message = "Object not found.";
|
||||
return Page();
|
||||
}
|
||||
|
||||
// Update properties
|
||||
existing.Name = Object.Name;
|
||||
existing.Description = Object.Description;
|
||||
existing.Type = Object.Type;
|
||||
existing.Tags = Object.Tags;
|
||||
existing.Biome = Object.Biome;
|
||||
existing.SpriteSheetId = Object.SpriteSheetId;
|
||||
existing.FrameIndex = Object.FrameIndex;
|
||||
existing.SpritePath = Object.SpritePath;
|
||||
existing.Width = Object.Width;
|
||||
existing.Height = Object.Height;
|
||||
existing.OffsetX = Object.OffsetX;
|
||||
existing.OffsetY = Object.OffsetY;
|
||||
existing.ZIndex = Object.ZIndex;
|
||||
existing.BlocksMovement = Object.BlocksMovement;
|
||||
existing.BlocksProjectiles = Object.BlocksProjectiles;
|
||||
existing.BlocksLineOfSight = Object.BlocksLineOfSight;
|
||||
existing.BlockedCellsJson = Object.BlockedCellsJson;
|
||||
existing.IsAnimated = Object.IsAnimated;
|
||||
existing.AnimationFrameCount = Object.AnimationFrameCount;
|
||||
existing.AnimationFps = Object.AnimationFps;
|
||||
existing.AnimationLoops = Object.AnimationLoops;
|
||||
existing.AnimationStatesJson = Object.AnimationStatesJson;
|
||||
existing.DefaultState = Object.DefaultState;
|
||||
existing.IsInteractable = Object.IsInteractable;
|
||||
existing.TriggeredByWalk = Object.TriggeredByWalk;
|
||||
existing.InteractionType = Object.InteractionType;
|
||||
existing.InteractionState = Object.InteractionState;
|
||||
existing.InteractionCooldown = Object.InteractionCooldown;
|
||||
existing.RequiredItemId = Object.RequiredItemId;
|
||||
existing.LootTableId = Object.LootTableId;
|
||||
existing.GoldAmount = Object.GoldAmount;
|
||||
existing.XpReward = Object.XpReward;
|
||||
existing.IsDestructible = Object.IsDestructible;
|
||||
existing.Health = Object.Health;
|
||||
existing.DestroyedState = Object.DestroyedState;
|
||||
existing.DestroyedLootTableId = Object.DestroyedLootTableId;
|
||||
existing.Damage = Object.Damage;
|
||||
existing.DamageTypeKey = Object.DamageTypeKey;
|
||||
existing.TriggerDelay = Object.TriggerDelay;
|
||||
existing.ResetTime = Object.ResetTime;
|
||||
existing.Weight = Object.Weight;
|
||||
existing.MinTier = Object.MinTier;
|
||||
existing.MaxTier = Object.MaxTier;
|
||||
existing.MaxPerRoom = Object.MaxPerRoom;
|
||||
existing.Placement = Object.Placement;
|
||||
existing.IsEnabled = Object.IsEnabled;
|
||||
existing.UpdatedAt = DateTime.UtcNow;
|
||||
|
||||
Message = "Changes saved!";
|
||||
}
|
||||
|
||||
await _db.SaveChangesAsync();
|
||||
|
||||
return RedirectToPage(new { id = Object.Id });
|
||||
}
|
||||
|
||||
private async Task LoadReferenceData()
|
||||
{
|
||||
SpriteSheets = await _db.TileMapSheets
|
||||
.Where(s => s.IsEnabled)
|
||||
.OrderBy(s => s.Name)
|
||||
.ToListAsync();
|
||||
|
||||
LootTables = await _db.DungeonLootTables
|
||||
.Where(t => t.IsEnabled)
|
||||
.OrderBy(t => t.Name)
|
||||
.ToListAsync();
|
||||
|
||||
DamageTypes = await _db.DamageResistanceTypes
|
||||
.OrderBy(d => d.Name)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public string GetCdnUrl(string? path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path)) return "";
|
||||
var baseUrl = CdnBaseUrl;
|
||||
if (!baseUrl.EndsWith("/downloads")) baseUrl += "/downloads";
|
||||
return $"{baseUrl}/{path.TrimStart('/')}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
@page "/admin/dungeonbuilder/objects"
|
||||
@model DungeonBuilder.ObjectsModel
|
||||
@using DataServer.Data.Entities
|
||||
@{
|
||||
ViewData["Title"] = "Object Templates";
|
||||
var types = Enum.GetValues<ObjectTemplateType>();
|
||||
}
|
||||
|
||||
<div class="mb-4">
|
||||
<a href="/admin/dungeonbuilder" class="text-blue-400 hover:text-blue-300 text-sm">← Back to Dungeon Builder</a>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3 mb-6">
|
||||
<div>
|
||||
<h1 class="text-2xl font-bold text-white">Object Templates</h1>
|
||||
<p class="text-gray-400 text-sm mt-1">Furniture, containers, traps, and decorations</p>
|
||||
</div>
|
||||
<a href="/admin/dungeonbuilder/objects/edit" class="btn btn-primary">+ New Object</a>
|
||||
</div>
|
||||
|
||||
@if (!string.IsNullOrEmpty(Model.Message))
|
||||
{
|
||||
<div class="mb-4 p-3 rounded @(Model.IsError ? "bg-red-900/50 text-red-300" : "bg-green-900/50 text-green-300")">
|
||||
@Model.Message
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- Filters -->
|
||||
<div class="card p-4 mb-4">
|
||||
<form method="get" class="flex flex-wrap gap-3">
|
||||
<div class="flex-1 min-w-[150px]">
|
||||
<input type="text" name="search" value="@Model.Search"
|
||||
class="input w-full text-sm" placeholder="Search by name..." />
|
||||
</div>
|
||||
<select name="type" class="input text-sm">
|
||||
<option value="">All Types</option>
|
||||
@foreach (var t in types)
|
||||
{
|
||||
<option value="@((int)t)" selected="@(Model.TypeFilter == (int)t)">@t</option>
|
||||
}
|
||||
</select>
|
||||
<select name="biome" class="input text-sm">
|
||||
<option value="">All Biomes</option>
|
||||
@foreach (var b in Model.Biomes)
|
||||
{
|
||||
<option value="@b" selected="@(Model.BiomeFilter == b)">@b</option>
|
||||
}
|
||||
</select>
|
||||
<button type="submit" class="btn btn-secondary text-sm">Filter</button>
|
||||
<a href="/admin/dungeonbuilder/objects" class="btn btn-ghost text-sm">Clear</a>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Objects Grid -->
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4">
|
||||
@foreach (var obj in Model.Objects)
|
||||
{
|
||||
<div class="card p-4 hover:border-purple-500/50 transition-colors">
|
||||
<div class="flex items-start gap-3">
|
||||
<!-- Preview -->
|
||||
<div class="w-16 h-16 bg-gray-900 rounded flex items-center justify-center flex-shrink-0">
|
||||
@if (obj.SpriteSheetId.HasValue && obj.SpriteSheet != null)
|
||||
{
|
||||
var cols = obj.SpriteSheet.TileWidth > 0 ? obj.SpriteSheet.SheetWidth / obj.SpriteSheet.TileWidth : 1;
|
||||
var row = obj.FrameIndex / cols;
|
||||
var col = obj.FrameIndex % cols;
|
||||
var bgX = -col * obj.SpriteSheet.TileWidth;
|
||||
var bgY = -row * obj.SpriteSheet.TileHeight;
|
||||
var imgUrl = Model.GetCdnUrl(obj.SpriteSheet.CdnPath);
|
||||
|
||||
<div style="width: @(obj.SpriteSheet.TileWidth)px; height: @(obj.SpriteSheet.TileHeight)px;
|
||||
background: url('@imgUrl') @(bgX)px @(bgY)px no-repeat;
|
||||
background-size: @(obj.SpriteSheet.SheetWidth)px @(obj.SpriteSheet.SheetHeight)px;
|
||||
image-rendering: pixelated;"></div>
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(obj.SpritePath))
|
||||
{
|
||||
<img src="@Model.GetCdnUrl(obj.SpritePath)" alt="@obj.Name" class="max-w-full max-h-full" style="image-rendering: pixelated;" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="text-gray-600 text-2xl">📦</span>
|
||||
}
|
||||
</div>
|
||||
|
||||
<!-- Info -->
|
||||
<div class="flex-1 min-w-0">
|
||||
<h3 class="font-semibold text-white truncate">@obj.Name</h3>
|
||||
<div class="text-xs text-gray-400 mt-1">
|
||||
<span class="@GetTypeColor(obj.Type)">@obj.Type</span>
|
||||
@if (!string.IsNullOrEmpty(obj.Biome))
|
||||
{
|
||||
<span class="ml-2">@obj.Biome</span>
|
||||
}
|
||||
</div>
|
||||
|
||||
<!-- Flags -->
|
||||
<div class="flex flex-wrap gap-1 mt-2">
|
||||
@if (obj.IsInteractable)
|
||||
{
|
||||
<span class="px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded text-xs">Interactive</span>
|
||||
}
|
||||
@if (obj.TriggeredByWalk)
|
||||
{
|
||||
<span class="px-1.5 py-0.5 bg-yellow-500/20 text-yellow-400 rounded text-xs">Walk Trigger</span>
|
||||
}
|
||||
@if (obj.IsAnimated)
|
||||
{
|
||||
<span class="px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded text-xs">Animated</span>
|
||||
}
|
||||
@if (obj.BlocksMovement)
|
||||
{
|
||||
<span class="px-1.5 py-0.5 bg-red-500/20 text-red-400 rounded text-xs">Solid</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-between mt-3 pt-3 border-t border-gray-700">
|
||||
<span class="text-xs text-gray-500">ID: @obj.Id</span>
|
||||
<div class="flex gap-2">
|
||||
<a href="/admin/dungeonbuilder/objects/edit?id=@obj.Id" class="text-blue-400 hover:text-blue-300 text-sm">Edit</a>
|
||||
<form method="post" asp-page-handler="Delete" class="inline" onsubmit="return confirm('Delete this object?');">
|
||||
<input type="hidden" name="id" value="@obj.Id" />
|
||||
<button type="submit" class="text-red-400 hover:text-red-300 text-sm">Delete</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (!Model.Objects.Any())
|
||||
{
|
||||
<div class="col-span-full card p-8 text-center text-gray-500">
|
||||
No object templates found. <a href="/admin/dungeonbuilder/objects/edit" class="text-blue-400 hover:underline">Create one</a>!
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<!-- Pagination -->
|
||||
@if (Model.TotalPages > 1)
|
||||
{
|
||||
<div class="flex justify-center gap-2 mt-6">
|
||||
@for (int i = 1; i <= Model.TotalPages; i++)
|
||||
{
|
||||
<a href="?page=@i&search=@Model.Search&type=@Model.TypeFilter&biome=@Model.BiomeFilter"
|
||||
class="px-3 py-1 rounded @(i == Model.CurrentPage ? "bg-purple-600 text-white" : "bg-gray-700 text-gray-300 hover:bg-gray-600")">
|
||||
@i
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@functions {
|
||||
string GetTypeColor(ObjectTemplateType type)
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
ObjectTemplateType.Decoration => "text-gray-400",
|
||||
ObjectTemplateType.Furniture => "text-blue-400",
|
||||
ObjectTemplateType.Container => "text-yellow-400",
|
||||
ObjectTemplateType.Obstacle => "text-orange-400",
|
||||
ObjectTemplateType.Trap => "text-red-400",
|
||||
ObjectTemplateType.Hazard => "text-red-500",
|
||||
ObjectTemplateType.Door => "text-purple-400",
|
||||
ObjectTemplateType.Switch => "text-cyan-400",
|
||||
ObjectTemplateType.Portal => "text-pink-400",
|
||||
ObjectTemplateType.Shrine => "text-green-400",
|
||||
ObjectTemplateType.Vendor => "text-emerald-400",
|
||||
ObjectTemplateType.Light => "text-yellow-300",
|
||||
ObjectTemplateType.Spawner => "text-orange-500",
|
||||
_ => "text-gray-400"
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
using DataServer.Data;
|
||||
using DataServer.Data.Entities;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Server.Services.Admin.Pages.DungeonBuilder;
|
||||
|
||||
public class ObjectsModel : AdminPageModel
|
||||
{
|
||||
private readonly GameDbContext _db;
|
||||
private readonly IConfiguration _config;
|
||||
|
||||
public ObjectsModel(GameDbContext db, IConfiguration config)
|
||||
{
|
||||
_db = db;
|
||||
_config = config;
|
||||
}
|
||||
|
||||
public List<ObjectTemplate> Objects { get; set; } = new();
|
||||
public List<string> Biomes { get; set; } = new();
|
||||
|
||||
public string? Search { get; set; }
|
||||
public int? TypeFilter { get; set; }
|
||||
public string? BiomeFilter { get; set; }
|
||||
|
||||
public int CurrentPage { get; set; } = 1;
|
||||
public int TotalPages { get; set; }
|
||||
public int PageSize { get; set; } = 20;
|
||||
|
||||
public string? Message { get; set; }
|
||||
public bool IsError { get; set; }
|
||||
|
||||
public async Task OnGetAsync(string? search, int? type, string? biome, int page = 1)
|
||||
{
|
||||
Search = search;
|
||||
TypeFilter = type;
|
||||
BiomeFilter = biome;
|
||||
CurrentPage = Math.Max(1, page);
|
||||
|
||||
// Get unique biomes
|
||||
Biomes = await _db.ObjectTemplates
|
||||
.Where(o => o.Biome != null)
|
||||
.Select(o => o.Biome!)
|
||||
.Distinct()
|
||||
.OrderBy(b => b)
|
||||
.ToListAsync();
|
||||
|
||||
// Build query
|
||||
var query = _db.ObjectTemplates
|
||||
.Include(o => o.SpriteSheet)
|
||||
.AsQueryable();
|
||||
|
||||
if (!string.IsNullOrEmpty(search))
|
||||
{
|
||||
query = query.Where(o => o.Name.Contains(search) || (o.Tags != null && o.Tags.Contains(search)));
|
||||
}
|
||||
|
||||
if (type.HasValue)
|
||||
{
|
||||
query = query.Where(o => o.Type == (ObjectTemplateType)type.Value);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(biome))
|
||||
{
|
||||
query = query.Where(o => o.Biome == biome);
|
||||
}
|
||||
|
||||
var total = await query.CountAsync();
|
||||
TotalPages = (int)Math.Ceiling(total / (double)PageSize);
|
||||
|
||||
Objects = await query
|
||||
.OrderBy(o => o.Name)
|
||||
.Skip((CurrentPage - 1) * PageSize)
|
||||
.Take(PageSize)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostDeleteAsync(int id)
|
||||
{
|
||||
var obj = await _db.ObjectTemplates.FindAsync(id);
|
||||
if (obj != null)
|
||||
{
|
||||
_db.ObjectTemplates.Remove(obj);
|
||||
await _db.SaveChangesAsync();
|
||||
Message = $"Deleted object template: {obj.Name}";
|
||||
}
|
||||
|
||||
return RedirectToPage();
|
||||
}
|
||||
|
||||
public string GetCdnUrl(string? path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path)) return "";
|
||||
|
||||
var baseUrl = _config["Cdn:BaseUrl"]?.TrimEnd('/') ?? "";
|
||||
if (!baseUrl.EndsWith("/downloads"))
|
||||
{
|
||||
baseUrl += "/downloads";
|
||||
}
|
||||
|
||||
return $"{baseUrl}/{path.TrimStart('/')}";
|
||||
}
|
||||
}
|
||||
@@ -166,6 +166,13 @@
|
||||
Room Templates
|
||||
</a>
|
||||
|
||||
<a href="/admin/dungeonbuilder" class="sidebar-link @(ViewContext.RouteData.Values["page"]?.ToString()?.Contains("DungeonBuilder") == true ? "active" : "")" onclick="closeMobileMenu()">
|
||||
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 4a2 2 0 114 0v1a1 1 0 001 1h3a1 1 0 011 1v3a1 1 0 01-1 1h-1a2 2 0 100 4h1a1 1 0 011 1v3a1 1 0 01-1 1h-3a1 1 0 01-1-1v-1a2 2 0 10-4 0v1a1 1 0 01-1 1H7a1 1 0 01-1-1v-3a1 1 0 00-1-1H4a2 2 0 110-4h1a1 1 0 001-1V7a1 1 0 011-1h3a1 1 0 001-1V4z"/>
|
||||
</svg>
|
||||
Dungeon Builder
|
||||
</a>
|
||||
|
||||
<a href="/admin/assets" class="sidebar-link @(ViewContext.RouteData.Values["page"]?.ToString()?.StartsWith("/Assets") == true ? "active" : "")" onclick="closeMobileMenu()">
|
||||
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"/>
|
||||
|
||||
@@ -39,6 +39,12 @@ public sealed class GameDbContext : DbContext
|
||||
public DbSet<RoomTemplate> RoomTemplates => Set<RoomTemplate>();
|
||||
public DbSet<DungeonTemplate> DungeonTemplates => Set<DungeonTemplate>();
|
||||
public DbSet<DungeonObjectDefinition> DungeonObjects => Set<DungeonObjectDefinition>();
|
||||
|
||||
// Dungeon Builder system
|
||||
public DbSet<TileTemplate> TileTemplates => Set<TileTemplate>();
|
||||
public DbSet<ObjectTemplate> ObjectTemplates => Set<ObjectTemplate>();
|
||||
public DbSet<BuilderRoomTemplate> BuilderRoomTemplates => Set<BuilderRoomTemplate>();
|
||||
public DbSet<DungeonPalette> DungeonPalettes => Set<DungeonPalette>();
|
||||
|
||||
public DbSet<DungeonBeltItem> DungeonBeltItems => Set<DungeonBeltItem>();
|
||||
public DbSet<DeathChest> DeathChests => Set<DeathChest>();
|
||||
|
||||
@@ -0,0 +1,646 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace DataServer.Data.Entities;
|
||||
|
||||
// =============================================================================
|
||||
// DUNGEON BUILDER SYSTEM
|
||||
// =============================================================================
|
||||
// This system provides a visual GUI for building dungeon content:
|
||||
// 1. Sprite Sheet Management - Upload sheets, tag individual tiles
|
||||
// 2. Tile Templates - Reusable floor/wall/door configurations
|
||||
// 3. Object Templates - Multi-tile objects with animations and interactions
|
||||
// 4. Room Templates - Pre-built room layouts using tiles and objects
|
||||
// 5. Dungeon Palettes - Collections of compatible templates for generation
|
||||
// =============================================================================
|
||||
|
||||
/// <summary>
|
||||
/// A reusable tile template (single tile or multi-tile pattern)
|
||||
/// Examples: "Stone Floor", "Corner Wall NE", "2x2 Pillar", "3x1 Bookshelf"
|
||||
/// </summary>
|
||||
[Table("tile_templates")]
|
||||
public class TileTemplate
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>Template name (e.g., "Stone Floor Clean", "Wall Corner NE")</summary>
|
||||
[Required, MaxLength(64)]
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
/// <summary>Description</summary>
|
||||
[MaxLength(256)]
|
||||
public string? Description { get; set; }
|
||||
|
||||
/// <summary>Template category for organization</summary>
|
||||
public TileTemplateCategory Category { get; set; } = TileTemplateCategory.Floor;
|
||||
|
||||
/// <summary>Tags for filtering (e.g., "stone,dungeon,clean")</summary>
|
||||
[MaxLength(256)]
|
||||
public string? Tags { get; set; }
|
||||
|
||||
/// <summary>Biome this template belongs to</summary>
|
||||
[MaxLength(32)]
|
||||
public string? Biome { get; set; }
|
||||
|
||||
/// <summary>Width in tiles (for multi-tile templates)</summary>
|
||||
public int Width { get; set; } = 1;
|
||||
|
||||
/// <summary>Height in tiles (for multi-tile templates)</summary>
|
||||
public int Height { get; set; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// JSON array of tile placements for this template
|
||||
/// Format: [{ "x": 0, "y": 0, "tileDefinitionId": 123, "layer": 0 }, ...]
|
||||
/// </summary>
|
||||
[Column(TypeName = "json")]
|
||||
public string? TilesJson { get; set; }
|
||||
|
||||
/// <summary>Primary tile definition (for 1x1 templates)</summary>
|
||||
public int? PrimaryTileDefinitionId { get; set; }
|
||||
|
||||
[ForeignKey(nameof(PrimaryTileDefinitionId))]
|
||||
public TileDefinition? PrimaryTileDefinition { get; set; }
|
||||
|
||||
// --- Blocking Properties (derived from constituent tiles or overridden) ---
|
||||
|
||||
/// <summary>Override: Can entities walk on this template?</summary>
|
||||
public bool IsWalkable { get; set; } = true;
|
||||
|
||||
/// <summary>Override: Does this block projectiles?</summary>
|
||||
public bool BlocksProjectiles { get; set; } = false;
|
||||
|
||||
/// <summary>Override: Does this block line of sight?</summary>
|
||||
public bool BlocksLineOfSight { get; set; } = false;
|
||||
|
||||
/// <summary>Override: Does this block movement?</summary>
|
||||
public bool BlocksMovement { get; set; } = false;
|
||||
|
||||
// --- Socket Configuration (for WFC-style matching) ---
|
||||
|
||||
/// <summary>North edge socket type</summary>
|
||||
public SocketType SocketN { get; set; } = SocketType.Open;
|
||||
|
||||
/// <summary>East edge socket type</summary>
|
||||
public SocketType SocketE { get; set; } = SocketType.Open;
|
||||
|
||||
/// <summary>South edge socket type</summary>
|
||||
public SocketType SocketS { get; set; } = SocketType.Open;
|
||||
|
||||
/// <summary>West edge socket type</summary>
|
||||
public SocketType SocketW { get; set; } = SocketType.Open;
|
||||
|
||||
/// <summary>Custom socket names (comma-separated for each direction)</summary>
|
||||
[MaxLength(128)]
|
||||
public string? SocketCustom { get; set; }
|
||||
|
||||
// --- Generation Weight ---
|
||||
|
||||
/// <summary>Weight for random selection (higher = more likely)</summary>
|
||||
public int Weight { get; set; } = 100;
|
||||
|
||||
/// <summary>Minimum tier this can appear in</summary>
|
||||
public int MinTier { get; set; } = 1;
|
||||
|
||||
/// <summary>Maximum tier (0 = no limit)</summary>
|
||||
public int MaxTier { get; set; } = 0;
|
||||
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Categories for tile templates
|
||||
/// </summary>
|
||||
public enum TileTemplateCategory
|
||||
{
|
||||
Floor = 0,
|
||||
Wall = 1,
|
||||
Door = 2,
|
||||
Window = 3,
|
||||
Stairs = 4,
|
||||
Pit = 5,
|
||||
Water = 6,
|
||||
Lava = 7,
|
||||
Bridge = 8,
|
||||
Platform = 9,
|
||||
Decoration = 10
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An object that can be placed on tiles (furniture, containers, traps, etc.)
|
||||
/// Enhanced version of DungeonObjectDefinition with more features
|
||||
/// </summary>
|
||||
[Table("object_templates")]
|
||||
public class ObjectTemplate
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>Object name (e.g., "Wooden Chest", "Stone Pillar", "Spike Trap")</summary>
|
||||
[Required, MaxLength(64)]
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
/// <summary>Description</summary>
|
||||
[MaxLength(256)]
|
||||
public string? Description { get; set; }
|
||||
|
||||
/// <summary>Object type category</summary>
|
||||
public ObjectTemplateType Type { get; set; } = ObjectTemplateType.Decoration;
|
||||
|
||||
/// <summary>Tags for filtering</summary>
|
||||
[MaxLength(256)]
|
||||
public string? Tags { get; set; }
|
||||
|
||||
/// <summary>Biome this object belongs to</summary>
|
||||
[MaxLength(32)]
|
||||
public string? Biome { get; set; }
|
||||
|
||||
// --- Sprite Configuration ---
|
||||
|
||||
/// <summary>Sprite sheet ID</summary>
|
||||
public int? SpriteSheetId { get; set; }
|
||||
|
||||
[ForeignKey(nameof(SpriteSheetId))]
|
||||
public TileMapSheet? SpriteSheet { get; set; }
|
||||
|
||||
/// <summary>Frame index in sprite sheet (for static objects)</summary>
|
||||
public int FrameIndex { get; set; } = 0;
|
||||
|
||||
/// <summary>CDN path for standalone sprite</summary>
|
||||
[MaxLength(256)]
|
||||
public string? SpritePath { get; set; }
|
||||
|
||||
// --- Size & Position ---
|
||||
|
||||
/// <summary>Width in tiles</summary>
|
||||
public int Width { get; set; } = 1;
|
||||
|
||||
/// <summary>Height in tiles</summary>
|
||||
public int Height { get; set; } = 1;
|
||||
|
||||
/// <summary>Pixel offset X for precise positioning</summary>
|
||||
public int OffsetX { get; set; } = 0;
|
||||
|
||||
/// <summary>Pixel offset Y for precise positioning</summary>
|
||||
public int OffsetY { get; set; } = 0;
|
||||
|
||||
/// <summary>Z-index for rendering order</summary>
|
||||
public int ZIndex { get; set; } = 10;
|
||||
|
||||
// --- Blocking Properties ---
|
||||
|
||||
/// <summary>Does this object block movement?</summary>
|
||||
public bool BlocksMovement { get; set; } = false;
|
||||
|
||||
/// <summary>Does this object block projectiles?</summary>
|
||||
public bool BlocksProjectiles { get; set; } = false;
|
||||
|
||||
/// <summary>Does this object block line of sight?</summary>
|
||||
public bool BlocksLineOfSight { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// JSON array of blocked cells relative to origin (for multi-tile objects)
|
||||
/// Format: [{ "x": 0, "y": 0 }, { "x": 1, "y": 0 }]
|
||||
/// If null, blocks all cells within Width x Height
|
||||
/// </summary>
|
||||
[Column(TypeName = "json")]
|
||||
public string? BlockedCellsJson { get; set; }
|
||||
|
||||
// --- Animation ---
|
||||
|
||||
/// <summary>Is this object animated?</summary>
|
||||
public bool IsAnimated { get; set; } = false;
|
||||
|
||||
/// <summary>Number of animation frames</summary>
|
||||
public int AnimationFrameCount { get; set; } = 1;
|
||||
|
||||
/// <summary>Animation frames per second</summary>
|
||||
public float AnimationFps { get; set; } = 8.0f;
|
||||
|
||||
/// <summary>Does the animation loop?</summary>
|
||||
public bool AnimationLoops { get; set; } = true;
|
||||
|
||||
// --- Animation States (for objects with multiple states) ---
|
||||
|
||||
/// <summary>
|
||||
/// JSON object defining animation states
|
||||
/// Format: { "idle": { "startFrame": 0, "frameCount": 4, "fps": 8 },
|
||||
/// "open": { "startFrame": 4, "frameCount": 3, "fps": 12 }, ... }
|
||||
/// </summary>
|
||||
[Column(TypeName = "json")]
|
||||
public string? AnimationStatesJson { get; set; }
|
||||
|
||||
/// <summary>Default animation state name</summary>
|
||||
[MaxLength(32)]
|
||||
public string? DefaultState { get; set; } = "idle";
|
||||
|
||||
// --- Interaction ---
|
||||
|
||||
/// <summary>Can this object be interacted with (clicked)?</summary>
|
||||
public bool IsInteractable { get; set; } = false;
|
||||
|
||||
/// <summary>Is this triggered by walking onto it?</summary>
|
||||
public bool TriggeredByWalk { get; set; } = false;
|
||||
|
||||
/// <summary>Interaction type</summary>
|
||||
public ObjectInteractionType InteractionType { get; set; } = ObjectInteractionType.None;
|
||||
|
||||
/// <summary>Animation state to play on interaction</summary>
|
||||
[MaxLength(32)]
|
||||
public string? InteractionState { get; set; }
|
||||
|
||||
/// <summary>Cooldown between interactions (seconds, 0 = one-time)</summary>
|
||||
public float InteractionCooldown { get; set; } = 0;
|
||||
|
||||
/// <summary>Does interaction require a specific item?</summary>
|
||||
public int? RequiredItemId { get; set; }
|
||||
|
||||
// --- Loot / Rewards ---
|
||||
|
||||
/// <summary>Loot table for containers</summary>
|
||||
public int? LootTableId { get; set; }
|
||||
|
||||
/// <summary>Gold amount for treasure</summary>
|
||||
public int GoldAmount { get; set; } = 0;
|
||||
|
||||
/// <summary>XP reward</summary>
|
||||
public int XpReward { get; set; } = 0;
|
||||
|
||||
// --- Destructible ---
|
||||
|
||||
/// <summary>Can this object be destroyed?</summary>
|
||||
public bool IsDestructible { get; set; } = false;
|
||||
|
||||
/// <summary>Health if destructible</summary>
|
||||
public int Health { get; set; } = 0;
|
||||
|
||||
/// <summary>Animation state when destroyed</summary>
|
||||
[MaxLength(32)]
|
||||
public string? DestroyedState { get; set; }
|
||||
|
||||
/// <summary>Loot table when destroyed</summary>
|
||||
public int? DestroyedLootTableId { get; set; }
|
||||
|
||||
// --- Trap / Hazard ---
|
||||
|
||||
/// <summary>Damage dealt (for traps/hazards)</summary>
|
||||
public int Damage { get; set; } = 0;
|
||||
|
||||
/// <summary>Damage type key</summary>
|
||||
[MaxLength(32)]
|
||||
public string? DamageTypeKey { get; set; }
|
||||
|
||||
/// <summary>Trigger delay in seconds</summary>
|
||||
public float TriggerDelay { get; set; } = 0;
|
||||
|
||||
/// <summary>Reset time after triggering (0 = doesn't reset)</summary>
|
||||
public float ResetTime { get; set; } = 0;
|
||||
|
||||
// --- Generation ---
|
||||
|
||||
/// <summary>Weight for random selection</summary>
|
||||
public int Weight { get; set; } = 100;
|
||||
|
||||
/// <summary>Minimum tier</summary>
|
||||
public int MinTier { get; set; } = 1;
|
||||
|
||||
/// <summary>Maximum tier (0 = no limit)</summary>
|
||||
public int MaxTier { get; set; } = 0;
|
||||
|
||||
/// <summary>Maximum count per room (0 = unlimited)</summary>
|
||||
public int MaxPerRoom { get; set; } = 0;
|
||||
|
||||
/// <summary>Valid placement types (floor, wall, ceiling, etc.)</summary>
|
||||
public ObjectPlacement Placement { get; set; } = ObjectPlacement.Floor;
|
||||
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Object template types
|
||||
/// </summary>
|
||||
public enum ObjectTemplateType
|
||||
{
|
||||
Decoration = 0, // Pure visual, no interaction
|
||||
Furniture = 1, // Tables, chairs, beds
|
||||
Container = 2, // Chests, barrels, crates
|
||||
Obstacle = 3, // Pillars, rocks, blocking objects
|
||||
Trap = 4, // Spike traps, pressure plates
|
||||
Hazard = 5, // Fire, poison pools
|
||||
Door = 6, // Interactive doors
|
||||
Switch = 7, // Levers, buttons
|
||||
Portal = 8, // Teleporters
|
||||
Shrine = 9, // Buff stations
|
||||
Vendor = 10, // Shops
|
||||
Light = 11, // Torches, lamps
|
||||
Spawner = 12 // Mob spawn points
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Where objects can be placed
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum ObjectPlacement
|
||||
{
|
||||
Floor = 1,
|
||||
Wall = 2,
|
||||
Ceiling = 4,
|
||||
Water = 8,
|
||||
Pit = 16,
|
||||
Any = Floor | Wall | Ceiling
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A room template built from tile templates and objects
|
||||
/// This is the main building block for dungeon generation
|
||||
/// </summary>
|
||||
[Table("builder_room_templates")]
|
||||
public class BuilderRoomTemplate
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>Room name</summary>
|
||||
[Required, MaxLength(64)]
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
/// <summary>Description</summary>
|
||||
[MaxLength(256)]
|
||||
public string? Description { get; set; }
|
||||
|
||||
/// <summary>Room type</summary>
|
||||
public RoomType Type { get; set; } = RoomType.Normal;
|
||||
|
||||
/// <summary>Tags for filtering</summary>
|
||||
[MaxLength(256)]
|
||||
public string? Tags { get; set; }
|
||||
|
||||
/// <summary>Biome</summary>
|
||||
[MaxLength(32)]
|
||||
public string? Biome { get; set; }
|
||||
|
||||
/// <summary>Width in tiles</summary>
|
||||
public int Width { get; set; } = 10;
|
||||
|
||||
/// <summary>Height in tiles</summary>
|
||||
public int Height { get; set; } = 10;
|
||||
|
||||
// --- Tile Data ---
|
||||
|
||||
/// <summary>
|
||||
/// JSON 2D array of tile template IDs
|
||||
/// Format: [[1,1,1],[1,0,1],[1,1,1]] where 0 = empty, >0 = TileTemplate.Id
|
||||
/// </summary>
|
||||
[Column(TypeName = "json")]
|
||||
public string? TileGridJson { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Alternative: JSON array of tile placements with more detail
|
||||
/// Format: [{ "x": 0, "y": 0, "templateId": 5, "rotation": 0 }, ...]
|
||||
/// </summary>
|
||||
[Column(TypeName = "json")]
|
||||
public string? TilePlacementsJson { get; set; }
|
||||
|
||||
// --- Object Placements ---
|
||||
|
||||
/// <summary>
|
||||
/// JSON array of object placements
|
||||
/// Format: [{ "x": 5, "y": 3, "objectTemplateId": 12, "state": "idle" }, ...]
|
||||
/// </summary>
|
||||
[Column(TypeName = "json")]
|
||||
public string? ObjectPlacementsJson { get; set; }
|
||||
|
||||
// --- Connection Points ---
|
||||
|
||||
/// <summary>
|
||||
/// JSON array of connection points (where hallways attach)
|
||||
/// Format: [{ "x": 5, "y": 0, "direction": "north", "width": 3 }, ...]
|
||||
/// </summary>
|
||||
[Column(TypeName = "json")]
|
||||
public string? ConnectionPointsJson { get; set; }
|
||||
|
||||
// --- Spawn Points ---
|
||||
|
||||
/// <summary>
|
||||
/// JSON array of mob spawn points
|
||||
/// Format: [{ "x": 3, "y": 4, "mobType": "normal", "count": 2 }, ...]
|
||||
/// </summary>
|
||||
[Column(TypeName = "json")]
|
||||
public string? MobSpawnsJson { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// JSON array of item spawn points
|
||||
/// Format: [{ "x": 5, "y": 5, "lootTableId": 3 }, ...]
|
||||
/// </summary>
|
||||
[Column(TypeName = "json")]
|
||||
public string? ItemSpawnsJson { get; set; }
|
||||
|
||||
/// <summary>Player spawn point (for entrance rooms)</summary>
|
||||
public int? PlayerSpawnX { get; set; }
|
||||
public int? PlayerSpawnY { get; set; }
|
||||
|
||||
/// <summary>Exit portal location (for exit rooms)</summary>
|
||||
public int? ExitPortalX { get; set; }
|
||||
public int? ExitPortalY { get; set; }
|
||||
|
||||
// --- Generation Settings ---
|
||||
|
||||
/// <summary>Weight for random selection</summary>
|
||||
public int Weight { get; set; } = 100;
|
||||
|
||||
/// <summary>Minimum tier</summary>
|
||||
public int MinTier { get; set; } = 1;
|
||||
|
||||
/// <summary>Maximum tier (0 = no limit)</summary>
|
||||
public int MaxTier { get; set; } = 0;
|
||||
|
||||
/// <summary>Required connections (minimum number of doors/hallways)</summary>
|
||||
public int MinConnections { get; set; } = 1;
|
||||
|
||||
/// <summary>Maximum connections</summary>
|
||||
public int MaxConnections { get; set; } = 4;
|
||||
|
||||
/// <summary>Can this room be rotated during generation?</summary>
|
||||
public bool AllowRotation { get; set; } = true;
|
||||
|
||||
/// <summary>Can this room be mirrored during generation?</summary>
|
||||
public bool AllowMirror { get; set; } = true;
|
||||
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A dungeon palette - collection of compatible templates for generation
|
||||
/// </summary>
|
||||
[Table("dungeon_palettes")]
|
||||
public class DungeonPalette
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>Palette name (e.g., "Stone Dungeon", "Cave System", "Castle")</summary>
|
||||
[Required, MaxLength(64)]
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
/// <summary>Description</summary>
|
||||
[MaxLength(256)]
|
||||
public string? Description { get; set; }
|
||||
|
||||
/// <summary>Biome</summary>
|
||||
[MaxLength(32)]
|
||||
public string? Biome { get; set; }
|
||||
|
||||
/// <summary>Tags</summary>
|
||||
[MaxLength(256)]
|
||||
public string? Tags { get; set; }
|
||||
|
||||
// --- Template Collections (JSON arrays of IDs) ---
|
||||
|
||||
/// <summary>Floor tile template IDs</summary>
|
||||
[Column(TypeName = "json")]
|
||||
public string? FloorTemplateIdsJson { get; set; }
|
||||
|
||||
/// <summary>Wall tile template IDs</summary>
|
||||
[Column(TypeName = "json")]
|
||||
public string? WallTemplateIdsJson { get; set; }
|
||||
|
||||
/// <summary>Door tile template IDs</summary>
|
||||
[Column(TypeName = "json")]
|
||||
public string? DoorTemplateIdsJson { get; set; }
|
||||
|
||||
/// <summary>Decoration object template IDs</summary>
|
||||
[Column(TypeName = "json")]
|
||||
public string? DecorationIdsJson { get; set; }
|
||||
|
||||
/// <summary>Container object template IDs</summary>
|
||||
[Column(TypeName = "json")]
|
||||
public string? ContainerIdsJson { get; set; }
|
||||
|
||||
/// <summary>Trap object template IDs</summary>
|
||||
[Column(TypeName = "json")]
|
||||
public string? TrapIdsJson { get; set; }
|
||||
|
||||
/// <summary>Room template IDs</summary>
|
||||
[Column(TypeName = "json")]
|
||||
public string? RoomTemplateIdsJson { get; set; }
|
||||
|
||||
// --- Generation Parameters ---
|
||||
|
||||
/// <summary>Default room count range</summary>
|
||||
public int MinRooms { get; set; } = 5;
|
||||
public int MaxRooms { get; set; } = 15;
|
||||
|
||||
/// <summary>Room size range</summary>
|
||||
public int MinRoomWidth { get; set; } = 6;
|
||||
public int MaxRoomWidth { get; set; } = 20;
|
||||
public int MinRoomHeight { get; set; } = 6;
|
||||
public int MaxRoomHeight { get; set; } = 20;
|
||||
|
||||
/// <summary>Corridor width range</summary>
|
||||
public int MinCorridorWidth { get; set; } = 3;
|
||||
public int MaxCorridorWidth { get; set; } = 5;
|
||||
|
||||
/// <summary>Decoration density (0-100)</summary>
|
||||
public int DecorationDensity { get; set; } = 30;
|
||||
|
||||
/// <summary>Trap density (0-100)</summary>
|
||||
public int TrapDensity { get; set; } = 10;
|
||||
|
||||
/// <summary>Container density (0-100)</summary>
|
||||
public int ContainerDensity { get; set; } = 20;
|
||||
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// HELPER CLASSES FOR JSON SERIALIZATION
|
||||
// =============================================================================
|
||||
|
||||
/// <summary>
|
||||
/// A tile placement within a template or room
|
||||
/// </summary>
|
||||
public class BuilderTilePlacement
|
||||
{
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
public int TemplateId { get; set; }
|
||||
public int TileDefinitionId { get; set; }
|
||||
public int Layer { get; set; } = 0;
|
||||
public int Rotation { get; set; } = 0; // 0, 90, 180, 270
|
||||
public bool FlipX { get; set; } = false;
|
||||
public bool FlipY { get; set; } = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An object placement within a room
|
||||
/// </summary>
|
||||
public class BuilderObjectPlacement
|
||||
{
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
public int ObjectTemplateId { get; set; }
|
||||
public string? State { get; set; }
|
||||
public int Rotation { get; set; } = 0;
|
||||
public bool FlipX { get; set; } = false;
|
||||
|
||||
/// <summary>Optional override properties</summary>
|
||||
public string? OverridesJson { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A mob spawn point in a room
|
||||
/// </summary>
|
||||
public class BuilderMobSpawn
|
||||
{
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
public string Type { get; set; } = "normal"; // normal, elite, boss, miniboss
|
||||
public int? MobDefinitionId { get; set; } // Specific mob, or null for random from pool
|
||||
public int Count { get; set; } = 1;
|
||||
public float SpawnChance { get; set; } = 1.0f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An item spawn point in a room
|
||||
/// </summary>
|
||||
public class BuilderItemSpawn
|
||||
{
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
public int? LootTableId { get; set; }
|
||||
public int? ItemDefinitionId { get; set; }
|
||||
public float SpawnChance { get; set; } = 1.0f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Animation state definition
|
||||
/// </summary>
|
||||
public class AnimationState
|
||||
{
|
||||
public string Name { get; set; } = "";
|
||||
public int StartFrame { get; set; } = 0;
|
||||
public int FrameCount { get; set; } = 1;
|
||||
public float Fps { get; set; } = 8.0f;
|
||||
public bool Loop { get; set; } = true;
|
||||
public string? NextState { get; set; } // State to transition to after playing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Blocked cell for multi-tile objects
|
||||
/// </summary>
|
||||
public class BlockedCell
|
||||
{
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
public bool BlocksMovement { get; set; } = true;
|
||||
public bool BlocksProjectiles { get; set; } = false;
|
||||
public bool BlocksLineOfSight { get; set; } = false;
|
||||
}
|
||||
Reference in New Issue
Block a user