Hey Folks! I went ahead and hard-coded the gas exchange stuff today, as mentioned yesterday.
Basically, I removed the special "Door/Portal" class from the game, which previously handled gas exchange, and just made Condition Owners (COs) able to do this instead. They now have a list of "Update Commands," which are basically just function calls with parameters that are in the data definitions for each CO. Surprisingly, it wasn't hard to swap out this old code for new, and the room gases were updating normally again pretty soon after. It's even more extensible now, since it allows the data to define input and output points relative to the CO, instead of assuming hard-coded tile positions for the Portal/Door class.
I then set about coding a bespoke function for respiration, and quickly bogged-down again.
At first, I tried to make this generic enough to handle both breathing and air pumps. However, I soon decided that these were different enough that I should just make this first one breathing-only. That helped for a bit, and I was able to code the parts where it takes in a volume of gas, and based on room pressure, would figure out the partial pressure of the desired gas being inhaled. It then removed that gas from room A, and deposited the same amount of a different gas into room B. All stuff the parameters would control.
Unfortunately, I got stuck in the middle of these two pieces, where the inhaled gas is applied to the CO (e.g. a crew). Do I just add an equivalent amount of O2 to the CO's stats? That'd probably work, but how would it handle other gases? What about toxic gases, for example? Should I write this function to specifically check certain gases that have an effect on crew? Does that mean this function is only used by crew? Should I just have the function iterate through all gases present, try applying them to CO stats, and let the CO sort out which it accepts?
And how does this all relate to air pumps, which basically take everything in room A and pump it into room B? And for that matter, what about filtering/scrubbing air?
Paralyzed by thought again. I'm thinking the best approach is to "just game jam it" and worry about it later. But I think my brain was so fried by this afternoon I couldn't even do that. Hopefully, tomorrow is better.