Derelicts and Debug Info
Hey Folks! More work today getting a rough salvage game loop established. I added random derelicts to the map, some new debug info to the HUD, and fixed some issues that were exposed by these changes.
The derelict system turned out to be a cinch. I added a new damage status property to ships so I could spawn them new, damaged, or derelict. "New" just means spawn them normally, "damaged" means random damage is applied to them, and "derelict" means random damage and all crew is ignored. And when the ship switches from shallow to fully loaded, it checks that property, and applies a handful of random damage passes on the ship after all tiles are loaded.
I had to bar it from damaging the player's ship during docking, as well as avoid spawning NPCs on derelict ships when the chargen or plot manager needs to create new ones. But otherwise, it was pretty straightforward.
I've also been meaning to update the UI with mouseover info, so I can see item stats more readily. So I added stats like the item name under the cursor, and in cases where it's a gas container, its gasses, pressures, and temperature stats. This might just be debug info for now, but when playing RimWorld, I found the live stats for rooms/items under the cursor really handy.
Immediately upon doing this, I found a bug in the gas system. On ships where a wall has been damaged, and that wall separates a voided room from more void, I end up with NaN gas amounts in each room. There was a limitation in the gas exchange code that required at least one room to be non-void, so I updated it to skip processing such situations. Since a boundless void cannot contain a gas, this was an unnecessary calculation anyway, and it fixed the gas system so punctured rooms lost air gradually again.
Also during testing, I finally found the reason I could become an LEOfficer when imprisoned during chargen. It was a case of the LEOfficer filter missing the imprisoned flag one gets when they are first imprisoned (as opposed to the prisoner career flag one gets when finishing prison).
Finally, I fixed a bugs involving items appearing when they shouldn't. It was a bug in removing items from containers as a result of an interaction (like eating a food pack from inventory), and this was just a matter of explicitly destroying the object after removal.
With all that done, I can now create a character, launch with their starter ship, check local space for derelicts, fly to one, dock with it, and board it. If there's anything on it I can carry, I can pick those up individually, and return to a station to sell them.
However, that is far from profitable. So it'd be better if there were things I could salvage besides food packets and hull patches. I think this means disassembling equipment like nav consoles or air pumps into carry-able parts. And/or moving around heavy things like gas canisters and batteries.
The disassembly probably means some new items defined as parts, and a new interaction to generate them when executed. I think the mode switching code will add the new parts where the old item was, which might be fine. But in some cases, it should probably try to find space around the old item, if that old item was something like a wall/floor. Basically, make sure the resulting items are in a place the player can reach them.
Moving heavy items around is either really easy or complex, depending on how it's done. If I want the player to put a 2-meter high gas canister in their pocket, I can add a "pick-up" option to the list of things the player does to canisters. This is trivial to do, but really unrealistic.
If I want the player to be limited in how they carry such things, like holding it in two hands and hauling them one item at a time, this is harder. This requires a more sophisticated inventory system.
For now, I think I'll go simple-yet-dumb. At least it gets things moving. I might also need to add some way to manually drop items. And if it's not too much work, maybe I can add a "Haul" interaction that pockets the item, walks to the barter zone, then drops it there.
Anyway, that simple-yet-dumb option lets me offload more valuable items from a ship, and maybe turns into a more interesting game loop. We'll see!