When airships break apart

Airships: Conquer the Skies
29 Oct 2013, 4:03 p.m.

The previous installment of the dev blog dealt with combat and damage, but posed the question: what happens when modules disintegrate?

This can happen because the module's been shot to pieces, or because the ship crashed into the ground or rammed another ship.

The problem is that the airship code heavily relies on there being a path between all the ship's modules for the crew to move through.

So if the only module that's connecting two parts of the ship is removed, everything crashes. My first attempt at preventing this was to disallow the removal of modules that would interrupt pathing.

But this had weird results: airships would end up as a curled-up "snake" of connected modules, only able to further disintegrate from the ends. To fix this, airships have to be able to break up into multiple pieces! I kind of wanted to avoid putting this in, because it sounded hard, if fun.

The eventual solution I came up with is as follows: modules on the edge of the ship can disintegrate. If pathing is interrupted, I can use a flood fill to find the separate chunks of connected pathing the ship has fallen apart into.

Then I take all the smaller chunks and turn them into their own airships, transferring the modules, tiles and crew of the original ship.

After some fiddling and fine-tuning, this actually works!

Next up: ramming, crashing, avoiding proper physics like the plague.