diff --git a/server/src/systems/thoughtSystem.ts b/server/src/systems/thoughtSystem.ts index 918ae7a..cbaf441 100644 --- a/server/src/systems/thoughtSystem.ts +++ b/server/src/systems/thoughtSystem.ts @@ -43,12 +43,15 @@ export function createThoughtSystem( for (const entityId of npcs) { if (!followedEntityIds.has(entityId)) continue; + // Skip sleeping NPCs - they don't think + const brain = world.getComponent(entityId, 'npcBrain'); + if (brain?.currentGoal === 'sleep') continue; + const cooldownUntil = cooldowns.get(entityId) ?? 0; if (tick < cooldownUntil) continue; const needs = world.getComponent(entityId, 'needs'); const social = world.getComponent(entityId, 'socialState'); - const brain = world.getComponent(entityId, 'npcBrain'); const context = determineTrigger(needs, social, brain, tick); eligible.push({ entityId, context }); @@ -139,12 +142,14 @@ function determineTrigger( function describeState(needs: Needs | undefined, brain: any): string { const parts: string[] = []; - if (needs) { + if (brain?.currentGoal === 'sleep') { + parts.push('sleeping'); + } else if (needs) { if (needs.hunger < 30) parts.push('hungry'); if (needs.energy < 30) parts.push('tired'); if (parts.length === 0) parts.push('content'); } - if (brain?.currentGoal) { + if (brain?.currentGoal && brain.currentGoal !== 'sleep') { parts.push(brain.currentGoal === 'wander' ? 'wandering' : brain.currentGoal); } return parts.join(', ') || 'idle';