Hey there!
So, I was implementing a constructor system, where the player puts an object in a machine, and it transforms it into something else. A bit like in satisfactory, except that there is no interface, you literraly put something in and it comes out the other side after some time.
I wanted to make a system that would store the crafted item, only spitting one, untill the player picks it up.
When the player picks the item from the crafter, if there is any more in the storage, the other one will come out.
To do that, I thought of using event dispatchers. Since all craftable items are pickable, I have 2 interfaces (one for pickable and one for craftable) that includes functions for those object.
Among them, I already have a “picked up” event, so the idea was to call an event dispatcher after that, and listen to it on the constructor (since I have the reference to the spawned object).
However, it seems that to bind to a certain event dispatcher, I need a reference to the specific class that implements said event. while, idealy, I could have called “on picked up” from any class that implements the pickable interface.
Is there a way to do it?
Inside my consctructor bp:
However, the issue is that Ready to spawn, is an array of multiple classes. The constructor should not have to care about what it is crafting.
It’s the items that hold the informations about what they will be crafted too.
For example, I have an iron nugget that implements the “craftable” interface that have a function called “get product”. In the implementation, iron returns the “metal bar” class reference when “get product” is called.
Same thing for the wood class that returns the “plank” class reference when “get product” is called.
So, in the array, in our example, if we have two woods and two iron, we would have something like [plank_class, plank_class, metal_bar_class, metal_bar_class]
this is where the issue lies, I can’t have both metal bars and planks share the “On Picked Up” event dispatcher.
I can’t even create one that has the same name in both classes and try to bind to it, because even when you create two ED with the same name, you get two different nodes for “bind” with the different input type depending of the class.