feat: add bounded npc memory retention
This commit is contained in:
+31
-6
@@ -31,6 +31,8 @@ func _ready() -> void:
|
||||
simulation_manager.relationship_changed.connect(_on_relationship_changed)
|
||||
if simulation_manager.has_signal("event_knowledge_changed"):
|
||||
simulation_manager.event_knowledge_changed.connect(_on_event_knowledge_changed)
|
||||
if simulation_manager.has_signal("event_knowledge_forgotten"):
|
||||
simulation_manager.event_knowledge_forgotten.connect(_on_event_knowledge_forgotten)
|
||||
|
||||
if "village" in simulation_manager:
|
||||
_on_village_changed(simulation_manager.village)
|
||||
@@ -133,6 +135,10 @@ func _on_event_knowledge_changed(_knower_id: int, _event: EconomicEventRecord) -
|
||||
_refresh_npc_inspector()
|
||||
|
||||
|
||||
func _on_event_knowledge_forgotten(_knower_id: int, _event: EconomicEventRecord) -> void:
|
||||
_refresh_npc_inspector()
|
||||
|
||||
|
||||
func _refresh_npc_inspector() -> void:
|
||||
if not debug_overlay_visible:
|
||||
return
|
||||
@@ -182,6 +188,7 @@ func _refresh_npc_inspector() -> void:
|
||||
score_text += "\n\nUnavailable\n" + "\n".join(rejection_rows)
|
||||
var event_text := _build_event_history(npc)
|
||||
var relationship_text := _build_relationship_display(npc)
|
||||
var memory_text := _build_memory_display(npc)
|
||||
var known_fact_text := _build_known_fact_display(npc)
|
||||
npc_inspector_label.text = (
|
||||
(
|
||||
@@ -192,6 +199,7 @@ func _refresh_npc_inspector() -> void:
|
||||
+ "Carrying food: %.0f wood: %.0f\n"
|
||||
+ "%s\n"
|
||||
+ "%s\n"
|
||||
+ "%s\n"
|
||||
+ "Why\n%s%s\n\n"
|
||||
+ "Recent\n%s\n\n"
|
||||
+ "[Tab] Next villager [F10] Cinematic/debug [F12] Demo reset"
|
||||
@@ -207,6 +215,7 @@ func _refresh_npc_inspector() -> void:
|
||||
npc.get_inventory_amount(SimulationIds.RESOURCE_FOOD),
|
||||
npc.get_inventory_amount(SimulationIds.RESOURCE_WOOD),
|
||||
relationship_text,
|
||||
memory_text,
|
||||
known_fact_text,
|
||||
reason_text,
|
||||
score_text,
|
||||
@@ -288,7 +297,8 @@ func _build_known_fact_display(npc: SimNPC) -> String:
|
||||
for other_npc in simulation_manager.npcs:
|
||||
name_map[other_npc.id] = other_npc.npc_name
|
||||
var latest_event := known_events[known_events.size() - 1] as EconomicEventRecord
|
||||
var provenance := ""
|
||||
var provenance := "source not recorded"
|
||||
var retention := "recent"
|
||||
if simulation_manager.has_method("get_known_event_record"):
|
||||
var known_record: KnownEventStateRecord = simulation_manager.get_known_event_record(
|
||||
npc.id, int(latest_event.data["event_id"])
|
||||
@@ -296,14 +306,29 @@ func _build_known_fact_display(npc: SimNPC) -> String:
|
||||
if known_record != null:
|
||||
match known_record.get_acquisition_method():
|
||||
SimulationIds.KNOWLEDGE_ACQUISITION_PERFORMED:
|
||||
provenance = " (performed personally)"
|
||||
provenance = "performed personally"
|
||||
SimulationIds.KNOWLEDGE_ACQUISITION_WITNESSED:
|
||||
provenance = " (witnessed)"
|
||||
provenance = "witnessed"
|
||||
SimulationIds.KNOWLEDGE_ACQUISITION_COMMUNICATED:
|
||||
var source_name: String = name_map.get(
|
||||
known_record.get_source_npc_id(), "someone"
|
||||
)
|
||||
provenance = " (heard from %s)" % source_name
|
||||
provenance = "heard from %s" % source_name
|
||||
SimulationIds.KNOWLEDGE_ACQUISITION_LEGACY:
|
||||
provenance = " (source not recorded)"
|
||||
return "Known fact: %s%s" % [latest_event.description(name_map), provenance]
|
||||
provenance = "source not recorded"
|
||||
if (
|
||||
simulation_manager.has_method("is_known_event_lasting")
|
||||
and (simulation_manager.is_known_event_lasting(npc.id, int(latest_event.data["event_id"])))
|
||||
):
|
||||
retention = "lasting"
|
||||
return "Known fact: %s (%s · %s)" % [latest_event.description(name_map), provenance, retention]
|
||||
|
||||
|
||||
func _build_memory_display(npc: SimNPC) -> String:
|
||||
if not simulation_manager.has_method("get_memory_summary"):
|
||||
return ""
|
||||
var summary: Dictionary = simulation_manager.get_memory_summary(npc.id)
|
||||
return (
|
||||
"Memory: %d lasting · %d recent"
|
||||
% [int(summary.get("lasting", 0)), int(summary.get("recent", 0))]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user