Skip to content

Claude/debug ai worker refactor 7qc pd#1115

Merged
braedonsaunders merged 2 commits into
mainfrom
claude/debug-ai-worker-refactor-7qcPd
Jan 30, 2026
Merged

Claude/debug ai worker refactor 7qc pd#1115
braedonsaunders merged 2 commits into
mainfrom
claude/debug-ai-worker-refactor-7qcPd

Conversation

@braedonsaunders

Copy link
Copy Markdown
Owner

No description provided.

SpawnSystem.ts line 83 calls game.getTerrainHeightAt() but this method
only existed in Game.ts, not WorkerGame. When SpawnSystem ran in the
worker context, the call failed silently, preventing component additions
to newly spawned entities. This caused AI-produced units to be created
as empty entities without Unit components.

https://claude.ai/code/session_01V4RhCiDvDJ7FmwSPYT74Y7
…plication

This refactor creates a proper inheritance hierarchy to prevent bugs like
the missing getTerrainHeightAt method that caused AI units not to spawn.

Architecture:
- GameCore (abstract base): Shared terrain, placement validation, commands
- Game (extends GameCore): Main thread - Selection, Audio, multiplayer
- WorkerGame (extends GameCore): Worker - simulation, AI, anti-throttling

Benefits:
- TypeScript catches missing methods at compile time
- Single source of truth for terrain/placement logic
- No more copy-paste between Game.ts and GameWorker.ts
- Clearer separation of thread-specific vs shared code

Also:
- Removed hardcoded DEBUG flag, use debugLogger system
- Cleaned up temporary debug logging from Entity.ts and World.ts

https://claude.ai/code/session_01V4RhCiDvDJ7FmwSPYT74Y7
@braedonsaunders braedonsaunders merged commit f74c34a into main Jan 30, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants