feat: seed household familiarity from shared home proximity
NPCs whose home positions are within 4m of each other gain mutual familiarity at baseline 0.5. Stored per NPC as a Dictionary keyed by other npc_id, serialized through NPCStateRecord with backward-compatible fallback for old saves. Household pairs form naturally from the home_positions configuration in main.tscn. Includes save/load round-trip test verifying familiarity persists.
This commit is contained in:
@@ -45,7 +45,8 @@ static func capture(npc: SimNPC) -> NPCStateRecord:
|
||||
"inventory": npc.inventory.duplicate(true),
|
||||
"last_task": String(npc.last_task),
|
||||
"random_seed": str(npc.random_source.seed),
|
||||
"random_state": str(npc.random_source.state)
|
||||
"random_state": str(npc.random_source.state),
|
||||
"familiarity": npc.familiarity.duplicate(true)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -160,6 +161,9 @@ func restore(debug_logs: bool) -> SimNPC:
|
||||
npc.last_task = StringName(data["last_task"])
|
||||
npc.random_source.state = String(data["random_state"]).to_int()
|
||||
npc.debug_logs = debug_logs
|
||||
var saved_familiarity = data.get("familiarity", {})
|
||||
if saved_familiarity is Dictionary:
|
||||
npc.familiarity = saved_familiarity.duplicate(true)
|
||||
return npc
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user