Week 4: Power to the People

Everything is more interesting in the dark.

An image of the ship cabin with all the lights off, but with a flashlight shining on the wall, illuminating a small circle in the middle. Small enough to make you wish for more.
This is enough light, right?

This week, I built an electrical system that controls power to the rest of the ship. If you lose a fuse, everything stops, leaving you adrift in the eerie quietness of space.

In The Dark

Before breaking everything, I realized that the cabin is very dark when the lights go out. I wanted the player to have some ability to stumble around and find fuses. One spotlight component later, and voila. Flashlight.

I'll revisit it later to make sure the amount and angle of light is right. And I have later plans to add in recharging to add just a touch of humor to a ... dark situation.

Thank you, I'll be here all week.

Power Connects Everything

The flashlight was the easy part. The harder part was building a power system that could affect everything else on the ship when it failed.

I extended my fusebox to be more functional. With both fuses in, power is on. Pull either fuse, and everything fails. Just one problem. The current mechanism for polling systems works on a 30-second timer. I needed systems to respond to a broken fuse immediately, not whenever the next update would be.

Event Dispatchers

The solution was Event Dispatchers. When the power state changes, the game broadcasts "PowerLost" or "PowerRestored" events. Any system that cares about power subscribes to those events and responds immediately.

So now when you yank a fuse, the fuse tells the fusebox to check the power state, which will tell the game instance that power has failed, and the game instance will tell anyone who cares. No polling required.

The Cascade

So I could see it in action, I coded a debug key (B for blow) to kill a random fuse. When a fuse dies, I swap the fuse texture for one that looks fried, so that a player knows which one to replace. I also play an audio cue to let the player know something just went terribly wrong.

Cabin interior while holding a dead fuse. The fuse's wrapper is obviously charred and blackened. There is no where to store dead fuses.
Where do I put the dead fuses, though?

Also, I had to make all the other systems respond to the power failure. The engine background audio cuts out. The lights die. O2 stops producing. Everything cascades in real-time.

Then the player can make their way to the fuse box and use the new flashlight to see which fuse needs to be pulled. If they remember where the backup fuses are, they can slot in a replacement and the systems come online immediately.

Cascading Consequences

The hope is, layering in all these systems will eventually make Running Late a real game. Life support currently depends on electrical systems. Engines will too, when those are implemented. The idea is to stack systems on top of systems until there's enough interesting, interlocking pieces to entertain you for the length of the ride.

But more importantly, the more that's going on, the more it feels like you're in a ship, and not just a room.

Week 5: Navigation

Next week is all about navigation. I'm a bit nervous about whipping up a console interface, but I have to keep telling myself, perfect is the enemy of good. So, I'm off to work on sensor calibration, course corrections, and what happens when you start drifting.

The ship has power. Now let's figure out where it's going.