feat(management): ✨ Update fauna integration module with new entity/asset management APIs and logic
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
9cfacb53de
commit
fe48cf68b6
1 changed files with 28 additions and 4 deletions
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue