From fe48cf68b6714ee09b9afea98e30f446f62562d6 Mon Sep 17 00:00:00 2001 From: Claude Code Date: Wed, 8 Apr 2026 20:09:59 -0700 Subject: [PATCH] =?UTF-8?q?feat(management):=20=E2=9C=A8=20Update=20fauna?= =?UTF-8?q?=20integration=20module=20with=20new=20entity/asset=20managemen?= =?UTF-8?q?t=20APIs=20and=20logic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Lilith Autocommit --- .../management/rust_fauna_integration.gd | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/src/game/engine/src/modules/management/rust_fauna_integration.gd b/src/game/engine/src/modules/management/rust_fauna_integration.gd index 13f4d5f7..0279bd3b 100644 --- a/src/game/engine/src/modules/management/rust_fauna_integration.gd +++ b/src/game/engine/src/modules/management/rust_fauna_integration.gd @@ -63,22 +63,46 @@ static func run_all_players() -> void: ## Each tuple is `[col, row, tier, species_id]` — the shape ## `RustFaunaBridge.stamp_lairs` accepts. ## -## Default tier baseline is used because the `Building` entity doesn't -## carry a tier field directly. iter 7l can refine via wilds.json lookup -## if the bench targets need true per-lair tiers. +## Per-lair tier is sourced from `wilds.json` `lair_types[].base_tier` via +## `DataLoader.get_wilds_config()`. The `Building.type_id` matches the +## `lair_types[].id`, so the lookup is O(1) through a cached map. If the +## type_id isn't in wilds.json (or the config isn't loaded yet), +## `DEFAULT_LAIR_TIER` is used as a safety fallback. static func _build_lair_list() -> Array: var lairs: Array = [] var species_seed: int = 1 + var tier_by_type: Dictionary = _build_tier_lookup() for b: Variant in GameState.npc_buildings: var type_id: String = b.type_id if type_id == "village" or type_id == "ruin": continue var pos: Vector2i = b.position - lairs.append([pos.x, pos.y, DEFAULT_LAIR_TIER, species_seed]) + var tier: int = int(tier_by_type.get(type_id, DEFAULT_LAIR_TIER)) + lairs.append([pos.x, pos.y, tier, species_seed]) species_seed += 1 return lairs +## Build a `type_id -> base_tier` map from `DataLoader.get_wilds_config()`. +## Called once per `_build_lair_list` invocation — the lookup is cheap +## enough that caching across calls isn't worth the autoload coupling. +## Returns an empty Dictionary if the config or its `lair_types` array +## is missing; callers fall back to `DEFAULT_LAIR_TIER` on miss. +static func _build_tier_lookup() -> Dictionary: + var out: Dictionary = {} + var cfg: Dictionary = DataLoader.get_wilds_config() + if cfg.is_empty(): + return out + var lair_types: Array = cfg.get("lair_types", []) + for entry: Variant in lair_types: + if entry is Dictionary: + var id: String = String(entry.get("id", "")) + if id.is_empty(): + continue + out[id] = int(entry.get("base_tier", DEFAULT_LAIR_TIER)) + return out + + ## Run the bridge for one player's units against the shared lair list. ## Invoked once per player per turn by `run_all_players`. static func _run_for_player(