feat: initialize thirst on NPC spawn, handle old saves missing thirst
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -15,6 +15,7 @@ export function spawnNPC(world: World, map: GameMap, positionHint?: Position, ev
|
||||
world.addComponent<Position>(entity, 'position', pos);
|
||||
world.addComponent<Needs>(entity, 'needs', {
|
||||
hunger: 40 + Math.random() * 40, // 40-80
|
||||
thirst: 40 + Math.random() * 40, // 40-80
|
||||
energy: 40 + Math.random() * 40,
|
||||
productivity: 60 + Math.random() * 40, // 60-100
|
||||
});
|
||||
|
||||
@@ -109,6 +109,11 @@ function deserializeComponent(name: string, json: string): unknown {
|
||||
}
|
||||
return parsed;
|
||||
}
|
||||
case 'needs': {
|
||||
const needs = parsed as any;
|
||||
if (needs.thirst === undefined) needs.thirst = 80;
|
||||
return needs;
|
||||
}
|
||||
case 'name':
|
||||
// These are strings directly
|
||||
return parsed;
|
||||
|
||||
Reference in New Issue
Block a user