Sign in to follow this  
Guy Meh

Handling actor (monster) types

Recommended Posts

I'm thinking of splitting my actors (that is, the monsters) into the actor itself and an actor type. The actor type would hold invariant data such as the actor's maximum health and be used to choose what sprite to use when drawing the actor. Basically, the actor type would have all the stuff that you'd define in the configuration files. I'm just wondering how to handle my collection of actor types and their relationships to the actors. I've thought of having an actor keep a regular pointer to its actor type, but that may make serialization tricky. I don't want to serialize the collection of actor types, whatever it will look like, since I can use the actor type collection between different play sessions and they're defined in my configuration files anyway. Have others encountered something like this?

Share this post


Link to post
Share on other sites
Give each actor type a name (such as "Monster_1_Type"), and have the actors serialize that type name. Create a map that goes from type name to type class, and all your actors will be able to grab a pointer to their type class when they're created or loaded from disk. Of course, you always want to load the actor types first (preferably once when the game loads).

Share this post


Link to post
Share on other sites

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