feat: wire desire systems into GameLoop and spawner
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -19,7 +19,10 @@ import { pickupSystem } from '../systems/pickupSystem.js';
|
||||
import { RecipeRegistry } from '../industry/recipeRegistry.js';
|
||||
import { spawnNPC } from './spawner.js';
|
||||
import { createLlmService, type LlmService } from '../llm/llmService.js';
|
||||
import { generateBackstory } from '../llm/backstoryGenerator.js';
|
||||
import { generateBackstoryAndDesires } from '../llm/backstoryGenerator.js';
|
||||
import { desireFulfillmentSystem } from '../systems/desireFulfillmentSystem.js';
|
||||
import { createDesireGeneratorSystem } from '../systems/desireGeneratorSystem.js';
|
||||
import type { DesireGeneratorSystem } from '../systems/desireGeneratorSystem.js';
|
||||
import { createNarrationService, type NarrationService } from '../llm/narrationService.js';
|
||||
import { narrationEmitter } from '../systems/narrationEmitter.js';
|
||||
import type { EntityId, InventionSummary, Position } from '@dflike/shared';
|
||||
@@ -44,6 +47,7 @@ export class GameLoop {
|
||||
readonly eventMemoryService: EventMemoryService;
|
||||
readonly thoughtSystem: ThoughtSystem;
|
||||
readonly inventionSystem: InventionSystem;
|
||||
private desireGeneratorSystem: DesireGeneratorSystem;
|
||||
public followedEntityIds: Set<EntityId> = new Set();
|
||||
public onInventionCreated: ((summary: InventionSummary) => void) | null = null;
|
||||
public onStockpileEvent: ((entry: StockpileLogEntry) => void) | null = null;
|
||||
@@ -66,6 +70,7 @@ export class GameLoop {
|
||||
this.eventMemoryService,
|
||||
(summary) => this.onInventionCreated?.(summary),
|
||||
);
|
||||
this.desireGeneratorSystem = createDesireGeneratorSystem(this.llmService);
|
||||
|
||||
this.saveManager = new SaveManager(options?.savePath ?? 'saves/default.db');
|
||||
|
||||
@@ -218,7 +223,7 @@ export class GameLoop {
|
||||
}
|
||||
|
||||
generateNpcBackstory(entityId: number): void {
|
||||
generateBackstory(this.world, entityId, this.llmService);
|
||||
generateBackstoryAndDesires(this.world, entityId, this.llmService, this.tick);
|
||||
}
|
||||
|
||||
private spawnInitialNPCs(count: number): void {
|
||||
@@ -274,6 +279,8 @@ export class GameLoop {
|
||||
socialSystem(this.world, this.eventMemoryService);
|
||||
narrationEmitter(this.world, this.narrationService, this.followedEntityIds, this.eventMemoryService);
|
||||
relationshipSystem(this.world, this.eventMemoryService);
|
||||
desireFulfillmentSystem(this.world, this.tick);
|
||||
this.desireGeneratorSystem.update(this.world, this.tick);
|
||||
industrySystem(this.world, this.map);
|
||||
pickupSystem(this.world, this.tick, (entry) => this.onStockpileEvent?.(entry));
|
||||
gatheringSystem(this.world, this.map);
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { GameMap } from '../map/GameMap.js';
|
||||
import { generateRandomAppearance } from '../spawner/appearanceGenerator.js';
|
||||
import { generateName } from '../spawner/nameGenerator.js';
|
||||
import { generateStats } from '../spawner/statGenerator.js';
|
||||
import type { EntityId, Position, Needs, Movement, NPCBrain, Appearance, SocialState, Stats, StatModifiers, Relationships } from '@dflike/shared';
|
||||
import type { EntityId, Position, Needs, Movement, NPCBrain, Appearance, SocialState, Stats, StatModifiers, Relationships, Desire } from '@dflike/shared';
|
||||
import type { EventMemoryService } from '../llm/eventMemoryService.js';
|
||||
|
||||
export function spawnNPC(world: World, map: GameMap, positionHint?: Position, eventMemoryService?: EventMemoryService): EntityId {
|
||||
@@ -48,6 +48,7 @@ export function spawnNPC(world: World, map: GameMap, positionHint?: Position, ev
|
||||
world.addComponent<Relationships>(entity, 'relationships', new Map());
|
||||
world.addComponent<string>(entity, 'backstory', '');
|
||||
world.addComponent<Map<string, number>>(entity, 'inventory', new Map());
|
||||
world.addComponent<Desire[]>(entity, 'desires', []);
|
||||
|
||||
eventMemoryService?.record(entity, {
|
||||
type: 'spawned',
|
||||
|
||||
Reference in New Issue
Block a user