feat: scale village queries and enrich Jajce center

This commit is contained in:
Rijad Zuzo
2026-07-16 23:51:08 +02:00
parent 4be72639d8
commit 2c88ed6ea8
48 changed files with 2059 additions and 280 deletions
+16 -14
View File
@@ -95,16 +95,17 @@ func get_primary_relationship(observer_id: int) -> RelationshipStateRecord:
return best
func get_most_familiar_living_subject(observer_id: int, npcs: Array[SimNPC]) -> SimNPC:
var living_by_id := {}
for npc in npcs:
if not npc.is_dead:
living_by_id[npc.id] = npc
func get_most_familiar_living(
observer_id: int, npcs: Array[SimNPC], population_view: SimulationPopulationView = null
) -> SimNPC:
var effective_view := population_view
if effective_view == null:
effective_view = SimulationPopulationView.new(npcs)
var best_relationship: RelationshipStateRecord
for relationship in relationships.values():
if relationship.get_observer_id() != observer_id:
continue
if not living_by_id.has(relationship.get_subject_id()):
if effective_view.get_living(relationship.get_subject_id()) == null:
continue
if (
best_relationship == null
@@ -117,21 +118,22 @@ func get_most_familiar_living_subject(observer_id: int, npcs: Array[SimNPC]) ->
best_relationship = relationship
if best_relationship == null:
return null
return living_by_id[best_relationship.get_subject_id()] as SimNPC
return effective_view.get_living(best_relationship.get_subject_id())
func get_trusted_starving_subject(observer_id: int, npcs: Array[SimNPC]) -> SimNPC:
var starving_by_id := {}
for npc in npcs:
if not npc.is_dead and npc.is_starving:
starving_by_id[npc.id] = npc
func get_trusted_starving_subject(
observer_id: int, npcs: Array, population_view: SimulationPopulationView = null
) -> SimNPC:
var effective_view := population_view
if effective_view == null:
effective_view = SimulationPopulationView.new(npcs)
var best_relationship: RelationshipStateRecord
for relationship in relationships.values():
if relationship.get_observer_id() != observer_id:
continue
if relationship.get_trust() < TRUSTED_HELP_THRESHOLD:
continue
if not starving_by_id.has(relationship.get_subject_id()):
if effective_view.get_starving(relationship.get_subject_id()) == null:
continue
if (
best_relationship == null
@@ -144,7 +146,7 @@ func get_trusted_starving_subject(observer_id: int, npcs: Array[SimNPC]) -> SimN
best_relationship = relationship
if best_relationship == null:
return null
return starving_by_id[best_relationship.get_subject_id()] as SimNPC
return effective_view.get_starving(best_relationship.get_subject_id())
func _get_or_create(observer_id: int, subject_id: int) -> RelationshipStateRecord: