Quote:Original post by Sean_Seanston
Hmmm... yeah, probably makes more sense. Keep 1 big input function but have it manage the other ones that actually implement the behaviour. That probably is a good idea.
That way, you can use a full-on object to pass commands, allowing you to pass an arbitrary amount of information to the entity. You might be able to inject a little extra flexibility by encoding part of the instructions in a string. Of course, if you find the strings getting too complicated, you probably want a scripting system.
This might not be as good as it sounds, though.
Quote:There aren't any glaring problems with my concept in general though? I think I'll go with #1 but with the single function controlling the private functions. Should be alright for my current purposes at least.
Just that you may be making things far more complicated and messy than they need to be. Bear in mind the
Single Responsibility Principle. Unless you can put almost all the command parsing in an Entity base class, which is unlikely, you are likely to wind up with a major violation of this principle, with event parsing code spread out between entity classes and scattered inside them, mixing with the actual game logic that's supposed to be in there.
You may be able to make it work, but you'll actually have to plan more carefully what kind of information passes through that one function to prevent it from turning into a hideous tangled mess. And you'll almost certainly need more than an enum if you want the system to scale farther than a very few kinds of entities.
You can make #1 work without constantly adding member functions to the entity interface. It may feel crazy at first, but if you put a little thought into the functions and make full use of their parameters, things will eventually settle down. I speak from experience with this approach.
You'll have to experiment with it. Perhaps you'll wind up with a hybrid approach, but whatever you do, don't let command interpretation get tangled with actual execution of the commands (game logic).
And again, don't forget that input handling is a different problem.
Edit: fixed link.
[Edited by - theOcelot on February 18, 2010 2:31:14 PM]