feat: wire socialSystem into game loop, spawner, and state serializer

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
root
2026-03-07 13:06:08 +00:00
parent 7cfc8c0537
commit 8daecfaa3f
3 changed files with 18 additions and 2 deletions
+7 -1
View File
@@ -1,12 +1,13 @@
import type {
EntityState, WorldState, StateUpdate,
Position, Movement, Appearance, Needs, NPCBrain, PlayerControlled,
Position, Movement, Appearance, Needs, NPCBrain, PlayerControlled, SocialState,
} from '@dflike/shared';
import { TILE_SIZE } from '@dflike/shared';
import type { World } from '../ecs/World.js';
import type { GameMap } from '../map/GameMap.js';
export function serializeEntity(world: World, entityId: number): EntityState {
const socialState = world.getComponent<SocialState>(entityId, 'socialState');
return {
id: entityId,
position: world.getComponent<Position>(entityId, 'position')!,
@@ -16,6 +17,11 @@ export function serializeEntity(world: World, entityId: number): EntityState {
npcBrain: world.getComponent<NPCBrain>(entityId, 'npcBrain'),
playerControlled: world.getComponent<PlayerControlled>(entityId, 'playerControlled'),
name: world.getComponent<string>(entityId, 'name'),
socialState: socialState ? {
phase: socialState.phase,
partnerId: socialState.partnerId,
outcome: socialState.outcome,
} : undefined,
};
}