From 4ac92d01399c6ca4128a873f756821b02f919dc3 Mon Sep 17 00:00:00 2001 From: dingo Date: Tue, 7 Apr 2026 11:34:22 -0400 Subject: [PATCH] Add hex stalagmite support for tile bottom models - TileBottomModel gains a Shape column (Square/Hex, default Square) so admins can manage separate stalagmite pools per tile grid type - EF migration 20260407153312_AddTileBottomModelShape adds the column with a default of 'Square' to preserve existing data - Admin UI splits the Tile Bottom Models section into Square and Hex cards, each with their own Add/toggle/delete controls - content.tile_bottoms response now returns squareUrls and hexUrls separately; handler queries each shape independently - ContentCache splits into _tile_bottom_urls_square / _hex and get_random_tile_bottom_url() now takes a shape parameter - game_screen: hex tiles with no 3D model now receive a hex stalagmite instead of silently skipping; 3D-model path passes shape_key through Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude Co-Authored-By: Happy --- .../origin-client/autoloads/ContentCache.gd | 40 +- .../origin-client/scenes/game/game_screen.gd | 11 +- .../Pages/Content/TileModelManagerPage.razor | 110 ++-- Server/src/SOR.Content/ContentMessages.cs | 2 +- .../Handlers/ContentGetTileBottomsHandler.cs | 17 +- .../SOR.Database/Contexts/CatalogDbContext.cs | 3 +- .../Entities/Catalog/TileBottomModel.cs | 7 +- ...153312_AddTileBottomModelShape.Designer.cs | 608 ++++++++++++++++++ .../20260407153312_AddTileBottomModelShape.cs | 53 ++ .../Catalog/CatalogDbContextModelSnapshot.cs | 6 +- 10 files changed, 780 insertions(+), 77 deletions(-) create mode 100644 Server/src/SOR.Database/Migrations/Catalog/20260407153312_AddTileBottomModelShape.Designer.cs create mode 100644 Server/src/SOR.Database/Migrations/Catalog/20260407153312_AddTileBottomModelShape.cs diff --git a/Client/origin-client/autoloads/ContentCache.gd b/Client/origin-client/autoloads/ContentCache.gd index 4893b8d..bd52b44 100644 --- a/Client/origin-client/autoloads/ContentCache.gd +++ b/Client/origin-client/autoloads/ContentCache.gd @@ -20,7 +20,7 @@ extends Node const CACHE_DIR := "user://content" const CACHE_PATH := "user://content/defs.json" const TILE_MODELS_PATH := "user://content/tile_models.json" -const TILE_BOTTOMS_PATH := "user://content/tile_bottoms.json" +const TILE_BOTTOMS_PATH := "user://content/tile_bottoms_v2.json" const SKYBOXES_PATH := "user://content/skyboxes.json" const PAGE_SIZE := 200 const REFRESH_INTERVAL_SECS := 300.0 # re-sync every 5 minutes during live play @@ -40,8 +40,9 @@ var _tile_models: Dictionary = {} ## "Affinity_Shape" → CDN texture URL string (2D texture for placeholder tiles) var _tile_textures: Dictionary = {} -## Array of CDN URL strings for tile bottom (stalagmite) models. -var _tile_bottom_urls: Array = [] +## CDN URL strings for tile bottom (stalagmite) models, split by tile shape. +var _tile_bottom_urls_square: Array = [] +var _tile_bottom_urls_hex: Array = [] ## Array of Dictionary (SkyboxDefinitionDto) for all active skyboxes. var _skyboxes: Array = [] @@ -129,11 +130,13 @@ func get_tile_texture_url(affinity: String, shape: String) -> String: return _tile_textures.get(affinity + "_" + shape, "") -## Returns a random active tile bottom (stalagmite) CDN URL, or "" if none configured. -func get_random_tile_bottom_url() -> String: - if _tile_bottom_urls.is_empty(): +## Returns a random active tile bottom (stalagmite) CDN URL for the given shape, +## or "" if none are configured. shape should be "Square" or "Hex". +func get_random_tile_bottom_url(shape: String) -> String: + var pool := _tile_bottom_urls_hex if shape == "Hex" else _tile_bottom_urls_square + if pool.is_empty(): return "" - return _tile_bottom_urls[randi() % _tile_bottom_urls.size()] as String + return pool[randi() % pool.size()] as String ## Fetch tile bottom model URLs from the server and update the local cache. @@ -312,12 +315,15 @@ func _on_tile_models(payload: Variant) -> void: func _on_tile_bottoms(payload: Variant) -> void: - var p := payload as Dictionary - var urls : Array = p.get("urls", []) - _tile_bottom_urls.clear() - for u in urls: + var p := payload as Dictionary + _tile_bottom_urls_square.clear() + _tile_bottom_urls_hex.clear() + for u in p.get("squareUrls", []): if typeof(u) == TYPE_STRING and not (u as String).is_empty(): - _tile_bottom_urls.append(u as String) + _tile_bottom_urls_square.append(u as String) + for u in p.get("hexUrls", []): + if typeof(u) == TYPE_STRING and not (u as String).is_empty(): + _tile_bottom_urls_hex.append(u as String) _save_tile_bottoms_to_disk() @@ -390,8 +396,12 @@ func _load_tile_bottoms_from_disk() -> void: return var parsed: Variant = JSON.parse_string(file.get_as_text()) file.close() - if typeof(parsed) == TYPE_ARRAY: - _tile_bottom_urls = parsed as Array + if typeof(parsed) == TYPE_DICTIONARY: + var d := parsed as Dictionary + if typeof(d.get("square")) == TYPE_ARRAY: + _tile_bottom_urls_square = d["square"] as Array + if typeof(d.get("hex")) == TYPE_ARRAY: + _tile_bottom_urls_hex = d["hex"] as Array func _save_tile_bottoms_to_disk() -> void: @@ -399,7 +409,7 @@ func _save_tile_bottoms_to_disk() -> void: var file := FileAccess.open(TILE_BOTTOMS_PATH, FileAccess.WRITE) if not file: return - file.store_string(JSON.stringify(_tile_bottom_urls)) + file.store_string(JSON.stringify({ "square": _tile_bottom_urls_square, "hex": _tile_bottom_urls_hex })) file.close() diff --git a/Client/origin-client/scenes/game/game_screen.gd b/Client/origin-client/scenes/game/game_screen.gd index 2ebc17c..a5913cc 100644 --- a/Client/origin-client/scenes/game/game_screen.gd +++ b/Client/origin-client/scenes/game/game_screen.gd @@ -1272,14 +1272,19 @@ func _try_load_tile_model(body: StaticBody3D, affinity: String) -> void: var model_url := ContentCache.get_tile_model_url(affinity, shape_key) if model_url.is_empty(): if _board_grid_type == "Hexagon": - # No hex model — keep the affinity-coloured cylinder placeholder as-is. + # No hex model — keep the affinity-coloured cylinder placeholder. + # Still attach a hex stalagmite below if one is available. + if want_bottom: + var bottom_url := ContentCache.get_random_tile_bottom_url("Hex") + if not bottom_url.is_empty(): + _try_load_tile_bottom(weakref(body), bottom_url) return # Square: apply a 2D texture and attach a stalagmite bottom. var tex_url := ContentCache.get_tile_texture_url(affinity, "Square") if not tex_url.is_empty(): _apply_tile_texture(body, tex_url) if want_bottom: - var bottom_url := ContentCache.get_random_tile_bottom_url() + var bottom_url := ContentCache.get_random_tile_bottom_url("Square") if not bottom_url.is_empty(): _try_load_tile_bottom(weakref(body), bottom_url) return @@ -1315,7 +1320,7 @@ func _try_load_tile_model(body: StaticBody3D, affinity: String) -> void: # Attach a random stalagmite bottom model below the tile (if any are configured). # PureVoid tiles are skipped — they float in empty space with no decoration below. if want_bottom: - var bottom_url : String = ContentCache.get_random_tile_bottom_url() + var bottom_url : String = ContentCache.get_random_tile_bottom_url(shape_key) if not bottom_url.is_empty(): _try_load_tile_bottom(body_ref, bottom_url) ) diff --git a/Server/src/SOR.Admin/Components/Pages/Content/TileModelManagerPage.razor b/Server/src/SOR.Admin/Components/Pages/Content/TileModelManagerPage.razor index a6c535e..1808f2c 100644 --- a/Server/src/SOR.Admin/Components/Pages/Content/TileModelManagerPage.razor +++ b/Server/src/SOR.Admin/Components/Pages/Content/TileModelManagerPage.razor @@ -83,57 +83,64 @@ else } -
-
- Tile Bottom Models (stalagmites, randomly selected per tile) - -
-
- @if (_bottomModels.Count == 0) - { -
No bottom models yet — upload GLBs and add them here.
- } - else - { - - - - - - - - - - @foreach (var bottom in _bottomModels) - { - var b = bottom; +@foreach (var (shapeLabel, bottomShape) in new[] { ("Square", TileShape.Square), ("Hex", TileShape.Hex) }) +{ + var shapeModels = _bottomModels.Where(m => m.Shape == bottomShape).ToList(); +
+
+ + Tile Bottom Models — @shapeLabel + (stalagmites, randomly selected per @shapeLabel.ToLower() tile) + + +
+
+ @if (shapeModels.Count == 0) + { +
No @shapeLabel.ToLower() bottom models yet — upload GLBs and add them here.
+ } + else + { +
ModelActive
+ - - - + + + - } - -
- @(b.CdnKey.Contains('/') ? b.CdnKey[(b.CdnKey.LastIndexOf('/') + 1)..] : b.CdnKey) - - - - - - ModelActive
- } + + + @foreach (var bottom in shapeModels) + { + var b = bottom; + + + @(b.CdnKey.Contains('/') ? b.CdnKey[(b.CdnKey.LastIndexOf('/') + 1)..] : b.CdnKey) + + + + + + + + + + } + + + } +
- +} @if (_pickerOpen) @@ -265,7 +272,7 @@ else