Jump to content
  • Advertisement
Sign in to follow this  
landlocked

.NET Event/Delegate Pattern for Objects

This topic is 2611 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm wondering how effective it would be to implement event handlers in game objects rather than processing everything in a "ProcessEvents," or similarly named, routine. What I'm asking is how effective would it be to add, for instance, OnDeath, OnHeal, OnAttack, OnBeingHit, etc and so on events onto my game object code and manipulate the object data and state like that rather than processing everything in a single routine in each game loop? Would this ease overall object computation and management and let me use the built-in event system in .NET or would it, in fact, complicate things? Or, is it what I "should" have been doing all along? :lol:

My current hunch is that it would make programming the individual objects a bit more laborious but it could actually help scaling and such. Given that each objects events would be specific to that object it would make maintenance a tad easier as well as a change to the object code would update all its instances. Of course, conformity could be enforced by interfaces or abstracts so it wouldn't be a big deal from a code management perspective, really.

Thanks.

Share this post


Link to post
Share on other sites
Advertisement
In general, it's a viable option, but won't be more scalable/performant. It tends to allow easier refactoring, adding new entities, reuse of entities and easier/more intuitive uptake by new developers. It tends to hurt debugging a lot, reuse of core components, and doing anything that can't be done in isolation or should be done all at once (an area of effect spell for example).

Like many design decisions, there are upsides and downsides.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!