feat: wire backstory generation into NPC spawn flow
Trigger fire-and-forget backstory generation whenever an NPC spawns, both during initial spawn and via player spawn-npc requests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -11,6 +11,7 @@ import { relationshipSystem } from '../systems/relationshipSystem.js';
|
||||
import { createBondRegistry } from '../systems/bondRegistry.js';
|
||||
import { spawnNPC } from './spawner.js';
|
||||
import { createLlmService, type LlmService } from '../llm/llmService.js';
|
||||
import { generateBackstory } from '../llm/backstoryGenerator.js';
|
||||
|
||||
export class GameLoop {
|
||||
readonly world: World;
|
||||
@@ -47,9 +48,14 @@ export class GameLoop {
|
||||
}
|
||||
}
|
||||
|
||||
generateNpcBackstory(entityId: number): void {
|
||||
generateBackstory(this.world, entityId, this.llmService);
|
||||
}
|
||||
|
||||
private spawnInitialNPCs(count: number): void {
|
||||
for (let i = 0; i < count; i++) {
|
||||
spawnNPC(this.world, this.map);
|
||||
const entity = spawnNPC(this.world, this.map);
|
||||
this.generateNpcBackstory(entity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,8 @@ export class SocketServer {
|
||||
|
||||
const target = map.findNearestWalkable(data.x, data.y, 3)
|
||||
?? map.getRandomWalkable();
|
||||
spawnNPC(world, map, target);
|
||||
const npcEntity = spawnNPC(world, map, target);
|
||||
this.gameLoop.generateNpcBackstory(npcEntity);
|
||||
});
|
||||
|
||||
// Handle superlatives subscription
|
||||
|
||||
Reference in New Issue
Block a user