Fix asteroid remaining count by using config length directly

Instead of looking up meshes by name (which failed due to naming mismatch),
return asteroidCount directly from the config - the authoritative source.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Michael Mainguy 2025-12-09 13:53:10 -06:00
parent 96bc3df51e
commit a7799a9c71
2 changed files with 6 additions and 14 deletions

View File

@ -67,7 +67,7 @@ export class LevelDeserializer {
startBase: AbstractMesh | null;
sun: AbstractMesh;
planets: AbstractMesh[];
asteroids: AbstractMesh[];
asteroidCount: number;
}> {
log.debug(`[LevelDeserializer] Deserializing meshes (hidden: ${hidden})`);
this._scoreObservable = scoreObservable;
@ -80,13 +80,13 @@ export class LevelDeserializer {
const planets = this.createPlanets();
// Create asteroid meshes (no physics)
const asteroids = await this.createAsteroidMeshes(scoreObservable, hidden);
await this.createAsteroidMeshes(scoreObservable, hidden);
return {
startBase: baseResult?.baseMesh || null,
sun,
planets,
asteroids
asteroidCount: this.config.asteroids.length
};
}
@ -239,9 +239,7 @@ export class LevelDeserializer {
private async createAsteroidMeshes(
scoreObservable: Observable<ScoreEvent>,
hidden: boolean
): Promise<AbstractMesh[]> {
const asteroids: AbstractMesh[] = [];
): Promise<void> {
for (let i = 0; i < this.config.asteroids.length; i++) {
const asteroidConfig = this.config.asteroids[i];
const useOrbitConstraints = this.config.useOrbitConstraints !== false;
@ -279,15 +277,9 @@ export class LevelDeserializer {
asteroidConfig.targetMode,
rotation
);
const mesh = this.scene.getMeshByName(asteroidConfig.id);
if (mesh) {
asteroids.push(mesh);
}
}
log.debug(`[LevelDeserializer] Created ${asteroids.length} asteroid meshes (hidden: ${hidden})`);
return asteroids;
log.debug(`[LevelDeserializer] Created ${this.config.asteroids.length} asteroid meshes (hidden: ${hidden})`);
}

View File

@ -406,7 +406,7 @@ export class Level1 implements Level {
);
this._startBase = entities.startBase;
this._asteroidCount = entities.asteroids.length;
this._asteroidCount = entities.asteroidCount;
// Initialize scoreboard with asteroid count
this._ship.scoreboard.setRemainingCount(this._asteroidCount);