#How can I do something like this?
1 messages · Page 1 of 1 (latest)
you should share the errors to make it easier for people to help.
In this case, you're defining a parameter of type T but just not supplying a value to it when calling RemoveItem<ScriptObject_Weapon>(slot);. the error would tell you this
if items have IDs, i don't see why you'd need this type in the first place though.
It's for categories, ie weapon, items, apparel, etc
the ID could be unique per category regardless
either way you either need to supply a value for that T type parameter, or just remove it. Realistically if you don't need the generic that can be removed too
I DID find a workaround, using typeof. Not EXACTLY what I wanted to do but it's much better than what I was doing before
Still makes no sense why youd ever need the type here unless youre storing this in some dictionary of <type, list<type>>
Can you show the implementation of RemoveItem
@harsh remnant I can but currently I'm away from my computer and won't be back for a while.
I can at least tell you the inventory has different lists for different item types. This function is simply does an if/else statement to find the correct item type, and accompanying list, and then removing the 'slot' from the list
I could use an enum, but if I ever wanted to add more item types, Id have to add to the enum and all scripts thereof. Enums can also get messy that way, I've learned
You dont need an enum. A dictionary of <type, list> would be fine here and would allow for infinite types without modifying the implementation of RemoveItem