Destructable Ship Parts

Hey Folks! Moving on to one of the suggestions from a couple days ago: damage modeling.

Since I'm on the lookout for things that make long transit times interesting, and ship salvage, repair, and maintenance are something I want to handle, I turned my attention to destructables today. And as an experiment, I decided to model it in the game using a dedicated component instead of purely through data.

I'm gradually shifting features like this from 100% data files to 80% code and 20% data, and it's going more smoothly. And I really should've done this from the start. Oh well, one has to learn somehow!

Anyway, now any item can have a "Destructable" component added to it, and one can specify a few things like:

  • Damage Stat - The stat on the item to monitor for damage.
  • Damage Threshold - The max value that stat can reach before an action is triggered.
  • Action - The action to trigger when it happens.
  • Check Rate - How often to check this stat.

That last one is still bad code design, since it'd be better to have an event subscription model instead of polling, but one thing at a time.

Anyway, it's only a few parameters right now, but they can do a lot. In today's image, we see busted floor tiles that expose the room to the void. These were created dynamically by assigning +10 "StatDamage" to the normal floor tile, and it detected the damage and changed to a new item: damaged floor.

This damaged floor tile is considered an obstacle for pathfinding and item placement purposes, and has a gas exchanger to boot. Similar to a doorway, it vents gas. In this case, vents gas into space "below" the floor.

In the future, I can probably add more features to this. I could have different damage stats for different things. Like, say, radiation fatigue. Or stress/strain fatigue. Or even temperature. And any of those could trigger an action that swaps the item out for another thing, which in turn, can have it's own properties and damage models. I could even have cascading damage, so it transitions from normal, to damaged, to obliterated.

Pretty cool!

Seems to be working so far. But I think the next thing will be to close the loop and make a way for crew to patch the hole. Hopefully, more on that tomorrow!