This might be a really silly question, but I’m trying to write a generic event messaging system, where every function in my game from attacks to drinking potions is notified through some function NotifyEvent(EventID, EventData). This gets sent to every component on the character/item/door/whatever, the idea being that items which have specific functionality for that event will be activated and the rest will ignore them. So if I run NotifyEvent(“Attack”, data), the sword I’m holding will play its swinging animation, but my armor will completely ignore it.
That having been said, different verbs require vastly different amounts and types of data. A weapon might want to know which enemy it’s attacking, a vehicle might need an axis value to read how hard you’re stomping on the gas, and consumables will want a callback to the character who consumes them. Is there an argument I can receive in my main method which will let me pass it any type of data or struct, and leave me to do my type safety checks inside each specific implementation?