Hey Folks! Today was all about ships and ship systems, as I started prepping for adding docking to the game.
Initially, that meant a lot of reading and thinking, as I refreshed my memory on how everything worked in code, then tried to come up with ways to represent the concept of a docked "other" ship. How would AI know it could pathfind on another ship? What about gas exchange between ships? What about room and item ID uniqueness?
As I started to form a picture of what was needed, that last point became a clear place to start: I would need a better ID system to ensure things could be tracked uniquely across multiple ships/stations.
It was a fairly easy change to make: just a simple change from numerical ID to a string. There's even a built-in library for generating a guaranteed unique id (a.k.a. GUID). So I updated all ID references in the game to be string GUIDs, and I think we can now have two ships dock without any item ID collisions. (Room IDs might also need this, but I'll get to that when ready.)
The next thing I decided to do was to build a more representative ship layout, with a docking system, nav station, batteries, atmo, bed, toilet, and fridge. Still far from a complete ship, but it gives me a chance to make sure all the current systems I've developed still work.
Incidentally, they don't :)
Looks like I made changes along the way that broke a few things. Not to mention some errors. My code to calculate input points around an object, for example, wasn't working when rotated. (I had my Y axis flipped, and my rotation in the wrong handedness.) So untangling that took some time.
Then, once I had my powered things using power, and my gas things pumping gas, I noticed another issue: opening the docking airlock wouldn't vent any air. In fact, my ship seemed to think it had an airtight room outside the port wall, and that the docking airlock room was infinite in size.
As it turns out, my code to calculate rooms was tripping on some edge cases, such as a port-side docking system. And, as far as I can tell, maybe the docking system itself? Somehow the bulkheads around the docking airlock are being treated as walls, portals, obstructions, and walkable, all at the same time. So who can blame the room generation code for getting confused by that?
Tomorrow, I'll see if I can figure out why that's happening. Once done, I can verify that the ship atmo sim is working again, and then...I guess load a second ship, rotate and align it to the docking ring, and see what happens?