Devtober Day #10


Welcome back to Day 10 of Devtober, in which we finally have an item system, and the next big hurdle looms overhead.

God, am I glad to finally be (mostly) done with the item system. Thankfully, that solution I thought up yesterday of switching items between rigidbody and staticbody modes while moving them seemed to do just the trick, and now we have the ability to grab, drop, and store items. Of course, there's still quite a few things to iron out, such as having items rotate correctly while being held instead of spazzing out, swapping items knocking your previously held item away, as well as smithing grids not having any collision at all, but those should at least be much easier tasks than this has been.

The rest of today was spent laying the groundwork for the game's inventory system, which will be responsible for managing item storage, both physically and data-wise. As I mentioned in yesterday's devlog, slots in a physical inventory will correspond to a specific physical location. For example, an item's position in a tool rack's inventory array would determine where it gets placed on the rack physically. And since the inventory is a resource, we can both save and load this information rather easily between game sessions, allowing us to repopulate our scene accordingly. On the other hand, we can use a similar system to save the positions of any non-stored items in the worldspace so they aren't lost either.

Inventories will also be able to maintain a whitelist of allowed item types, and check against it accordingly whenever the player tries to store an item. Special workstations, such as the anvil, will only have slots for specific item types, and always store them in the same physical location. 

Smithing grids go in the smithing grid spot, and ingots go in the ingot spot. 

This means that we can make sure the correct item will also go to the correct position, as well as swap out items easily by checking if the workstation already has that slot filled.

As for the player's inventory, it will work on a more traditional system. Items will be stored as data rather than physically, as well as be able to transfer between data and physical item at will. Since I've already done the work of abstracting physical items from their item data, this is as easy as instantiating an item object and assigning it the relevant item data from the inventory. To prevent the player's held item from being lost, we'll also save the first position in the inventory array for the held item (if any) in a similar manner to workstation slots.

And, once all that is complete and working, I plan to (finally) start working on the heat and pattern systems, which I've been itching to start for a while now. At the moment, my code is filled with all sorts of stopgaps just waiting for those mechanics to come and fill them in, but for now, we'll just have to live with a bunch of code that doesn't do anything.

At least the best part of putting all this work into making the system highly modular is that it makes future development much easier. More pain now in exchange for less pain later, I suppose. Or at least, a different kind of pain.


Anyway, that's about it for now. 'Till tomorrow,

- Ian, Lunarium Works

Get Voxelsmith

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.