Add skybox system: admin management + client 3D application

- SkyboxDefinition entity (catalog schema) with static/animated support
- EF migration: catalog.skybox_definitions table
- content.get_skybox_config handler returns active skybox definition
- SkyboxManagerPage.razor: full CRUD admin UI with inline editing,
  activate/deactivate, and animated frame config
- NavMenu.razor: Skyboxes link under Content section
- game_screen.gd: fetches active skybox on ready; applies as
  PanoramaSkyMaterial on WorldEnvironment; animated skyboxes cycle
  frames via Timer; procedural sky kept as fallback when none active

Also fixes inverted camera pan (delta.x / -delta.y signs corrected).

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
dingo
2026-03-21 08:55:45 -04:00
co-authored by Claude Happy
parent 7c0b0f1953
commit 5b66f459c0
11 changed files with 1173 additions and 6 deletions
+114 -5
View File
@@ -157,6 +157,12 @@ var _unit_bodies : Dictionary = {} # instanceId → StaticBody3D
var _anim_players : Dictionary = {} # instanceId → AnimationPlayer (null if none) var _anim_players : Dictionary = {} # instanceId → AnimationPlayer (null if none)
var _unit_def_ids : Dictionary = {} # instanceId → card definition ID string var _unit_def_ids : Dictionary = {} # instanceId → card definition ID string
# ── Skybox state ───────────────────────────────────────────────────────────────
var _skybox_sky : Sky = null # the Sky object created in _setup_environment
var _skybox_frames : Array = [] # Array[ImageTexture] for animated skybox frames
var _skybox_frame_idx : int = 0
var _skybox_timer : Timer = null
# ── Animation / facing state ─────────────────────────────────────────────────── # ── Animation / facing state ───────────────────────────────────────────────────
var _local_is_p1 : bool = false # true when Auth.user_id == playerOneAccountId var _local_is_p1 : bool = false # true when Auth.user_id == playerOneAccountId
var _prev_unit_hp : Dictionary = {} # instanceId → int, HP snapshot for damage detection var _prev_unit_hp : Dictionary = {} # instanceId → int, HP snapshot for damage detection
@@ -294,18 +300,121 @@ func _setup_spectator_ui() -> void:
func _setup_environment() -> void: func _setup_environment() -> void:
var env := Environment.new() var env := Environment.new()
var sky := Sky.new() _skybox_sky = Sky.new()
var proc := ProceduralSkyMaterial.new() var proc := ProceduralSkyMaterial.new()
proc.sky_top_color = Color(0.08, 0.10, 0.20) proc.sky_top_color = Color(0.08, 0.10, 0.20)
proc.sky_horizon_color = Color(0.28, 0.38, 0.55) proc.sky_horizon_color = Color(0.28, 0.38, 0.55)
proc.ground_bottom_color = Color(0.373, 0.374, 0.484, 1.0) proc.ground_bottom_color = Color(0.373, 0.374, 0.484, 1.0)
proc.ground_horizon_color = Color(0.20, 0.28, 0.38) proc.ground_horizon_color = Color(0.20, 0.28, 0.38)
sky.sky_material = proc _skybox_sky.sky_material = proc
env.background_mode = Environment.BG_SKY env.background_mode = Environment.BG_SKY
env.sky = sky env.sky = _skybox_sky
env.ambient_light_source = Environment.AMBIENT_SOURCE_SKY env.ambient_light_source = Environment.AMBIENT_SOURCE_SKY
env.ambient_light_energy = 0.6 env.ambient_light_energy = 0.6
$WorldEnvironment.environment = env $WorldEnvironment.environment = env
_fetch_skybox()
func _fetch_skybox() -> void:
Network.request("content.get_skybox_config", {},
func(_type: String, resp: Variant) -> void:
var d := resp as Dictionary
var skybox := d.get("skybox", null)
if skybox == null:
return # no active skybox — keep procedural sky
var cdn_path : String = str(skybox.get("cdnPath", ""))
var is_animated : bool = bool(skybox.get("isAnimated", false))
var frame_count : int = int(skybox.get("frameCount", 1))
var fps : float = float(skybox.get("fps", 24.0))
if cdn_path.is_empty():
return
if is_animated:
_load_animated_skybox(cdn_path, frame_count, fps)
else:
_load_static_skybox(cdn_path),
func(code: String, msg: String) -> void:
push_warning("[GameScreen] Skybox fetch failed — %s: %s" % [code, msg]))
func _load_static_skybox(url: String) -> void:
var http := HTTPRequest.new()
add_child(http)
http.request_completed.connect(
func(_result: int, code: int, _headers: PackedStringArray, data: PackedByteArray) -> void:
http.queue_free()
if code < 200 or code >= 300 or data.is_empty():
push_warning("[GameScreen] Failed to download skybox: HTTP %d" % code)
return
var img := Image.new()
var ext := url.get_extension().to_lower()
var err : int
if ext in ["jpg", "jpeg"]:
err = img.load_jpg_from_buffer(data)
elif ext == "webp":
err = img.load_webp_from_buffer(data)
else:
err = img.load_png_from_buffer(data)
if err != OK:
push_warning("[GameScreen] Failed to decode skybox image")
return
var tex := ImageTexture.create_from_image(img)
var mat := PanoramaSkyMaterial.new()
mat.panorama = tex
if is_instance_valid(_skybox_sky):
_skybox_sky.sky_material = mat)
http.request(url)
func _load_animated_skybox(base_url: String, frame_count: int, fps: float) -> void:
_skybox_frames.clear()
_skybox_frame_idx = 0
var loaded : int = 0
var frames_arr: Array = []
frames_arr.resize(frame_count)
for i in frame_count:
var url := "%s/%d.png" % [base_url, i]
var http := HTTPRequest.new()
var frame_idx := i
add_child(http)
http.request_completed.connect(
func(_result: int, code: int, _headers: PackedStringArray, data: PackedByteArray) -> void:
http.queue_free()
loaded += 1
if code >= 200 and code < 300 and not data.is_empty():
var img := Image.new()
if img.load_png_from_buffer(data) == OK:
frames_arr[frame_idx] = ImageTexture.create_from_image(img)
if loaded == frame_count:
_skybox_frames = frames_arr.filter(func(f: Variant) -> bool: return f != null)
if not _skybox_frames.is_empty():
_start_skybox_animation(fps))
http.request(url)
func _start_skybox_animation(fps: float) -> void:
_apply_skybox_frame(0)
if _skybox_frames.size() <= 1:
return
if _skybox_timer != null:
_skybox_timer.queue_free()
_skybox_timer = Timer.new()
_skybox_timer.wait_time = 1.0 / maxf(fps, 1.0)
_skybox_timer.autostart = true
_skybox_timer.timeout.connect(_on_skybox_frame_tick)
add_child(_skybox_timer)
func _apply_skybox_frame(idx: int) -> void:
if _skybox_frames.is_empty() or not is_instance_valid(_skybox_sky):
return
var tex : ImageTexture = _skybox_frames[idx % _skybox_frames.size()]
if tex == null:
return
var mat := _skybox_sky.sky_material
if not (mat is PanoramaSkyMaterial):
mat = PanoramaSkyMaterial.new()
_skybox_sky.sky_material = mat
(mat as PanoramaSkyMaterial).panorama = tex
func _on_skybox_frame_tick() -> void:
_skybox_frame_idx = (_skybox_frame_idx + 1) % _skybox_frames.size()
_apply_skybox_frame(_skybox_frame_idx)
# ── Camera ──────────────────────────────────────────────────────────────────── # ── Camera ────────────────────────────────────────────────────────────────────
@@ -375,10 +484,10 @@ func _unhandled_input(event: InputEvent) -> void:
_apply_camera() _apply_camera()
if _pan_active: if _pan_active:
var ps := _cam_distance * 0.0015 var ps := _cam_distance * 0.0015
var right := _camera_rig.global_basis.x * -delta.x * ps var right := _camera_rig.global_basis.x * delta.x * ps
var fwd := Vector3(_camera_rig.global_basis.z.x, 0, var fwd := Vector3(_camera_rig.global_basis.z.x, 0,
_camera_rig.global_basis.z.z).normalized() _camera_rig.global_basis.z.z).normalized()
_cam_pivot += right + fwd * delta.y * ps _cam_pivot += right + fwd * -delta.y * ps
_cam_pivot.x = clampf(_cam_pivot.x, -6.0, 6.0) _cam_pivot.x = clampf(_cam_pivot.x, -6.0, 6.0)
_cam_pivot.z = clampf(_cam_pivot.z, -6.0, 6.0) _cam_pivot.z = clampf(_cam_pivot.z, -6.0, 6.0)
_apply_camera() _apply_camera()
@@ -122,6 +122,11 @@
<i class="bi bi-music-note-beamed me-2"></i>Audio Config <i class="bi bi-music-note-beamed me-2"></i>Audio Config
</NavLink> </NavLink>
</li> </li>
<li class="nav-item">
<NavLink class="nav-link text-white-50 py-1" href="/content/skyboxes">
<i class="bi bi-cloud-sun me-2"></i>Skyboxes
</NavLink>
</li>
</ul> </ul>
</li> </li>
<li class="nav-item"> <li class="nav-item">
@@ -0,0 +1,304 @@
@page "/content/skyboxes"
@attribute [Authorize(Roles = "Admin,SuperAdmin")]
@using Microsoft.EntityFrameworkCore
@using SOR.Database.Contexts
@using SOR.Database.Entities.Catalog
@inject CatalogDbContext Db
<PageTitle>Skyboxes – SOR Admin</PageTitle>
<div class="d-flex justify-content-between align-items-center mb-4">
<div>
<h1 class="mb-0">Skyboxes</h1>
<div class="text-muted small">
Configure 3D environment skyboxes displayed in gameplay scenes.
Only the active skybox is sent to clients.
</div>
</div>
<button class="btn btn-outline-secondary btn-sm" @onclick="LoadAsync" disabled="@_loading">
<i class="bi bi-arrow-clockwise me-1"></i>Refresh
</button>
</div>
@if (_message is not null)
{
<div class="alert @(_isError ? "alert-danger" : "alert-success") alert-dismissible">
@_message
<button type="button" class="btn-close" @onclick="() => _message = null"></button>
</div>
}
<div class="card shadow-sm mb-4">
<div class="card-header fw-medium">Skybox Library</div>
<div class="card-body p-0">
@if (_loading)
{
<p class="p-3 text-muted">Loading…</p>
}
else if (_skyboxes.Count == 0)
{
<p class="p-3 text-muted fst-italic">No skyboxes defined yet. Add one below.</p>
}
else
{
<table class="table table-sm table-hover mb-0 align-middle">
<thead>
<tr>
<th>Name</th>
<th style="width:100px" class="text-center">Type</th>
<th>CDN Path</th>
<th style="width:90px" class="text-center">Frames</th>
<th style="width:80px" class="text-center">FPS</th>
<th style="width:80px" class="text-center">Active</th>
<th style="width:130px"></th>
</tr>
</thead>
<tbody>
@foreach (var s in _skyboxes.OrderByDescending(s => s.IsActive).ThenBy(s => s.Name))
{
var skybox = s;
<tr class="@(skybox.IsActive ? "table-success" : "")">
<td>
<input @bind="skybox.Name" class="form-control form-control-sm"
placeholder="e.g. Night Sky" />
</td>
<td class="text-center">
<div class="form-check form-switch d-flex justify-content-center">
<input @bind="skybox.IsAnimated" type="checkbox"
class="form-check-input" role="switch"
title="@(skybox.IsAnimated ? "Animated" : "Static")" />
<label class="form-check-label ms-2 small text-muted">
@(skybox.IsAnimated ? "Anim" : "Static")
</label>
</div>
</td>
<td>
<input @bind="skybox.CdnPath" class="form-control form-control-sm"
placeholder="https://cdn.sor.gg/skyboxes/…" />
</td>
<td class="text-center">
<input @bind="skybox.FrameCount" type="number" min="1"
class="form-control form-control-sm text-center"
disabled="@(!skybox.IsAnimated)" />
</td>
<td class="text-center">
<input @bind="skybox.Fps" type="number" min="1" max="60" step="1"
class="form-control form-control-sm text-center"
disabled="@(!skybox.IsAnimated)" />
</td>
<td class="text-center">
<span class="badge @(skybox.IsActive ? "bg-success" : "bg-secondary")">
@(skybox.IsActive ? "Active" : "Inactive")
</span>
</td>
<td>
<button class="btn btn-sm btn-outline-primary me-1"
@onclick="() => SaveAsync(skybox)" title="Save">
<i class="bi bi-floppy"></i>
</button>
@if (!skybox.IsActive)
{
<button class="btn btn-sm btn-outline-success me-1"
@onclick="() => SetActiveAsync(skybox)" title="Set Active">
<i class="bi bi-check-circle"></i>
</button>
}
else
{
<button class="btn btn-sm btn-outline-secondary me-1"
@onclick="() => DeactivateAsync(skybox)" title="Deactivate">
<i class="bi bi-x-circle"></i>
</button>
}
<button class="btn btn-sm btn-outline-danger"
@onclick="() => DeleteAsync(skybox)" title="Delete">
<i class="bi bi-trash"></i>
</button>
</td>
</tr>
}
</tbody>
</table>
}
</div>
</div>
<div class="card shadow-sm">
<div class="card-header fw-medium">Add Skybox</div>
<div class="card-body">
<div class="row g-2 align-items-end">
<div class="col-md-2">
<label class="form-label small">Name</label>
<input @bind="_newName" class="form-control form-control-sm" placeholder="Night Sky" />
</div>
<div class="col-md-1 text-center">
<label class="form-label small d-block">Animated</label>
<div class="form-check form-switch d-flex justify-content-center pt-1">
<input @bind="_newIsAnimated" type="checkbox" class="form-check-input" role="switch" />
</div>
</div>
<div class="col-md-4">
<label class="form-label small">
CDN Path
@if (_newIsAnimated)
{
<span class="text-muted ms-1">(base folder — frames at /0.png, /1.png …)</span>
}
else
{
<span class="text-muted ms-1">(full URL to panoramic image)</span>
}
</label>
<input @bind="_newCdnPath" class="form-control form-control-sm"
placeholder="https://cdn.sor.gg/skyboxes/…" />
</div>
@if (_newIsAnimated)
{
<div class="col-md-1">
<label class="form-label small">Frames</label>
<input @bind="_newFrameCount" type="number" min="1"
class="form-control form-control-sm" />
</div>
<div class="col-md-1">
<label class="form-label small">FPS</label>
<input @bind="_newFps" type="number" min="1" max="60" step="1"
class="form-control form-control-sm" />
</div>
}
<div class="col-md-2">
<button class="btn btn-primary btn-sm w-100"
@onclick="AddAsync"
disabled="@(string.IsNullOrWhiteSpace(_newName) || string.IsNullOrWhiteSpace(_newCdnPath))">
<i class="bi bi-plus-lg me-1"></i>Add
</button>
</div>
</div>
<div class="text-muted small mt-2">
<strong>Static</strong>: Set CDN path to a single panoramic/equirectangular image (PNG/JPG recommended).<br />
<strong>Animated</strong>: Upload frames as <code>/0.png</code>, <code>/1.png</code>, … <code>/{FrameCount-1}.png</code>
inside the base folder, then set CDN path to that folder URL.
</div>
</div>
</div>
@code {
private List<SkyboxDefinition> _skyboxes = new();
private bool _loading;
private string? _message;
private bool _isError;
private string _newName = "";
private bool _newIsAnimated = false;
private string _newCdnPath = "";
private int _newFrameCount = 1;
private float _newFps = 24f;
protected override async Task OnInitializedAsync() => await LoadAsync();
private async Task LoadAsync()
{
_loading = true;
_skyboxes = await Db.SkyboxDefinitions.OrderBy(s => s.CreatedAt).ToListAsync();
_loading = false;
}
private async Task SaveAsync(SkyboxDefinition skybox)
{
if (!skybox.IsAnimated) { skybox.FrameCount = 1; skybox.Fps = 0f; }
try
{
await Db.SaveChangesAsync();
_message = $"Skybox \"{skybox.Name}\" saved.";
_isError = false;
}
catch (Exception ex)
{
_message = $"Save failed: {ex.Message}";
_isError = true;
}
}
private async Task SetActiveAsync(SkyboxDefinition skybox)
{
// Deactivate all, then activate the chosen one.
foreach (var s in _skyboxes)
s.IsActive = false;
skybox.IsActive = true;
try
{
await Db.SaveChangesAsync();
_message = $"\"{skybox.Name}\" is now the active skybox.";
_isError = false;
}
catch (Exception ex)
{
_message = $"Activate failed: {ex.Message}";
_isError = true;
}
}
private async Task DeactivateAsync(SkyboxDefinition skybox)
{
skybox.IsActive = false;
try
{
await Db.SaveChangesAsync();
_message = $"\"{skybox.Name}\" deactivated. No skybox is now active (clients use procedural sky).";
_isError = false;
}
catch (Exception ex)
{
_message = $"Deactivate failed: {ex.Message}";
_isError = true;
}
}
private async Task DeleteAsync(SkyboxDefinition skybox)
{
Db.SkyboxDefinitions.Remove(skybox);
try
{
await Db.SaveChangesAsync();
_skyboxes.Remove(skybox);
_message = $"Skybox \"{skybox.Name}\" deleted.";
_isError = false;
}
catch (Exception ex)
{
_message = $"Delete failed: {ex.Message}";
_isError = true;
}
}
private async Task AddAsync()
{
var s = new SkyboxDefinition
{
Id = Guid.NewGuid(),
Name = _newName.Trim(),
IsAnimated = _newIsAnimated,
CdnPath = _newCdnPath.Trim(),
FrameCount = _newIsAnimated ? Math.Max(1, _newFrameCount) : 1,
Fps = _newIsAnimated ? Math.Max(1f, _newFps) : 0f,
IsActive = false,
CreatedAt = DateTimeOffset.UtcNow,
};
Db.SkyboxDefinitions.Add(s);
try
{
await Db.SaveChangesAsync();
_skyboxes.Add(s);
_newName = _newCdnPath = "";
_newIsAnimated = false;
_newFrameCount = 1;
_newFps = 24f;
_message = $"Skybox \"{s.Name}\" added.";
_isError = false;
}
catch (Exception ex)
{
_message = $"Add failed: {ex.Message}";
_isError = true;
}
}
}
+25
View File
@@ -132,6 +132,31 @@ public sealed record CardAnimationBindingDto(
string? CastSoundCdnUrl, string? CastSoundCdnUrl,
string? ImpactSoundCdnUrl); string? ImpactSoundCdnUrl);
// ── Skybox config ─────────────────────────────────────────────────────────────
/// <summary>Fetch the currently active skybox definition (if any).</summary>
public sealed record GetSkyboxConfigRequest;
/// <summary>
/// Response for content.get_skybox_config.
/// Skybox is null when no skybox is active (client keeps the default procedural sky).
/// </summary>
public sealed record GetSkyboxConfigResponse(SkyboxDefinitionDto? Skybox);
/// <summary>
/// Describes one skybox for use in the 3D gameplay scene.
///
/// Static: CdnPath is the full URL to a panoramic image (PNG/JPG).
/// Animated: CdnPath is the base folder URL; frames are at {CdnPath}/0.png, /1.png, etc.
/// </summary>
public sealed record SkyboxDefinitionDto(
Guid Id,
string Name,
bool IsAnimated,
string CdnPath,
int FrameCount,
float Fps);
// ── BGM config ─────────────────────────────────────────────────────────────── // ── BGM config ───────────────────────────────────────────────────────────────
/// <summary>Fetch all active background music tracks (keyed by game context).</summary> /// <summary>Fetch all active background music tracks (keyed by game context).</summary>
@@ -0,0 +1,39 @@
namespace SOR.Content.Handlers;
using Microsoft.EntityFrameworkCore;
using SOR.Database.Contexts;
using SOR.Networking.Abstractions.Messaging;
using SOR.Networking.Abstractions.Transport;
using SOR.Shared.Networking;
/// <summary>
/// content.get_skybox_config — returns the currently active skybox definition, or null if none.
/// The client applies it to the WorldEnvironment in the gameplay scene.
/// </summary>
internal sealed class ContentGetSkyboxConfigHandler : IMessageHandler
{
private readonly CatalogDbContext _catalogDb;
public ContentGetSkyboxConfigHandler(CatalogDbContext catalogDb)
{
_catalogDb = catalogDb;
}
public string MessageType => "content.get_skybox_config";
public async Task<IServerMessage?> HandleAsync(
IClientMessage message,
AuthenticatedConnection connection,
CancellationToken ct)
{
var skybox = await _catalogDb.SkyboxDefinitions
.AsNoTracking()
.Where(s => s.IsActive)
.OrderByDescending(s => s.CreatedAt)
.Select(s => new SkyboxDefinitionDto(s.Id, s.Name, s.IsAnimated, s.CdnPath, s.FrameCount, s.Fps))
.FirstOrDefaultAsync(ct);
return ServerMessage.Reply("content.get_skybox_config.ack", message.Seq,
new GetSkyboxConfigResponse(skybox));
}
}
@@ -24,6 +24,7 @@ public static class ServiceRegistration
services.AddTransient<IMessageHandler, ContentGetTileModelsHandler>(); services.AddTransient<IMessageHandler, ContentGetTileModelsHandler>();
services.AddTransient<IMessageHandler, ContentGetTileBottomsHandler>(); services.AddTransient<IMessageHandler, ContentGetTileBottomsHandler>();
services.AddTransient<IMessageHandler, ContentGetAudioConfigHandler>(); services.AddTransient<IMessageHandler, ContentGetAudioConfigHandler>();
services.AddTransient<IMessageHandler, ContentGetSkyboxConfigHandler>();
return services; return services;
} }
@@ -28,7 +28,8 @@ public sealed class CatalogDbContext : DbContext
public DbSet<CdnUploadRecord> CdnUploadRecords => Set<CdnUploadRecord>(); public DbSet<CdnUploadRecord> CdnUploadRecords => Set<CdnUploadRecord>();
public DbSet<TileModelBinding> TileModelBindings => Set<TileModelBinding>(); public DbSet<TileModelBinding> TileModelBindings => Set<TileModelBinding>();
public DbSet<TileBottomModel> TileBottomModels => Set<TileBottomModel>(); public DbSet<TileBottomModel> TileBottomModels => Set<TileBottomModel>();
public DbSet<GameAudioConfig> AudioConfigs => Set<GameAudioConfig>(); public DbSet<GameAudioConfig> AudioConfigs => Set<GameAudioConfig>();
public DbSet<SkyboxDefinition> SkyboxDefinitions => Set<SkyboxDefinition>();
protected override void OnModelCreating(ModelBuilder builder) protected override void OnModelCreating(ModelBuilder builder)
{ {
@@ -162,5 +163,14 @@ public sealed class CatalogDbContext : DbContext
e.HasIndex(g => g.Context); e.HasIndex(g => g.Context);
e.HasIndex(g => g.IsActive); e.HasIndex(g => g.IsActive);
}); });
builder.Entity<SkyboxDefinition>(e =>
{
e.ToTable("skybox_definitions");
e.HasKey(s => s.Id);
e.Property(s => s.Name).IsRequired();
e.Property(s => s.CdnPath).IsRequired();
e.HasIndex(s => s.IsActive);
});
} }
} }
@@ -0,0 +1,49 @@
namespace SOR.Database.Entities.Catalog;
/// <summary>
/// Defines a skybox displayed in the 3D gameplay scene.
///
/// Static skyboxes: CdnPath is the full URL to a single panoramic image (PNG/JPG/HDR).
/// Animated skyboxes: CdnPath is the base URL of a frame folder.
/// Frames are named {CdnPath}/0.png, {CdnPath}/1.png, … {CdnPath}/{FrameCount-1}.png.
/// The client downloads all frames and cycles through them at Fps frames per second.
///
/// Only the skybox with IsActive = true is served to clients.
/// At most one skybox should be active at a time; the admin panel enforces this.
/// </summary>
public sealed class SkyboxDefinition
{
public Guid Id { get; set; } = Guid.NewGuid();
/// <summary>Human-readable display name shown in the admin panel.</summary>
public string Name { get; set; } = string.Empty;
/// <summary>
/// When false: CdnPath is a direct URL to a single panoramic image.
/// When true: CdnPath is a base folder URL; frames are sequential PNGs starting at /0.png.
/// </summary>
public bool IsAnimated { get; set; }
/// <summary>
/// For static: full CDN URL to the panoramic image (e.g. https://cdn.sor.gg/skyboxes/night.png).
/// For animated: base folder URL without trailing slash (e.g. https://cdn.sor.gg/skyboxes/aurora).
/// </summary>
public string CdnPath { get; set; } = string.Empty;
/// <summary>
/// Number of animation frames. Always 1 for static skyboxes.
/// Animated frames are expected at {CdnPath}/0.png … {CdnPath}/{FrameCount-1}.png.
/// </summary>
public int FrameCount { get; set; } = 1;
/// <summary>Playback speed in frames per second. Ignored for static skyboxes.</summary>
public float Fps { get; set; } = 24f;
/// <summary>
/// When true, this skybox is served to game clients.
/// Deactivate all others before activating a new one.
/// </summary>
public bool IsActive { get; set; }
public DateTimeOffset CreatedAt { get; set; } = DateTimeOffset.UtcNow;
}
@@ -0,0 +1,541 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using SOR.Database.Contexts;
#nullable disable
namespace SOR.Database.Migrations.Catalog
{
[DbContext(typeof(CatalogDbContext))]
[Migration("20260321114732_AddSkyboxDefinitions")]
partial class AddSkyboxDefinitions
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("catalog")
.HasAnnotation("ProductVersion", "8.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardAnimationBinding", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("ActionName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("AnimationCdnUrl")
.IsRequired()
.HasColumnType("text");
b.Property<string>("AnimationTrackName")
.HasColumnType("text");
b.Property<Guid>("CardDefinitionId")
.HasColumnType("uuid");
b.Property<string>("CastSoundCdnUrl")
.HasColumnType("text");
b.Property<string>("ImpactSoundCdnUrl")
.HasColumnType("text");
b.Property<bool>("IsAiGenerated")
.HasColumnType("boolean");
b.HasKey("Id");
b.HasIndex("CardDefinitionId", "ActionName")
.IsUnique();
b.ToTable("card_animation_bindings", "catalog");
});
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardAsset", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("AssetType")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("CardDefinitionId")
.HasColumnType("uuid");
b.Property<string>("CdnUrl")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ContentETag")
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("IsAiGenerated")
.HasColumnType("boolean");
b.Property<string>("MimeType")
.HasColumnType("text");
b.Property<string>("ModelFacingDirection")
.HasColumnType("text");
b.Property<string>("ModelTintMaskUrl")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CardDefinitionId", "AssetType");
b.ToTable("card_assets", "catalog");
});
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardDefinition", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("AbilitiesJson")
.HasColumnType("jsonb")
.HasColumnName("abilities");
b.Property<string>("Affinity")
.IsRequired()
.HasColumnType("text");
b.Property<string>("AttackSoundUrl")
.HasColumnType("text");
b.Property<string>("AttackType")
.HasColumnType("text");
b.Property<string>("BlockedSoundUrl")
.HasColumnType("text");
b.Property<bool?>("CanAttack")
.HasColumnType("boolean");
b.Property<bool?>("CanBeAttacked")
.HasColumnType("boolean");
b.Property<bool?>("CanBeBlocked")
.HasColumnType("boolean");
b.Property<bool?>("CanBeObstructed")
.HasColumnType("boolean");
b.Property<bool?>("CanBeSacrificed")
.HasColumnType("boolean");
b.Property<bool?>("CanDefend")
.HasColumnType("boolean");
b.Property<bool?>("CanMove")
.HasColumnType("boolean");
b.Property<bool?>("CanUseAbility")
.HasColumnType("boolean");
b.Property<string>("CardType")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("CollectorNumber")
.HasColumnType("integer");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<int?>("Damage")
.HasColumnType("integer");
b.Property<string>("DamagedSoundUrl")
.HasColumnType("text");
b.Property<string>("DeathSoundUrl")
.HasColumnType("text");
b.Property<long>("DefinitionVersion")
.ValueGeneratedOnAdd()
.HasColumnType("bigint")
.HasDefaultValue(0L);
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<string>("EffectsJson")
.HasColumnType("jsonb")
.HasColumnName("effects");
b.Property<string[]>("Genus")
.HasColumnType("text[]");
b.Property<bool>("IsPublished")
.HasColumnType("boolean");
b.Property<bool>("IsRetired")
.HasColumnType("boolean");
b.Property<int?>("MaxAttackRange")
.HasColumnType("integer");
b.Property<int?>("MaxChannelRange")
.HasColumnType("integer");
b.Property<int?>("MaxDefense")
.HasColumnType("integer");
b.Property<int?>("MaxHealth")
.HasColumnType("integer");
b.Property<int?>("MinAttackRange")
.HasColumnType("integer");
b.Property<int?>("MinChannelRange")
.HasColumnType("integer");
b.Property<float?>("ModelScale")
.HasColumnType("real");
b.Property<string>("ModelTintColor")
.HasColumnType("text");
b.Property<string>("MoveSoundUrl")
.HasColumnType("text");
b.Property<int?>("MovementPoints")
.HasColumnType("integer");
b.Property<string>("MovementType")
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("OtherCostsJson")
.HasColumnType("jsonb")
.HasColumnName("other_costs");
b.Property<Guid?>("PreviousTierId")
.HasColumnType("uuid");
b.Property<string>("Rarity")
.IsRequired()
.HasColumnType("text");
b.Property<bool?>("RequiresLos")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("RetiredAt")
.HasColumnType("timestamp with time zone");
b.Property<Guid?>("SetId")
.HasColumnType("uuid");
b.Property<int>("SpCost")
.HasColumnType("integer");
b.Property<int>("StCost")
.HasColumnType("integer");
b.Property<string>("TerramorphaMode")
.HasColumnType("text");
b.Property<int?>("Tier")
.HasColumnType("integer");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("Affinity");
b.HasIndex("CardType");
b.HasIndex("DefinitionVersion");
b.HasIndex("Name");
b.HasIndex("PreviousTierId");
b.HasIndex("Rarity");
b.HasIndex("SetId");
b.HasIndex("IsPublished", "SetId");
b.ToTable("card_definitions", "catalog");
});
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardSet", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Code")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Description")
.HasColumnType("text");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateOnly?>("ReleaseDate")
.HasColumnType("date");
b.HasKey("Id");
b.HasIndex("Code")
.IsUnique();
b.ToTable("card_sets", "catalog");
});
modelBuilder.Entity("SOR.Database.Entities.Catalog.CdnUploadRecord", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("ContentType")
.HasColumnType("text");
b.Property<bool>("IsAiGenerated")
.HasColumnType("boolean");
b.Property<string>("ObjectKey")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Prefix")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PublicUrl")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("UploadedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("IsAiGenerated");
b.HasIndex("ObjectKey")
.IsUnique();
b.HasIndex("Prefix");
b.ToTable("cdn_upload_records", "catalog");
});
modelBuilder.Entity("SOR.Database.Entities.Catalog.GameAudioConfig", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Context")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<string>("TrackCdnUrl")
.IsRequired()
.HasColumnType("text");
b.Property<string>("TrackName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("Context");
b.HasIndex("IsActive");
b.ToTable("game_audio_configs", "catalog");
});
modelBuilder.Entity("SOR.Database.Entities.Catalog.SkyboxDefinition", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CdnPath")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<float>("Fps")
.HasColumnType("real");
b.Property<int>("FrameCount")
.HasColumnType("integer");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<bool>("IsAnimated")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("IsActive");
b.ToTable("skybox_definitions", "catalog");
});
modelBuilder.Entity("SOR.Database.Entities.Catalog.TileBottomModel", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CdnKey")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<string>("PublicUrl")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("IsActive");
b.ToTable("tile_bottom_models", "catalog");
});
modelBuilder.Entity("SOR.Database.Entities.Catalog.TileModelBinding", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Affinity")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ModelCdnKey")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ModelPublicUrl")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Shape")
.IsRequired()
.HasColumnType("text");
b.Property<string>("TexturePublicUrl")
.HasColumnType("text");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("Affinity", "Shape")
.IsUnique();
b.ToTable("tile_model_bindings", "catalog");
});
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardAnimationBinding", b =>
{
b.HasOne("SOR.Database.Entities.Catalog.CardDefinition", "CardDefinition")
.WithMany("AnimationBindings")
.HasForeignKey("CardDefinitionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CardDefinition");
});
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardAsset", b =>
{
b.HasOne("SOR.Database.Entities.Catalog.CardDefinition", "CardDefinition")
.WithMany("Assets")
.HasForeignKey("CardDefinitionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CardDefinition");
});
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardDefinition", b =>
{
b.HasOne("SOR.Database.Entities.Catalog.CardDefinition", "PreviousTier")
.WithMany()
.HasForeignKey("PreviousTierId")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("SOR.Database.Entities.Catalog.CardSet", "Set")
.WithMany("Cards")
.HasForeignKey("SetId")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("PreviousTier");
b.Navigation("Set");
});
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardDefinition", b =>
{
b.Navigation("AnimationBindings");
b.Navigation("Assets");
});
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardSet", b =>
{
b.Navigation("Cards");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,48 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SOR.Database.Migrations.Catalog
{
/// <inheritdoc />
public partial class AddSkyboxDefinitions : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "skybox_definitions",
schema: "catalog",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
IsAnimated = table.Column<bool>(type: "boolean", nullable: false),
CdnPath = table.Column<string>(type: "text", nullable: false),
FrameCount = table.Column<int>(type: "integer", nullable: false),
Fps = table.Column<float>(type: "real", nullable: false),
IsActive = table.Column<bool>(type: "boolean", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_skybox_definitions", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_skybox_definitions_IsActive",
schema: "catalog",
table: "skybox_definitions",
column: "IsActive");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "skybox_definitions",
schema: "catalog");
}
}
}
@@ -383,6 +383,42 @@ namespace SOR.Database.Migrations.Catalog
b.ToTable("game_audio_configs", "catalog"); b.ToTable("game_audio_configs", "catalog");
}); });
modelBuilder.Entity("SOR.Database.Entities.Catalog.SkyboxDefinition", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CdnPath")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<float>("Fps")
.HasColumnType("real");
b.Property<int>("FrameCount")
.HasColumnType("integer");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<bool>("IsAnimated")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("IsActive");
b.ToTable("skybox_definitions", "catalog");
});
modelBuilder.Entity("SOR.Database.Entities.Catalog.TileBottomModel", b => modelBuilder.Entity("SOR.Database.Entities.Catalog.TileBottomModel", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")