Pattern for performing game actions

Posted by Arkiliknam on Game Development See other posts from Game Development or by Arkiliknam
Published on 2012-09-25T18:53:20Z Indexed on 2012/09/25 21:51 UTC
Read the original article Hit count: 297

Filed under:
|

Is there a generally accepted pattern for performing various actions within a game? A way a player can perform actions and also that an AI might perform actions, such as move, attack, self-destruct, etc.

I currently have an abstract BaseAction which uses .NET generics to specify the different objects that get returned by the various actions. This is all implemented in a pattern similar to the Command, where each action is responsible for itself and does all that it needs.

My reasoning for being abstract is so that I may have a single ActionHandler, and AI can just queue up different action implementing the baseAction. And the reason it is generic is so that the different actions can return result information relevant to the action (as different actions can have totally different outcomes in the game), along with some common beforeAction and afterAction implementations.

So... is there a more accepted way of doing this, or does this sound alright?

© Game Development or respective owner

Related posts about ai

Related posts about design-patterns