feat(memory): wire EventMemoryService into GameLoop and SocketServer
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user