feat: add person history and trust reactions

This commit is contained in:
Rijad Zuzo
2026-07-12 11:42:10 +02:00
parent 99b8146f75
commit 9fcf6a0a58
19 changed files with 543 additions and 90 deletions
+12
View File
@@ -730,6 +730,18 @@ func get_known_events(npc_id: int, max_count: int = 3) -> Array[EconomicEventRec
return known
func get_retained_memory_events(npc_id: int, max_count: int = 4) -> Array[EconomicEventRecord]:
var retained: Array[EconomicEventRecord] = []
var event_ids := event_knowledge_system.get_retained_event_ids(
npc_id, _get_lasting_event_ids(npc_id), max_count
)
for event_id in event_ids:
var event := event_log.get_by_id(event_id)
if event != null:
retained.append(event)
return retained
func npc_knows_event(npc_id: int, event_id: int) -> bool:
return event_knowledge_system.knows_event(npc_id, event_id)
+23 -3
View File
@@ -103,12 +103,30 @@ func get_known_event_ids(knower_id: int, max_count: int = 3) -> Array[int]:
return recent_ids
func get_retained_event_ids(
knower_id: int, lasting_event_ids: Array[int], max_count: int = 4
) -> Array[int]:
return _get_ranked_event_ids(knower_id, lasting_event_ids, false, max_count)
func get_communicable_event_ids(knower_id: int, lasting_event_ids: Array[int]) -> Array[int]:
return _get_ranked_event_ids(knower_id, lasting_event_ids, true, 0)
func _get_ranked_event_ids(
knower_id: int, lasting_event_ids: Array[int], direct_only: bool, max_count: int
) -> Array[int]:
var ranked: Array[Dictionary] = []
for record in known_events.values():
if record.get_knower_id() != knower_id:
continue
if record.get_acquisition_method() not in KnownEventStateRecord.DIRECT_ACQUISITION_METHODS:
if (
direct_only
and (
record.get_acquisition_method()
not in KnownEventStateRecord.DIRECT_ACQUISITION_METHODS
)
):
continue
(
ranked
@@ -120,10 +138,12 @@ func get_communicable_event_ids(knower_id: int, lasting_event_ids: Array[int]) -
}
)
)
ranked.sort_custom(_sort_communicable)
ranked.sort_custom(_sort_by_importance)
var event_ids: Array[int] = []
for item in ranked:
event_ids.append(int(item["event_id"]))
if max_count > 0 and event_ids.size() >= max_count:
break
return event_ids
@@ -234,7 +254,7 @@ static func _sort_by_acquisition(
return first.get_event_id() < second.get_event_id()
static func _sort_communicable(first: Dictionary, second: Dictionary) -> bool:
static func _sort_by_importance(first: Dictionary, second: Dictionary) -> bool:
if bool(first["lasting"]) != bool(second["lasting"]):
return bool(first["lasting"])
if int(first["acquired_tick"]) != int(second["acquired_tick"]):