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 <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
dingo
2026-04-07 11:34:46 -04:00
co-authored by Claude Happy
parent be8b1f7765
commit 4ac92d0139
10 changed files with 780 additions and 77 deletions
+25 -15
View File
@@ -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()