Anchor beetles to generated tree surfaces
This commit is contained in:
parent
f1c952f5d6
commit
5ed4cccf76
18 changed files with 446 additions and 71 deletions
|
|
@ -294,7 +294,7 @@ func _begin_population_if_ready() -> void:
|
|||
_current_season()
|
||||
):
|
||||
_cache_spawn_surface(entry)
|
||||
for _spawn_index: int in entry.population:
|
||||
for _spawn_index: int in _target_population(entry):
|
||||
_spawn_entity(entry)
|
||||
|
||||
|
||||
|
|
@ -1383,11 +1383,22 @@ func _reconcile_seasonal_population() -> void:
|
|||
for entry: GatherableDataType in _catalog.get_available_entries(season):
|
||||
_cache_spawn_surface(entry)
|
||||
var current_population: int = _population_for_type(entry.type_id)
|
||||
while current_population < entry.population:
|
||||
var target_population := _target_population(entry)
|
||||
while current_population < target_population:
|
||||
_spawn_entity(entry)
|
||||
current_population += 1
|
||||
|
||||
|
||||
func _target_population(entry: GatherableDataType) -> int:
|
||||
if entry == null or entry.spawn_anchor_set_id.is_empty():
|
||||
return entry.population if entry != null else 0
|
||||
var anchors: PackedVector3Array = _spawn_anchor_positions.get(
|
||||
entry.type_id,
|
||||
PackedVector3Array(),
|
||||
)
|
||||
return entry.target_population_for_anchor_count(anchors.size())
|
||||
|
||||
|
||||
func _population_for_type(type_id: StringName) -> int:
|
||||
var count: int = 0
|
||||
for state: Dictionary in _entities.values():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue