Hey Folks! Helmet is now working, and was a pretty good test case for more "active" equipment to come.
I decided to make a simple equip/unequip process for now, and expand it later as-needed. So when the player wants to equip something, they right-click it and choose "equip." This does the usual pathfinding thing if needed to the item selected, then instead of adding it to the crew's "container," it gets slotted into the first appropriate slot with room. In this case, the empty "helmet" slot.
Then, once it's there, it can be unequipped by dropping it, just like any other item that was carried by the crew. The main difference here is that items equipped on the crew have their slot name in parentheses next to the item name in the UI. (See today's image, in the lower right.)
Not perfect, but it'll do the job for now.
The second piece of the puzzle was to add life support to the helmet, so it actually provided a benefit when equipped. I decided to make the helmet bestow an "airtight" container status to the player when worn, as well as just enough breathable O2 to avoid hypoxia. (About 20kPa pressure.) By doing this, the player becomes insulated from the environment, but continues to do it's existing breathing code. So minimal changes are necessary to that system, which is good!
However, the byproduct of this setup is that, as one might expect, the helmet gradually fills up with CO2 as the crew respirates the O2. That's where the rebreather comes in. Basically, I added a respiration process to the helmet that exactly reverses human respiration. It takes the CO2 out of the helmet's atmo at the same rate it's wearer creates it.
The result? I could open the airlocks, vent the ship's atmo, and the crew could still walk around and breathe! And if I took the helmet off, they'd start to suffocate. So not bad! Seems to do what it's supposed to.
One minor glitch remains, however. The debug status text on the player doesn't clear when the helmet is removed, so it looks like the player has helmet pressure even when it's off, even though they don't (and will suffocate eventually). I'm pretty sure this is just a matter of adding code to the gas container to clear it's contribution to the status text before it is destroyed on helmet removal.
Overall, I'm pretty pleased with it. It wasn't too hard to do, and things just sort of worked as they should. And we can now explore airless ships without dying!
I think I might try tackling clothes next, since it should pretty much reuse everything I did today, and hopefully won't be too hard to setup. The one difference here is that the clothes will (initially, anyway) be focused on temperature regulation rather than air, and I don't have that setup yet. In theory, I should be able to borrow a bunch of logic from NEO Scavenger, and hopefully it won't be too tricky.
Oh, one other thing. Right now, helmets work infinitely. At some point, I should add an "off" version of them, and probably some sort of running time limit, so they have a limited time use. I think that should be fairly easy to setup, though. And it should make exploring derelicts a bit more tense :)
Anyway, hope everyone has a good weekend! See you Monday.