• Advertisement
Sign in to follow this  

Handling actor (monster) types

This topic is 3448 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 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
Advertisement
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
Sign in to follow this  

  • Advertisement