/*! * @file story_entity.h * holds the base class of everything that is playable - that is part of the story */ #ifndef _STORY_ENTITY_H #define _STORY_ENTITY_H #include "base_object.h" #include "story_def.h" #include "error.h" //! A class that represents something to play in orxonox. it is a container for worlds, movies, mission briefings, etc... class StoryEntity : public BaseObject { public: StoryEntity (); virtual ~StoryEntity (); // INIT AND LOAD // /** initializes a Story Entity to default Values */ virtual ErrorMessage init() {}; /** called before loading */ virtual ErrorMessage preLoad() {}; /** called to load. */ virtual ErrorMessage load() {}; /** called right after loading */ virtual ErrorMessage postLoad() {}; /** called after postload to check for integrity. (optional) */ virtual ErrorMessage check() {}; // RUNNING // /** called shortly before starting the Entity */ virtual ErrorMessage preStart() {}; /** starts the Entity. Starts the main cycle */ virtual ErrorMessage start() = 0; /** pauses the Entity. call to resume required to get it running again */ virtual ErrorMessage pause() = 0; /** resumes the Entity after a stop/pause or suspend. */ virtual ErrorMessage resume() = 0; /** suspends the Entity detaches all mayor functions (optional) */ virtual ErrorMessage suspend() {}; /** rewinds to the beginning/last checkpoint */ virtual ErrorMessage rewind() {}; /** leaves the Entity. Ends it */ virtual ErrorMessage preStop() {}; /** Stops the entity. */ virtual ErrorMessage stop() = 0; /** sets the story id of the current entity, this enables it to be identified in a global context. @param storyID the story id */ inline void setStoryID(int storyID) { this->storyID = storyID; } /** sets the story id of the current entity, this enables it to be identified in a global context. @returns the story id */ inline int getStoryID() { this->storyID = storyID; } /** sets the id of the next story entity: StoryEntities can choose their following entity themselfs. * the entity id defined here will be startet after this entity ends. this can be convenient if you * want to have a non linear story with switches. * @param nextStoryID the story id of the next StoryEntity */ inline void setNextStoryID(int nextStoryID) { this->nextStoryID = nextStoryID; } /** gets the story id of the current entity @returns story id */ inline int getNextStoryID() { return this->nextStoryID; } protected: bool isInit; //!< if the entity is initialized, this has to be true. bool readyToRun; //!< If the entity is ready to run -> post-check. bool isPaused; //!< is true if the entity is paused bool isSuspended; //!< if the Entity is suspended. private: int storyID; //!< this is the number of this entity, identifying it in a list/tree... int nextStoryID; //!< if this entity has finished, this entity shall be called }; #endif /* _STORY_ENTITY_H */