I began researching delegates and events recently to try and improve the versatility of my classes. Considering various classes in my game are going to be needing player input (keyboard or mouse), I’ve set up delegate events such as OnMouseDown, OnMouseUp, and OnKeyPressed. Each event passes an object containing data for the input (screen position of click, world position, targeted unit, etc), which gives me super easy access to a flexible player input from anywhere.
While it seems effective and clean, I’m curious if there’s any downfalls to it or perhaps any better methods?
Also another question, if anybody is experienced in Garry’s Mod Lua, you’re able to hook into various events such as :
And modify the parameters of the event (CTakeDamageInfo) before its passed to the entity taking damage. Is this possibly the work of delegate events on a lower level?