5 minutes
Death, Linger, Restart
Course 2 left you a loose end and told you it was deliberate. When you die, destroyShip freezes the ship, hides it, silences the gun, tags it dead, and attaches a RespawnTimer. Nothing in the entire combat set reads that timer. You sit there, invisible and stationary, for as long as you care to wait.
That was the right place to stop, because "what happens after a death" is not a question the damage code gets to answer. Here is the component that does:
Naming the death you mean
on defaults to ['game.player.died'], the cross-game name every genre in the library can agree on. Your space shooter already emits spaceshooter.player.killed for the same fact, and has since Course 2.
Two ways to reconcile that. Emit game.player.died as well, from the kill path. Now one death produces two events, every future listener has to know which one is real, and someone subscribes to both and counts a death twice. Or point the component at the name your game already uses, in the scene, in one line. The second is why on is a list of strings instead of a hardcoded constant: it is what lets a truly game-agnostic part work in a genre that had its own names first.
Continue reading
Unlock the Full Course
Every lesson, the runnable examples, and the finished build — yours to keep.