Feature: GLB animation playback, model facing, CDN animation preview

Server:
- CardAnimationBinding.AnimationTrackName: nullable override for GLB track name
  (blank = case-insensitive convention match; Idle/Attack/Damaged/Moving/Dying)
- CardAnimationBindingDto: includes AnimationTrackName in content sync
- CardEditor: GLB Track Name column in animation bindings table
- CdnBrowser: model-viewer animation list + playback (JS interop on load event)
- Migration: AddAnimationTrackName applied to production

Client:
- ContentCache.get_anim_track(): resolves GLB track name from binding override
  or falls back to convention with case-insensitive aliases
- game_screen.gd:
  - _find_animation_player(): recursive search in loaded GLB scene tree
  - _resolve_anim_track(): case-insensitive + alias resolution
  - _play_unit_anim(): plays track, returns to Idle when one-shot finishes
  - _play_damage_animations(): detects HP drops and unit deaths before rebuild
  - Model facing: P1 units rotated 180deg Y to face opponent across board
  - Idle loop starts automatically after real model loads
  - Attack animation fires immediately on attack input (before ACK)

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-15 14:06:55 -04:00
co-authored by Claude Happy
parent dfafe89e79
commit c4999c953a
12 changed files with 747 additions and 28 deletions
@@ -83,6 +83,25 @@ func start_sync() -> void:
fetch_tile_models()
## Return the GLB animation track name for a card action.
##
## Looks for an animationBinding with the given action_name (case-insensitive).
## If found and the binding has a non-empty animationTrackName, returns that.
## Otherwise returns the action_name itself so the caller can do its own
## case-insensitive fuzzy match against the AnimationPlayer's track list.
##
## card_def_id: card definition GUID string
## action_name: e.g. "attack", "idle", "death", "move"
func get_anim_track(card_def_id: String, action_name: String) -> String:
var def := get_definition(card_def_id)
var action_lower := action_name.to_lower()
for binding: Dictionary in def.get("animationBindings", []):
if str(binding.get("actionName", "")).to_lower() == action_lower:
var track := str(binding.get("animationTrackName", ""))
return track if not track.is_empty() else action_name
return action_name
## Return the CDN URL for a tile's 3D model, or "" if not assigned.
## affinity: e.g. "Forest" shape: "Square" or "Hex"
func get_tile_model_url(affinity: String, shape: String) -> String:
@@ -0,0 +1 @@
uid://c8lby4cq8hsco
+151 -22
View File
@@ -149,8 +149,24 @@ var _friendly_unit_ids: Dictionary = {} # instanceId → true
# ── Scene refs ────────────────────────────────────────────────────────────────
var _tile_bodies : Dictionary = {} # "x,y" → StaticBody3D
var _unit_meshes : Dictionary = {} # instanceId → MeshInstance3D (placeholder)
var _unit_meshes : Dictionary = {} # instanceId → Node3D (placeholder or real model)
var _unit_bodies : Dictionary = {} # instanceId → StaticBody3D
var _anim_players : Dictionary = {} # instanceId → AnimationPlayer (null if none)
var _unit_def_ids : Dictionary = {} # instanceId → card definition ID string
# ── Animation / facing state ───────────────────────────────────────────────────
var _local_is_p1 : bool = false # true when Auth.user_id == playerOneAccountId
var _prev_unit_hp : Dictionary = {} # instanceId → int, HP from last rebuild
## Animation name aliases: maps the canonical lower-case action to fallback track names.
## The AnimationPlayer track list is matched case-insensitively against each entry.
const ANIM_ALIASES : Dictionary = {
"idle": ["idle", "idle_a", "idle1", "idle_loop"],
"attack": ["attack", "attack_a", "attack1", "attack_b", "strike"],
"damaged": ["damaged", "attacked", "hit", "hurt", "flinch"],
"dying": ["dying", "death", "die", "dead"],
"moving": ["moving", "move", "walk", "run", "walk_cycle"],
}
# ── Lifecycle ─────────────────────────────────────────────────────────────────
@@ -520,19 +536,28 @@ func _rebuild_units(state: Dictionary) -> void:
for c in _units_root.get_children(): c.queue_free()
_unit_meshes.clear()
_unit_bodies.clear()
_anim_players.clear()
_unit_def_ids.clear()
_prev_unit_hp.clear()
var my_id := Auth.user_id
for player: Dictionary in state.get("players", []):
var is_mine : bool = str(player.get("accountId", "")).to_lower() == my_id.to_lower()
var color : Color = Color(0.3, 0.5, 1.0) if is_mine else Color(1.0, 0.35, 0.35)
var arch : Dictionary = player.get("archSpirit", {})
if not arch.is_empty() and arch.get("position") != null:
_add_unit_mesh(arch, color)
_add_unit_mesh(arch, color, not is_mine)
for unit: Dictionary in player.get("field", []):
if unit.get("position") != null:
_add_unit_mesh(unit, color)
_add_unit_mesh(unit, color, not is_mine)
# Store HP for damage detection on next state update.
for unit: Dictionary in ([arch] + player.get("field", [])):
if unit.is_empty(): continue
var iid := str(unit.get("instanceId", ""))
if not iid.is_empty():
_prev_unit_hp[iid] = int(unit.get("currentHealth", 0))
func _add_unit_mesh(unit: Dictionary, team_color: Color) -> void:
func _add_unit_mesh(unit: Dictionary, team_color: Color, is_enemy: bool = false) -> void:
var pd : Dictionary = unit.get("position", {})
if pd.is_empty(): return
var wp := _coord_to_world(pd.get("x", 0), pd.get("y", 0))
@@ -593,6 +618,8 @@ func _add_unit_mesh(unit: Dictionary, team_color: Color) -> void:
# ── Try to load the real 3D model from the card definition ──────────────
var def_id : String = str(unit.get("cardDefinitionId", ""))
if not def_id.is_empty():
_unit_def_ids[iid] = def_id
if def_id.is_empty():
return
var def := ContentCache.get_definition(def_id)
@@ -601,6 +628,10 @@ func _add_unit_mesh(unit: Dictionary, team_color: Color) -> void:
return
var body_ref : Variant = weakref(body)
# Capture facing flag: P1 units face +Z (rotate 180° Y); P2 units face -Z (default).
# Convention: GLB models exported facing -Z. P1 is at -Z side of the board.
# Rotate if: (local is P1 AND friendly) OR (local is P2 AND enemy).
var needs_face_rotation : bool = _local_is_p1 != is_enemy
ModelCache.load_model(model_url, func(model_node: Node3D) -> void:
# Guard: body may have been freed by a state rebuild before load finished.
var b := body_ref.get_ref() as StaticBody3D
@@ -616,12 +647,22 @@ func _add_unit_mesh(unit: Dictionary, team_color: Color) -> void:
if child is MeshInstance3D:
child.queue_free()
# Apply facing rotation so units face their opponent across the board.
if needs_face_rotation:
model_node.rotation_degrees = Vector3(0, 180, 0)
# Position model so its local origin sits at the body's position.
# Models should be authored with their base (foot) at y = 0.
# Adjust the body back down so the model base lands on the tile surface.
b.position = wp + Vector3(0, 0.5, 0)
b.add_child(model_node)
_unit_meshes[iid] = model_node
# Find and store the AnimationPlayer, then start the Idle loop.
var ap := _find_animation_player(model_node)
_anim_players[iid] = ap
if ap != null:
_play_unit_anim(iid, "idle", true)
)
@@ -633,6 +674,87 @@ func _find_model3d_url(def: Dictionary) -> String:
return str(d.get("cdnUrl", ""))
return ""
## Recursively find the first AnimationPlayer in a model subtree.
func _find_animation_player(node: Node) -> AnimationPlayer:
if node is AnimationPlayer:
return node as AnimationPlayer
for child in node.get_children():
var found := _find_animation_player(child)
if found != null:
return found
return null
## Case-insensitive track name resolver with fallback aliases.
## Returns the exact track name in the AnimationPlayer, or "" if not found.
func _resolve_anim_track(ap: AnimationPlayer, action_lower: String) -> String:
# Strip library prefix (e.g. "model/Idle" → "idle") for comparison.
for full_name: String in ap.get_animation_list():
var short := full_name.get_slice("/", full_name.get_slice_count("/") - 1)
if short.to_lower() == action_lower:
return full_name
# Try known aliases.
for alias: String in ANIM_ALIASES.get(action_lower, []):
for full_name: String in ap.get_animation_list():
var short := full_name.get_slice("/", full_name.get_slice_count("/") - 1)
if short.to_lower() == alias:
return full_name
return ""
## Play an animation on a unit by action name. Uses card's AnimationTrackName
## override when set, then falls back to case-insensitive convention matching.
## Pass loop=true for looping animations (e.g. Idle).
func _play_unit_anim(iid: String, action: String, loop: bool = false) -> void:
var ap : AnimationPlayer = _anim_players.get(iid, null)
if ap == null or not is_instance_valid(ap):
return
# Resolve via CardAnimationBinding override first.
var def_id : String = _unit_def_ids.get(iid, "")
var desired := action
if not def_id.is_empty():
var override := ContentCache.get_anim_track(def_id, action)
if not override.is_empty():
desired = override
var track := _resolve_anim_track(ap, desired.to_lower())
if track.is_empty():
return
var anim := ap.get_animation(track)
if anim == null:
return
anim.loop_mode = Animation.LOOP_LINEAR if loop else Animation.LOOP_NONE
if not loop and ap.current_animation == track and ap.is_playing():
return # Don't restart the same one-shot animation mid-play.
ap.play(track)
# Return to Idle after one-shot animations finish.
if not loop:
ap.animation_finished.connect(
func(_n: String) -> void: _play_unit_anim(iid, "idle", true),
CONNECT_ONE_SHOT)
## Detect HP decreases and unit deaths vs previous state, and fire animations.
## Called just before _rebuild_units so animations play on the existing nodes.
func _play_damage_animations(state: Dictionary) -> void:
if _prev_unit_hp.is_empty():
return
var seen_iids : Dictionary = {}
for player: Dictionary in state.get("players", []):
for unit: Dictionary in ([player.get("archSpirit", {})] + player.get("field", [])):
if unit.is_empty(): continue
var iid := str(unit.get("instanceId", ""))
var new_hp := int(unit.get("currentHealth", 0))
var old_hp : int = _prev_unit_hp.get(iid, new_hp)
seen_iids[iid] = true
if new_hp < old_hp:
_play_unit_anim(iid, "damaged")
# Units that vanished this update → play dying.
for iid: String in _prev_unit_hp:
if not seen_iids.has(iid):
_play_unit_anim(iid, "dying")
# ── Highlights ────────────────────────────────────────────────────────────────
func _clear_highlights() -> void:
@@ -912,6 +1034,7 @@ func _handle_board_click(mouse_pos: Vector2) -> void:
Mode.UNIT_SELECTED:
if not unit_id.is_empty():
if _is_enemy_unit(unit_id):
_play_unit_anim(_sel_unit_id, "attack")
Game.send_attack(_sel_unit_id, unit_id)
_set_mode(Mode.NONE)
elif unit_id == _sel_unit_id:
@@ -1816,24 +1939,26 @@ func _on_state_updated(state: Dictionary) -> void:
_rebuild_ownership(state)
# Orient camera behind the local player's row on the first state with playerOneAccountId.
if not _camera_oriented:
var p1_id : String = str(state.get("playerOneAccountId", ""))
if not p1_id.is_empty():
_camera_oriented = true
var bh := float(Game.board_height())
# Shift cam_pivot toward the opponent's side (30 % of board half-length)
# so the player's own row appears in the lower-middle of the screen,
# above the hand panel — not hidden behind it.
var pivot_offset := (bh - 1.0) * 0.3
if Auth.user_id.to_lower() == p1_id.to_lower():
# P1 row is at world -Z. Camera looks from -Z toward +Z → yaw=180°.
# Shift pivot toward world -Z so P1's row is NOT at the very bottom.
_cam_yaw = 180.0
_cam_pivot = Vector3(0.0, 0.0, -pivot_offset)
else:
# P2 row is at world +Z (default yaw=0°).
_cam_pivot = Vector3(0.0, 0.0, pivot_offset)
_apply_camera()
var p1_id : String = str(state.get("playerOneAccountId", ""))
if not p1_id.is_empty():
# Update P1/P2 flag every time — used for model facing on full rebuild.
_local_is_p1 = Auth.user_id.to_lower() == p1_id.to_lower()
if not _camera_oriented and not p1_id.is_empty():
_camera_oriented = true
var bh := float(Game.board_height())
# Shift cam_pivot toward the opponent's side (30 % of board half-length)
# so the player's own row appears in the lower-middle of the screen,
# above the hand panel — not hidden behind it.
var pivot_offset := (bh - 1.0) * 0.3
if _local_is_p1:
# P1 row is at world -Z. Camera looks from -Z toward +Z → yaw=180°.
# Shift pivot toward world -Z so P1's row is NOT at the very bottom.
_cam_yaw = 180.0
_cam_pivot = Vector3(0.0, 0.0, -pivot_offset)
else:
# P2 row is at world +Z (default yaw=0°).
_cam_pivot = Vector3(0.0, 0.0, pivot_offset)
_apply_camera()
var board : Dictionary = state.get("board", {})
if _tile_bodies.is_empty() and not board.is_empty():
@@ -1844,6 +1969,10 @@ func _on_state_updated(state: Dictionary) -> void:
_update_tile_affinity(c.get("x", 0), c.get("y", 0),
tile.get("resolvedAffinity", "Void"))
# Play damage/death animations on existing unit nodes before the rebuild
# destroys them. These play for one frame — enough for a flash effect and
# as a foundation for a future deferred-rebuild architecture.
_play_damage_animations(state)
_rebuild_units(state)
var hand := Game.get_hand()
print("[GameScreen] state phase=", state.get("phase","?"),
@@ -0,0 +1 @@
uid://02h6fbskf8bq
@@ -323,7 +323,7 @@ else
<h6 class="text-muted mb-3">Animation Bindings</h6>
<table class="table table-sm">
<thead><tr><th>Action</th><th>Animation CDN URL</th><th>Cast Sound URL</th><th>Impact Sound URL</th><th>AI</th><th>Upload</th><th></th></tr></thead>
<thead><tr><th>Action</th><th>GLB Track Name</th><th>Animation CDN URL</th><th>Cast Sound URL</th><th>Impact Sound URL</th><th>AI</th><th>Upload</th><th></th></tr></thead>
<tbody>
@foreach (var anim in _card.AnimationBindings)
{
@@ -333,6 +333,10 @@ else
<input @bind="anim.ActionName" class="form-control form-control-sm"
placeholder="e.g. attack" />
</td>
<td style="width:140px">
<input @bind="anim.AnimationTrackName" class="form-control form-control-sm"
placeholder="e.g. Attack (blank=auto)" />
</td>
<td>
<input @bind="anim.AnimationCdnUrl" class="form-control form-control-sm"
placeholder="https://cdn.sor.gg/anims/…" />
@@ -1,5 +1,6 @@
@page "/content/cdn"
@attribute [Authorize(Roles = "Admin,SuperAdmin")]
@implements IDisposable
@using Amazon.S3
@using Amazon.S3.Model
@using Microsoft.AspNetCore.Components.Forms
@@ -283,10 +284,11 @@
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><i class="bi bi-box me-2"></i>3D Preview</h5>
<button type="button" class="btn-close" @onclick="() => _previewUrl = null"></button>
<button type="button" class="btn-close" @onclick="ClosePreview"></button>
</div>
<div class="modal-body p-0" style="background:#f0f0f0">
<model-viewer src="@_previewUrl"
<model-viewer id="mv-preview"
src="@_previewUrl"
camera-controls
auto-rotate
auto-rotate-delay="1000"
@@ -295,13 +297,29 @@
style="width:100%;height:520px;background:#f5f5f5">
</model-viewer>
</div>
<div class="modal-footer py-2">
<div class="modal-footer py-2 flex-wrap gap-2">
<span class="text-muted small font-monospace me-auto text-break">@_previewUrl</span>
@if (_previewAnimations.Count > 0)
{
<select class="form-select form-select-sm" style="width:auto"
value="@_selectedAnimation"
@onchange="OnAnimationSelected">
<option value="">— No animation —</option>
@foreach (var name in _previewAnimations)
{
<option value="@name">@name</option>
}
</select>
}
else if (_previewUrl is not null)
{
<span class="text-muted small fst-italic">Loading animations…</span>
}
<button class="btn btn-sm btn-outline-secondary"
@onclick="() => CopyUrlAsync(_previewUrl)">
@onclick="() => CopyUrlAsync(_previewUrl!)">
<i class="bi bi-clipboard me-1"></i>Copy URL
</button>
<button class="btn btn-sm btn-secondary" @onclick="() => _previewUrl = null">Close</button>
<button class="btn btn-sm btn-secondary" @onclick="ClosePreview">Close</button>
</div>
</div>
</div>
@@ -309,6 +327,24 @@
}
<script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/3.5.0/model-viewer.min.js"></script>
<script>
window.sorCdn = {
initModelViewerAnimations: function (elementId, dotnetRef) {
const el = document.getElementById(elementId);
if (!el) { dotnetRef.invokeMethodAsync('OnAnimationsLoaded', []); return; }
const report = () =>
dotnetRef.invokeMethodAsync('OnAnimationsLoaded', Array.from(el.availableAnimations ?? []));
if (el.loaded) { report(); }
else { el.addEventListener('load', report, { once: true }); }
},
setModelAnimation: function (elementId, animName) {
const el = document.getElementById(elementId);
if (!el) return;
if (animName) { el.setAttribute('animation-name', animName); el.setAttribute('autoplay', ''); }
else { el.removeAttribute('animation-name'); el.removeAttribute('autoplay'); }
}
};
</script>
@code {
private readonly List<CdnObjectRow> _items = new();
@@ -345,6 +381,10 @@
// 3D preview
private string? _previewUrl;
private List<string> _previewAnimations = new();
private string _selectedAnimation = "";
private DotNetObjectReference<CdnBrowser>? _dotNetRef;
private bool _animWatcherActive;
private string _activePrefixDisplay => string.IsNullOrEmpty(_activePrefix) ? "/" : $"/{_activePrefix}";
@@ -384,8 +424,45 @@
private void OpenPreview(string url)
{
_previewUrl = url;
_previewAnimations.Clear();
_selectedAnimation = "";
_animWatcherActive = false;
}
private void ClosePreview()
{
_previewUrl = null;
_previewAnimations.Clear();
_selectedAnimation = "";
_animWatcherActive = false;
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (_previewUrl is not null && !_animWatcherActive)
{
_animWatcherActive = true;
_dotNetRef ??= DotNetObjectReference.Create(this);
await Js.InvokeVoidAsync("sorCdn.initModelViewerAnimations", "mv-preview", _dotNetRef);
}
}
[JSInvokable]
public void OnAnimationsLoaded(string[] animations)
{
_previewAnimations = animations.ToList();
_selectedAnimation = "";
StateHasChanged();
}
private async Task OnAnimationSelected(ChangeEventArgs e)
{
_selectedAnimation = e.Value?.ToString() ?? "";
await Js.InvokeVoidAsync("sorCdn.setModelAnimation", "mv-preview", _selectedAnimation);
}
public void Dispose() => _dotNetRef?.Dispose();
protected override async Task OnInitializedAsync()
{
var options = CdnOptionsAccessor.Value;
@@ -108,6 +108,7 @@ public sealed record CardAnimationBindingDto(
string ActionName,
string AnimationCdnUrl,
bool IsAiGenerated,
string? AnimationTrackName,
string? CastSoundCdnUrl,
string? ImpactSoundCdnUrl);
@@ -57,6 +57,7 @@ internal static class ContentDtoMapper
b.ActionName,
b.AnimationCdnUrl,
b.IsAiGenerated,
b.AnimationTrackName,
b.CastSoundCdnUrl,
b.ImpactSoundCdnUrl)));
}
@@ -32,6 +32,14 @@ public sealed class CardAnimationBinding
/// </summary>
public bool IsAiGenerated { get; set; }
/// <summary>
/// The animation track name inside the card's GLB model that should play for this action.
/// When null or empty, the client falls back to convention (case-insensitive match of ActionName
/// against the model's animation list, with common aliases: death→dying, defend→damaged, etc.).
/// Use this to map non-standard GLB track names exported by artists.
/// </summary>
public string? AnimationTrackName { get; set; }
/// <summary>CDN URL to the sound played when this action begins (e.g. cast, attack swing).</summary>
public string? CastSoundCdnUrl { get; set; }
@@ -0,0 +1,445 @@
// <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("20260315175036_AddAnimationTrackName")]
partial class AddAnimationTrackName
{
/// <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<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("IsAiGenerated")
.HasColumnType("boolean");
b.Property<string>("MimeType")
.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>("AttackType")
.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<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<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.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<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,30 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SOR.Database.Migrations.Catalog
{
/// <inheritdoc />
public partial class AddAnimationTrackName : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "AnimationTrackName",
schema: "catalog",
table: "card_animation_bindings",
type: "text",
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "AnimationTrackName",
schema: "catalog",
table: "card_animation_bindings");
}
}
}
@@ -37,6 +37,9 @@ namespace SOR.Database.Migrations.Catalog
.IsRequired()
.HasColumnType("text");
b.Property<string>("AnimationTrackName")
.HasColumnType("text");
b.Property<Guid>("CardDefinitionId")
.HasColumnType("uuid");