feat(map-placer): ✨ Introduce school affinity logic to strategically group and place resources using new affinity-based placement methods
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
ebcdc7b4c5
commit
7b1f5ad105
1 changed files with 6 additions and 2 deletions
|
|
@ -131,7 +131,9 @@ func place_resources(game_map: RefCounted, multiplier: float) -> void:
|
|||
var res_id: String = res.get("id", "")
|
||||
var valid_terrains: Array = res.get("terrains", [])
|
||||
var climate_zones: Array = res.get("climate_zones", [])
|
||||
var affinity: String = res.get("school_affinity", "")
|
||||
var affinity: String = ""
|
||||
if res.has("school_affinity") and res["school_affinity"] != null:
|
||||
affinity = str(res["school_affinity"])
|
||||
eligible[res_id] = []
|
||||
eligible_weights[res_id] = PackedFloat32Array()
|
||||
for axial: Vector2i in game_map.tiles:
|
||||
|
|
@ -186,7 +188,9 @@ func place_resources(game_map: RefCounted, multiplier: float) -> void:
|
|||
if candidates.is_empty():
|
||||
continue
|
||||
|
||||
var cand_weights_arr: Array[float] = Array(cand_weights, TYPE_FLOAT, "", null)
|
||||
var cand_weights_arr: Array[float] = []
|
||||
for w: float in cand_weights:
|
||||
cand_weights_arr.append(w)
|
||||
var tile_idx: int = _weighted_random_index(cand_weights_arr)
|
||||
if tile_idx < 0:
|
||||
tile_idx = _rng.randi_range(0, candidates.size() - 1)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue