Wildcard function input

OK so I’'m really not sure if this is possible (or if it is safe) so i have functions that are doing something fairly simple but take a lot of options. for this example I will use a hypothetical remove an item from an inventory. But each character has a collection of say 5 inventory’s (equipped, key items, character Inv, etc) and I want to remove an item either by a direct item(struct) (that will be searched in the array) or by a slot.

Now i know I can do this 2 easy ways

  1. have several functions with different options ie. function 1 would only accept an inventory and a slot, function 2 would take a inventory and item, etc.
    The issue here is that i will need a LOT of (seamingly) redundant and harder to bug test(as they will be all spread out) functions.

  2. lots of wasted inputs and enums. ie. so a function that takes an inventory collection enum asking of inventory’s in the collection enum with values slot and Item, an item a slot. than in the blueprint disregard any info not selected by the enums.

Issue Here being possibly missed data and unexpected behavior. etc as someone might try to pass data to mulbible fields thinking that it might do both etc.

OK long winded explanation of issue over here are the possibility’s I have found and they would require major changes to my systems to implement (also currently I’m using prebuilt versions for most of my work (occasional bugfix implementation not counted) (BTW this inventory manager is currently a blueprint function lib atm)

So the 2 things that I have come up with so far to fix this issue are [Tutorial] How to accept wildcard structs in your UFUNCTIONs - Community & Industry Discussion - Epic Developer Community Forums
If im understanding correctly is able to take a struct wildcard and extract the info.
im seeing 2 main problems about this.

  1. I’m sot seeing some way to work with this info after it has been extracted. ie. break struct and set values and edit them in the blueprint editor (as there’s no way you will know there contents before hand)

  2. this will be the first permanent source code modification to the engine(Not that I’m unwilling to do this but I’m not super familiar with working with source anymore been 15 years or so… whole new lvl of possible bugs that in so far I have avoided for the most part.)

Option 2

Cast to X

currently all my inventory’s/inventoryCollection’s are all built around (fairly large Structs of Structs)
OK so this is something I’m not super familiar with but i think that this would theoretically work but basically create an input of type object on the function and pass my inventory to that and in the inventory manager run a cast to (either inventory or inventory collection) and another object input that will cast to either (slot or item)
Problems i could see out of this issue

  1. If I’m not mistaken I will have to convert my Structs of Structs to full fledged blueprints to gain the cast to ability.

  2. would have to be careful as some things might accidentally (not very likely in this particular case) be casted in properly IE. say in the case were the object is passing between a float and int and the value contains a whole number will the cast to success both times?

advice on witch one would be best (safest) in this given scenario or even other options that might be simpler. I’ve got no problems doing the research in to the correct path but these are both very large and time consuming options and I don’t even know if I’m looking the the right direction here, or if I’m just way to tired :stuck_out_tongue:

As a side note i know that I could place the inventory manager in with the inventory collection blueprint and solve this whole thing but the manager is huge and and my items are fairly complex so I’ve got it in a BPFunctionLib for garbage collection and redundant action reasons (IE. after a battle I would expect the inventory manager called no fewer than 5 times and I don’t want the calls to scramble each other up) also helps keep modular ability.

Erm so this might be a complex example but let me know if i can do anything to clarify.

I don’t know but whatabout try a type input(only works in c++)