I’ve extensively looked at data assets, data tables, and lots of other things already and just feeling really frustrated.
I want a simple to define set of items with high flexibility.
Let’s say I have a sword.
I could create a struct that has “name”, “icon”, “damage”
Then I could create a data table that has all sorts of different types of swords.
But I also have some item, french bread
I could create a food struct that has “name”, “icon”, “hungerFill”
I could create a variety of breads.
But what if I want to make the some french bread also be equipped and be a weapon with a damage of 1. A bread sword!
Well I could just create a megaBaseItem
I could create a struct that has “name”, “icon”, “damage”, “hungerFill”, and “everythingPossible”
but now I have tons of items with ‘blank fields’ or I have to deal with what it means an item to recognize 0 or -1 as dummy value.
This feels wrong too.
With making items in ue4. I totally get I could have ‘components’ for ‘sword component’ and ‘food component’ and it makes perfect sense on how to properly separate these at a UActor type level.
But I have no idea how to handle this from a data driven side of the world.
I was thinking of just having a json file that I parse things manually myself because and handle the ‘dynamicness’ myself.
The problem with this, is I feel like I start to lose some benefit of having ‘typing’ and that I’d still love to be able to do “someItem.damage”
Even if that means doing something like “wildcardItem.As<Sword>().getDamage()” and “wildcardItem.As<Food>().getHungerFill()”.
But I’d also be interested in getting something like ItemDataTable.get(“FrenchBread”).As<Sword>().getDamage()
I suppose I could always create some ‘dummyClass’ whenever you do ItemDataTable.get(something) and then have regular interfaces on object. Sorta as a short lived object maybe, even just as a proxy data object for the actual UActor.
Ideally I think I’d like to define the item as
{
"name": "FrenchBread",
"icon": "Texture2D'/Game/Icons/Textures/FrenchBread.FrenchBread'",
"components": {
"meleeComponent": {
"damage": 1
},
"foodComponent": {
"hungerFill": 5
// someMissingField that defaults to some defined constant for foodComponent someHow?
}
]
}
But I wasn’t sure if this was great either.
Any thoughts/suggestions?