diff --git a/Client/origin-client/scenes/game/game_screen.gd b/Client/origin-client/scenes/game/game_screen.gd index 994ea41..c3e3a24 100644 --- a/Client/origin-client/scenes/game/game_screen.gd +++ b/Client/origin-client/scenes/game/game_screen.gd @@ -168,6 +168,17 @@ var _rebuild_tween : Tween = null const MOVE_STEP_SECS : float = 0.28 ## How long to hold after one-shot animations (attack / damaged / dying) before rebuilding. const POST_ANIM_SECS : float = 1.2 +## Seconds to skip at the start of looping animations on subsequent loop iterations. +## GLB animations use the first N frames as a transition-in from idle; on repeat loops +## we jump past them to avoid the bind-pose flash. +const ANIM_TRANSITION_SECS : float = 5.0 / 30.0 # 5 frames at 30 fps + +# Per-unit animation loop tracking. +var _idle_entry_done : Dictionary = {} # iid → true once the first idle entry has played +var _idle_callbacks : Dictionary = {} # iid → Callable (active loop reconnect, to cancel on interrupt) +# Per-unit model config. +var _model_base_angles : Dictionary = {} # iid → float (base facing angle, radians) +var _needs_face_rot : Dictionary = {} # iid → bool (team-based 180° flip flag) ## Animation name aliases: maps the canonical lower-case action to fallback track names. ## The AnimationPlayer track list is matched case-insensitively against each entry. @@ -580,6 +591,10 @@ func _rebuild_units(state: Dictionary) -> void: _unit_meshes.erase(iid) _anim_players.erase(iid) _unit_def_ids.erase(iid) + _idle_entry_done.erase(iid) + _idle_callbacks.erase(iid) # callback already fired or animation stopping + _model_base_angles.erase(iid) + _needs_face_rot.erase(iid) # 3. Add units not yet present (newly played, or first render after connect). for iid : String in desired: @@ -653,16 +668,26 @@ func _add_unit_mesh(unit: Dictionary, team_color: Color, is_enemy: bool = false) _unit_def_ids[iid] = def_id if def_id.is_empty(): return - var def := ContentCache.get_definition(def_id) - var model_url := _find_model3d_url(def) + var def := ContentCache.get_definition(def_id) + var model_asset := _find_model3d_asset(def) + var model_url := str(model_asset.get("cdnUrl", "")) if model_url.is_empty(): 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. + # Read per-model config from the asset. + var facing_dir : String = str(model_asset.get("modelFacingDirection", "north")) + var model_scale : float = float(model_asset.get("modelScale", 1.0)) + var tint_str : String = str(model_asset.get("modelTintColor", "")) + var model_tint : Color = Color.WHITE + if not tint_str.is_empty() and tint_str != "null": + model_tint = Color(tint_str) + + # Team-based facing: P1 units face +Z (toward P2), P2 units face -Z (toward P1). # Rotate if: (local is P1 AND friendly) OR (local is P2 AND enemy). var needs_face_rotation : bool = _local_is_p1 != is_enemy + var base_angle : float = _facing_to_base_angle(facing_dir) + + var body_ref : Variant = weakref(body) 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 @@ -678,9 +703,19 @@ func _add_unit_mesh(unit: Dictionary, team_color: Color, is_enemy: bool = false) 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) + # Apply uniform scale if configured. + if not is_equal_approx(model_scale, 1.0): + model_node.scale = Vector3.ONE * model_scale + + # Store per-unit model config for movement facing and idle rotation. + _model_base_angles[iid] = base_angle + _needs_face_rot[iid] = needs_face_rotation + + # Apply idle/team rotation (facing toward opponent). + model_node.rotation.y = _idle_rotation(iid) + + # Apply multiplicative tint to all StandardMaterial3D surfaces. + _apply_model_tint(model_node, model_tint) # Position model so its local origin sits at the body's position. # Skip reset if a move tween is driving this body — it controls position. @@ -697,13 +732,36 @@ func _add_unit_mesh(unit: Dictionary, team_color: Color, is_enemy: bool = false) ) -func _find_model3d_url(def: Dictionary) -> String: +## Returns the first Model3D asset dict for a card definition, or {} if none. +func _find_model3d_asset(def: Dictionary) -> Dictionary: for asset: Variant in def.get("assets", []): var d := asset as Dictionary if d == null: continue if str(d.get("assetType", "")) == "Model3D": - return str(d.get("cdnUrl", "")) - return "" + return d + return {} + + +## Apply a multiplicative colour tint to all StandardMaterial3D surfaces in a +## model subtree. Materials are duplicated per-instance to avoid cross-unit +## bleed. White (default) is a no-op. +func _apply_model_tint(model: Node3D, tint: Color) -> void: + if tint.is_equal_approx(Color.WHITE): + return + var stack : Array = [model] + while not stack.is_empty(): + var n = stack.pop_back() + if n is MeshInstance3D: + var mi := n as MeshInstance3D + if mi.mesh != null: + for i in mi.mesh.get_surface_count(): + var mat := mi.get_active_material(i) + if mat is StandardMaterial3D: + var dup := mat.duplicate() as StandardMaterial3D + dup.albedo_color = dup.albedo_color * tint + mi.set_surface_override_material(i, dup) + for child in n.get_children(): + stack.append(child) ## Recursively find the first AnimationPlayer in a model subtree. @@ -749,9 +807,32 @@ func _resolve_anim_track(ap: AnimationPlayer, action_lower: String) -> String: return "" +## Convert a model's exported facing direction string to a base angle in radians. +## The angle represents atan2(dir.x, -dir.z) for the direction the model faces +## when rotation.y == 0. All animations and movement share this offset. +func _facing_to_base_angle(facing: String) -> float: + match facing.to_lower(): + "south": return PI + "east": return PI / 2.0 + "west": return -PI / 2.0 + _: return 0.0 # "north" / default: model faces -Z + +## Returns the rotation.y (radians) that makes a unit's model face its opponent +## across the board, given its stored base angle and team-flip flag. +func _idle_rotation(iid: String) -> float: + var base : float = float(_model_base_angles.get(iid, 0.0)) + var flip : bool = bool(_needs_face_rot.get(iid, false)) + # flip=true → unit should face +Z (south, toward P2) atan2(0,-1)=π + # flip=false → unit should face -Z (north, toward P1) atan2(0, 1)=0 + var dir := Vector3(0, 0, 1) if flip else Vector3(0, 0, -1) + return atan2(dir.x, -dir.z) - base + ## 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). +## Pass loop=true for looping animations (e.g. idle, moving). +## GLB convention: the first ANIM_TRANSITION_SECS of any animation are +## "entry frames" that blend from idle into the action. For looping animations +## those frames are played once on entry, then skipped on every subsequent loop. 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): @@ -769,23 +850,48 @@ func _play_unit_anim(iid: String, action: String, loop: bool = false) -> void: var anim := ap.get_animation(track) if anim == null: return - anim.loop_mode = Animation.LOOP_LINEAR if loop else Animation.LOOP_NONE + + # All animations are managed with LOOP_NONE; looping is handled manually + # so we can seek past the transition frames on subsequent iterations. + anim.loop_mode = Animation.LOOP_NONE + + # Disconnect any stale idle loop callback that would restart idle unexpectedly. + if _idle_callbacks.has(iid): + var old_cb := _idle_callbacks[iid] as Callable + if ap.animation_finished.is_connected(old_cb): + ap.animation_finished.disconnect(old_cb) + _idle_callbacks.erase(iid) + # Don't restart the same animation while it's already playing correctly. if ap.current_animation == track and ap.is_playing(): return - ap.play(track) - # For one-shot animations (not dying), queue idle immediately so the - # AnimationPlayer transitions with no bind-pose gap between them. + + # Starting a non-loop animation: reset entry-done so the NEXT idle play + # uses the transition frames to blend back from the action pose. if not loop: + _idle_entry_done.erase(iid) + + ap.play(track) + + if loop: + # On subsequent loop iterations skip the GLB entry frames. + if _idle_entry_done.get(iid, false): + ap.seek(ANIM_TRANSITION_SECS, true) + else: + _idle_entry_done[iid] = true + # Schedule the next loop iteration via animation_finished. + var cb := func(_n: String) -> void: _play_unit_anim(iid, action, true) + ap.animation_finished.connect(cb, CONNECT_ONE_SHOT) + _idle_callbacks[iid] = cb + else: + # For one-shot non-death animations: return to idle via animation_finished + # (fires synchronously inside AnimationPlayer._process, so no gap frame). var action_l := action.to_lower() var is_death := action_l == "dying" or action_l == "death" or action_l == "die" if not is_death: - var idle_track := _resolve_anim_track(ap, "idle") - if not idle_track.is_empty(): - var idle_anim := ap.get_animation(idle_track) - if idle_anim != null: - idle_anim.loop_mode = Animation.LOOP_LINEAR - ap.queue(idle_track) + 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. @@ -886,17 +992,38 @@ func _animate_unit_move(iid: String, from_coord: Vector2i, to_coord: Vector2i, (_move_anims[iid] as Tween).kill() # Play the looping move animation. _play_unit_anim(iid, "moving", true) - # Tween the body through each grid step, preserving its current Y. + # Pre-compute per-step facing angles so the closures capture the correct values. + var base_angle := float(_model_base_angles.get(iid, 0.0)) + var prev_coord := from_coord + var step_angles : Array[float] = [] + for step : Vector2i in path: + var step_wp := _coord_to_world(step.x, step.y) + var prev_wp := _coord_to_world(prev_coord.x, prev_coord.y) + var dir := step_wp - prev_wp # XZ direction in world space + step_angles.append(atan2(dir.x, -dir.z) - base_angle) + prev_coord = step + # Tween the body through each grid step, rotating the model to face each direction. var body_y := body.position.y var tween := create_tween() tween.set_ease(Tween.EASE_IN_OUT) tween.set_trans(Tween.TRANS_SINE) - for step : Vector2i in path: - var wp := _coord_to_world(step.x, step.y) + for i in path.size(): + var step : Vector2i = path[i] + var wp := _coord_to_world(step.x, step.y) + # Snap model rotation to face the movement direction before each step. + tween.tween_callback( + (func(angle: float) -> void: + var m := _unit_meshes.get(iid) as Node3D + if is_instance_valid(m): + m.rotation.y = angle + ).bind(step_angles[i])) tween.tween_property(body, "position", Vector3(wp.x, body_y, wp.z), MOVE_STEP_SECS) - # Return to Idle once movement finishes. + # Return to idle rotation and idle animation once movement finishes. tween.tween_callback(func() -> void: _move_anims.erase(iid) + var m := _unit_meshes.get(iid) as Node3D + if is_instance_valid(m): + m.rotation.y = _idle_rotation(iid) _play_unit_anim(iid, "idle", true)) _move_anims[iid] = tween return duration diff --git a/Server/src/SOR.Content/ContentMessages.cs b/Server/src/SOR.Content/ContentMessages.cs index d274a0a..c98551c 100644 --- a/Server/src/SOR.Content/ContentMessages.cs +++ b/Server/src/SOR.Content/ContentMessages.cs @@ -101,7 +101,12 @@ public sealed record CardAssetDto( string AssetType, string CdnUrl, string? MimeType, - bool IsAiGenerated); + bool IsAiGenerated, + // Model3D config + string? ModelFacingDirection, + float? ModelScale, + string? ModelTintColor, + string? ModelTintMaskUrl); public sealed record CardAnimationBindingDto( Guid Id, diff --git a/Server/src/SOR.Content/Handlers/ContentDtoMapper.cs b/Server/src/SOR.Content/Handlers/ContentDtoMapper.cs index 31e41e3..b188890 100644 --- a/Server/src/SOR.Content/Handlers/ContentDtoMapper.cs +++ b/Server/src/SOR.Content/Handlers/ContentDtoMapper.cs @@ -51,7 +51,11 @@ internal static class ContentDtoMapper a.AssetType.ToString(), a.CdnUrl, a.MimeType, - a.IsAiGenerated)), + a.IsAiGenerated, + a.ModelFacingDirection, + a.ModelScale, + a.ModelTintColor, + a.ModelTintMaskUrl)), AnimationBindings: c.AnimationBindings.Select(b => new CardAnimationBindingDto( b.Id, b.ActionName, diff --git a/Server/src/SOR.Database/Entities/Catalog/CardAsset.cs b/Server/src/SOR.Database/Entities/Catalog/CardAsset.cs index 4245d41..7a3d483 100644 --- a/Server/src/SOR.Database/Entities/Catalog/CardAsset.cs +++ b/Server/src/SOR.Database/Entities/Catalog/CardAsset.cs @@ -19,6 +19,38 @@ public sealed class CardAsset /// MIME type of the asset, e.g. image/webp, model/gltf-binary. public string? MimeType { get; set; } + // ── Model3D config (null = use client defaults) ─────────────────────────── + + /// + /// Direction the model's front faces in its exported GLB coordinate space. + /// Valid values: "north" | "south" | "east" | "west". + /// Null defaults to "north" (model faces -Z, Godot's forward). + /// Used by the client to compute rotation when the unit moves or is placed. + /// + public string? ModelFacingDirection { get; set; } + + /// + /// Uniform scale multiplier applied to the model root node. + /// Null or 1.0 = no scaling. + /// + public float? ModelScale { get; set; } + + /// + /// CSS-style hex tint applied multiplicatively to all StandardMaterial3D + /// surfaces on the model (e.g. "#FF8800"). Null = no tint (white). + /// Lets one GLB be reused with different faction/team colours. + /// + public string? ModelTintColor { get; set; } + + /// + /// CDN URL of a greyscale mask texture whose red channel controls how + /// strongly the ModelTintColor is applied per texel (0 = original, 1 = full tint). + /// Null = tint applies uniformly across all surfaces. + /// + public string? ModelTintMaskUrl { get; set; } + + // ───────────────────────────────────────────────────────────────────────── + /// /// True if this asset was generated by an AI tool (Midjourney, DALL-E, Stable Diffusion, etc.). /// Surfaced in the AI art tracker report in the admin portal. diff --git a/Server/src/SOR.Database/Migrations/Catalog/20260316020112_AddModelConfig.Designer.cs b/Server/src/SOR.Database/Migrations/Catalog/20260316020112_AddModelConfig.Designer.cs new file mode 100644 index 0000000..9c283b1 --- /dev/null +++ b/Server/src/SOR.Database/Migrations/Catalog/20260316020112_AddModelConfig.Designer.cs @@ -0,0 +1,457 @@ +// +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("20260316020112_AddModelConfig")] + partial class AddModelConfig + { + /// + 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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ActionName") + .IsRequired() + .HasColumnType("text"); + + b.Property("AnimationCdnUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("AnimationTrackName") + .HasColumnType("text"); + + b.Property("CardDefinitionId") + .HasColumnType("uuid"); + + b.Property("CastSoundCdnUrl") + .HasColumnType("text"); + + b.Property("ImpactSoundCdnUrl") + .HasColumnType("text"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AssetType") + .IsRequired() + .HasColumnType("text"); + + b.Property("CardDefinitionId") + .HasColumnType("uuid"); + + b.Property("CdnUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("IsAiGenerated") + .HasColumnType("boolean"); + + b.Property("MimeType") + .HasColumnType("text"); + + b.Property("ModelFacingDirection") + .HasColumnType("text"); + + b.Property("ModelScale") + .HasColumnType("real"); + + b.Property("ModelTintColor") + .HasColumnType("text"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AbilitiesJson") + .HasColumnType("jsonb") + .HasColumnName("abilities"); + + b.Property("Affinity") + .IsRequired() + .HasColumnType("text"); + + b.Property("AttackType") + .HasColumnType("text"); + + b.Property("CanAttack") + .HasColumnType("boolean"); + + b.Property("CanBeAttacked") + .HasColumnType("boolean"); + + b.Property("CanBeBlocked") + .HasColumnType("boolean"); + + b.Property("CanBeObstructed") + .HasColumnType("boolean"); + + b.Property("CanBeSacrificed") + .HasColumnType("boolean"); + + b.Property("CanDefend") + .HasColumnType("boolean"); + + b.Property("CanMove") + .HasColumnType("boolean"); + + b.Property("CanUseAbility") + .HasColumnType("boolean"); + + b.Property("CardType") + .IsRequired() + .HasColumnType("text"); + + b.Property("CollectorNumber") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Damage") + .HasColumnType("integer"); + + b.Property("DefinitionVersion") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasDefaultValue(0L); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("EffectsJson") + .HasColumnType("jsonb") + .HasColumnName("effects"); + + b.Property("Genus") + .HasColumnType("text[]"); + + b.Property("IsPublished") + .HasColumnType("boolean"); + + b.Property("IsRetired") + .HasColumnType("boolean"); + + b.Property("MaxAttackRange") + .HasColumnType("integer"); + + b.Property("MaxChannelRange") + .HasColumnType("integer"); + + b.Property("MaxDefense") + .HasColumnType("integer"); + + b.Property("MaxHealth") + .HasColumnType("integer"); + + b.Property("MinAttackRange") + .HasColumnType("integer"); + + b.Property("MinChannelRange") + .HasColumnType("integer"); + + b.Property("MovementPoints") + .HasColumnType("integer"); + + b.Property("MovementType") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("OtherCostsJson") + .HasColumnType("jsonb") + .HasColumnName("other_costs"); + + b.Property("PreviousTierId") + .HasColumnType("uuid"); + + b.Property("Rarity") + .IsRequired() + .HasColumnType("text"); + + b.Property("RequiresLos") + .HasColumnType("boolean"); + + b.Property("RetiredAt") + .HasColumnType("timestamp with time zone"); + + b.Property("SetId") + .HasColumnType("uuid"); + + b.Property("SpCost") + .HasColumnType("integer"); + + b.Property("StCost") + .HasColumnType("integer"); + + b.Property("TerramorphaMode") + .HasColumnType("text"); + + b.Property("Tier") + .HasColumnType("integer"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ContentType") + .HasColumnType("text"); + + b.Property("IsAiGenerated") + .HasColumnType("boolean"); + + b.Property("ObjectKey") + .IsRequired() + .HasColumnType("text"); + + b.Property("Prefix") + .IsRequired() + .HasColumnType("text"); + + b.Property("PublicUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Context") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("TrackCdnUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Affinity") + .IsRequired() + .HasColumnType("text"); + + b.Property("ModelCdnKey") + .IsRequired() + .HasColumnType("text"); + + b.Property("ModelPublicUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("Shape") + .IsRequired() + .HasColumnType("text"); + + b.Property("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 + } + } +} diff --git a/Server/src/SOR.Database/Migrations/Catalog/20260316020112_AddModelConfig.cs b/Server/src/SOR.Database/Migrations/Catalog/20260316020112_AddModelConfig.cs new file mode 100644 index 0000000..141a6d9 --- /dev/null +++ b/Server/src/SOR.Database/Migrations/Catalog/20260316020112_AddModelConfig.cs @@ -0,0 +1,66 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace SOR.Database.Migrations.Catalog +{ + /// + public partial class AddModelConfig : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "ModelFacingDirection", + schema: "catalog", + table: "card_assets", + type: "text", + nullable: true); + + migrationBuilder.AddColumn( + name: "ModelScale", + schema: "catalog", + table: "card_assets", + type: "real", + nullable: true); + + migrationBuilder.AddColumn( + name: "ModelTintColor", + schema: "catalog", + table: "card_assets", + type: "text", + nullable: true); + + migrationBuilder.AddColumn( + name: "ModelTintMaskUrl", + schema: "catalog", + table: "card_assets", + type: "text", + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "ModelFacingDirection", + schema: "catalog", + table: "card_assets"); + + migrationBuilder.DropColumn( + name: "ModelScale", + schema: "catalog", + table: "card_assets"); + + migrationBuilder.DropColumn( + name: "ModelTintColor", + schema: "catalog", + table: "card_assets"); + + migrationBuilder.DropColumn( + name: "ModelTintMaskUrl", + schema: "catalog", + table: "card_assets"); + } + } +} diff --git a/Server/src/SOR.Database/Migrations/Catalog/CatalogDbContextModelSnapshot.cs b/Server/src/SOR.Database/Migrations/Catalog/CatalogDbContextModelSnapshot.cs index 3a44890..fa4818c 100644 --- a/Server/src/SOR.Database/Migrations/Catalog/CatalogDbContextModelSnapshot.cs +++ b/Server/src/SOR.Database/Migrations/Catalog/CatalogDbContextModelSnapshot.cs @@ -86,6 +86,18 @@ namespace SOR.Database.Migrations.Catalog b.Property("MimeType") .HasColumnType("text"); + b.Property("ModelFacingDirection") + .HasColumnType("text"); + + b.Property("ModelScale") + .HasColumnType("real"); + + b.Property("ModelTintColor") + .HasColumnType("text"); + + b.Property("ModelTintMaskUrl") + .HasColumnType("text"); + b.HasKey("Id"); b.HasIndex("CardDefinitionId", "AssetType");