feat(memory): wire EventMemoryService into GameLoop and SocketServer

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
root
2026-03-08 21:54:56 +00:00
parent 1f5cafe2fd
commit 2c4a0d1f75
2 changed files with 21 additions and 0 deletions
+18
View File
@@ -45,6 +45,16 @@ export class SocketServer {
this.gameLoop.thoughtSystem.onThought = (data) => {
this.io.emit('npc-thought', data);
};
this.gameLoop.eventMemoryService.onEventRecorded = (entityId, event) => {
// Only send to clients following this NPC
for (const [socketId, followedId] of this.followedEntities) {
if (followedId === entityId) {
const sock = this.io.sockets.sockets.get(socketId);
sock?.emit('memory-event', { entityId, event });
}
}
};
}
private setupConnections(): void {
@@ -118,6 +128,14 @@ export class SocketServer {
socket.on('follow-npc', (data: { entityId: EntityId | null }) => {
this.followedEntities.set(socket.id, data.entityId);
this.rebuildFollowedEntityIds();
// Send memory history when following a new NPC
if (data.entityId !== null) {
const events = this.gameLoop.eventMemoryService.getEvents(data.entityId);
if (events.length > 0) {
socket.emit('memory-history', { entityId: data.entityId, events });
}
}
});
// Handle disconnect