Stacking Up

Hey Folks! Almost there with the stacking feature. I've actually got loot spawning into an area and stacking correctly, it seems. And now we're down to edge cases and other ways loot appears in the game.

Continuing yesterday's work, I ended up making several changes to item stacking and unstacking. Unsurprisingly, more than a few errors were made along the way in my first draft, and I had to rethink a few steps. And today's work was not exempt from error, either. Even by the time I got everything compiling, I had to fix crashes a number of times before I saw a stack appear in the game.

Today's image, however, is the result. A rough draft of wall salvage loot, consisting of two x5 stacks of aluminum scrap metal, a x6 stack of small mechanical parts, a x17 stack of carbon fiber trash, and a x21 stack of general trash. The numbers will require tweaking, as will material types, and probably even UI/graphics treatment of the stack counters.

But not bad! I can theoretically spawn components, scrap, and trash loot in stacks on, say, a derelict.

From here, I have a bit more work to do. First, I have to fix a bug that I introduced with equipping items, likely due to the branching code there now to handle slots vs. stacks vs. containers.

Next, I need to expand the code I added to spawn loot into nearby stacks so it also covers AI dropping items, and interactions. That will open up the possibility to interact with objects, like a wall, and have it yield stacks of loot around the interaction. I.e. use a laser torch on a wall to get scrap and trash from it. Or have the damage interaction degrade the item into a damaged state with trash around it.

I also need to do a bit of tidying up of the stacks as they interact with the UI. Currently, mousing over a stack shows a long list of everything in the stack. It'd be better if a stack was listed like "Hull Patch x5" instead of the same word 5 times. And on a similar note, those extra stack items should probably be ignored by raycasts, mouse events, and other game logic. So I may have to disable their collision meshes at the same time as I disable their render meshes. (And, honestly, the mesh objects I'm using for items should eventually be cleaned-up to be more consistent and useful, and maybe optimized.)

Finally, I'll also need to verify that AI can pick up, drop, and generally work with stacks of items, whether they be on the floor, in a container, on themselves, or maybe even slotted.

Lots of potential cases to consider. But hopefully the bulk of the system is done now, and I can optionally tackle these cases as they are needed!

Tags: Ostranauts