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:
parent
96bc3df51e
commit
a7799a9c71
@ -67,7 +67,7 @@ export class LevelDeserializer {
|
|||||||
startBase: AbstractMesh | null;
|
startBase: AbstractMesh | null;
|
||||||
sun: AbstractMesh;
|
sun: AbstractMesh;
|
||||||
planets: AbstractMesh[];
|
planets: AbstractMesh[];
|
||||||
asteroids: AbstractMesh[];
|
asteroidCount: number;
|
||||||
}> {
|
}> {
|
||||||
log.debug(`[LevelDeserializer] Deserializing meshes (hidden: ${hidden})`);
|
log.debug(`[LevelDeserializer] Deserializing meshes (hidden: ${hidden})`);
|
||||||
this._scoreObservable = scoreObservable;
|
this._scoreObservable = scoreObservable;
|
||||||
@ -80,13 +80,13 @@ export class LevelDeserializer {
|
|||||||
const planets = this.createPlanets();
|
const planets = this.createPlanets();
|
||||||
|
|
||||||
// Create asteroid meshes (no physics)
|
// Create asteroid meshes (no physics)
|
||||||
const asteroids = await this.createAsteroidMeshes(scoreObservable, hidden);
|
await this.createAsteroidMeshes(scoreObservable, hidden);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
startBase: baseResult?.baseMesh || null,
|
startBase: baseResult?.baseMesh || null,
|
||||||
sun,
|
sun,
|
||||||
planets,
|
planets,
|
||||||
asteroids
|
asteroidCount: this.config.asteroids.length
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,9 +239,7 @@ export class LevelDeserializer {
|
|||||||
private async createAsteroidMeshes(
|
private async createAsteroidMeshes(
|
||||||
scoreObservable: Observable<ScoreEvent>,
|
scoreObservable: Observable<ScoreEvent>,
|
||||||
hidden: boolean
|
hidden: boolean
|
||||||
): Promise<AbstractMesh[]> {
|
): Promise<void> {
|
||||||
const asteroids: AbstractMesh[] = [];
|
|
||||||
|
|
||||||
for (let i = 0; i < this.config.asteroids.length; i++) {
|
for (let i = 0; i < this.config.asteroids.length; i++) {
|
||||||
const asteroidConfig = this.config.asteroids[i];
|
const asteroidConfig = this.config.asteroids[i];
|
||||||
const useOrbitConstraints = this.config.useOrbitConstraints !== false;
|
const useOrbitConstraints = this.config.useOrbitConstraints !== false;
|
||||||
@ -279,15 +277,9 @@ export class LevelDeserializer {
|
|||||||
asteroidConfig.targetMode,
|
asteroidConfig.targetMode,
|
||||||
rotation
|
rotation
|
||||||
);
|
);
|
||||||
|
|
||||||
const mesh = this.scene.getMeshByName(asteroidConfig.id);
|
|
||||||
if (mesh) {
|
|
||||||
asteroids.push(mesh);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug(`[LevelDeserializer] Created ${asteroids.length} asteroid meshes (hidden: ${hidden})`);
|
log.debug(`[LevelDeserializer] Created ${this.config.asteroids.length} asteroid meshes (hidden: ${hidden})`);
|
||||||
return asteroids;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -406,7 +406,7 @@ export class Level1 implements Level {
|
|||||||
);
|
);
|
||||||
|
|
||||||
this._startBase = entities.startBase;
|
this._startBase = entities.startBase;
|
||||||
this._asteroidCount = entities.asteroids.length;
|
this._asteroidCount = entities.asteroidCount;
|
||||||
|
|
||||||
// Initialize scoreboard with asteroid count
|
// Initialize scoreboard with asteroid count
|
||||||
this._ship.scoreboard.setRemainingCount(this._asteroidCount);
|
this._ship.scoreboard.setRemainingCount(this._asteroidCount);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user