Sign in to follow this  

Type checking, is there another way?

This topic is 2052 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 have a message class, it contains a reference to the sending object, it is intended to be inherited from by all other message types so they may hold relevant information.
The message is sent to the entity manager, which will send it to all entities, who will do what they like with the information carried by the message depending on what message it is and then send it to all components where the .
I'm unsure on how I should approach this.
my original idea was to use a single message class with an enum containing its message type and pointing to an object holding the relevant information. Problem with that is between the library and the program it would be quite messy and hard to work with as you can't extend an enum, and working with numbers directly would be a nightmare to keep track of.

So now, to my knowledge to keep it flexible and easy to work with I'm stuck with a master message and a bunch of children,
of which I assume casting into types and null checking to be my only option.

if anyone knows of any better ways to approach this any and all help is appreciated,
Thanks in advanced,
Bombshell

Share this post


Link to post
Share on other sites

This topic is 2052 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this