Hello Everyone,
I am developing my new game and by basis of it is a complex inventory system that is combination of Arma 3 inventory system with resident evil’s tetris inventory system. What my question is, I want to know if my implementation is correct. I am a web dev for 7 years so I know about programming and OOP basics, but I was wondering if there is a better solution to this.
FUNCTIONALITY:
To build a tetris like system, I followed this video to build the tetris system, then I build the other inventory section, such as if I get close to objects on the ground they will autopopulate the list of the other inventory section, that can either be world, a character or a treasure.
Next is to implement functionality of equipment and changing inventory tetris grid whether I select backpack, vest or clothes inventory option.
My question is regarding the implementation of this system. I am currently relying heavily on DataTables and Structs and they sometimes cause me alot of pain. Most of the time, rather than doing something new, I am putting out fires. I will now talk about implementation.
IMPLEMENTATION:
First, to have items in real world, I have actors:
_Item is the parent Item object. it is being used to move items around so I wont be redoing it again and again. All _Item does is setMaterial, and ModifyQuantity which is common among all the Items. Now to the important part. It also has a variable called ST_Item. ST_Item is the heart of the Inventory. a Struct that basically is basis for all the items in the inventory. Problem is, I am not sure about its implementation.
ST_Item struct:
if you are wondering why am I defining all the structs of each item type in the ST Item, thats basically it, I dont know how to handle this apart from this way. Everywhere, I am using ItemType to check what Struct would I need to use.
This is causing its own problems. For example, a vest and backpack can have their own ST Items, but it wont let me do that and keep saying variable is invalid, so I had to create a copy of ST_Item without Vest and Backpack Struct, meaning I cannot have those in my inventory themselves hurting the flexibility of my inventory system.
Backpack struct:
Modular ST_Item struct:
Now, when I am going to implement the Equipment section, I would need Struct for each of the different items, Torch, Compass, Map and Radio. SImilar to ST_Item, I would need to define them in EquipmentStruct. I wanted to know if this is the correct approach and if there is no other way to do this properly.
I am from JS background so It sees a bit weird to me to work with OOP, but any suggestion would be great. Thank you!