logo
By Lawrence

5 minutes

Win and Lose

Everything in the scene announces things. Ships die and say so; waves clear and say so; the freighter that doesn't exist would announce its own destruction. Nobody is listening. You can kill every enemy in the field and the game will not react, because no component in the scene holds an opinion about how a run ends.

One line fixes it:

        "MissionDirector": { "killQuota": 6 }

Six kills wins. And because the component name matches its System's name, the loader wires it for you. No cabinet edit this lesson.

What a run is made of

src/components/MissionDirector/MissionDirector.defs.ts
export interface MissionDirectorInput {
  /** Player deaths allowed before the run is lost. */
  lives?: number;
  /** Kills that win the run outright. 0 disables the kill-count win (an escort
   *  mission is won by delivering the convoy to the final gate instead). */
  killQuota?: number;
  /** Hostiles downed so far. */
  kills?: number;
  /** True once the escort track has been completed. */
  objectiveComplete?: boolean;
  /** Current run state. */
  status?: MissionStatus;
}

Three numbers, a flag and a string: five fields, all serializable, all meaningful after a reload. lives defaults to 3. kills and objectiveComplete are progress. status is 'active' | 'won' | 'lost'.

killQuota: 0 is the interesting default: it disables the kill-count win. A mission with no quota can't be won by shooting, and has to be won some other way, which is the door the next section walks through.

A quota wins the run here because "clear every wave" cannot. Last lesson's director has an ALL_CLEARED event that sounds exactly right, and it can never fire in this scene: four ships are bucketed behind a waypoint gate that doesn't exist, so a wave stays pending forever. A quota needs nothing from the schedule.

Continue reading

Unlock the Full Course

Every lesson, the runnable examples, and the finished build — yours to keep.

$9one-time

Was this page helpful?

We read every note — tell us what's working and what isn't.

↑↓ NavigateEnter SelectEsc CloseCtrl+K Open Search