/*! * @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" typedef enum StoryEntityState { SE_STATE_RUN = 0, SE_STATE_STOP, SE_STATE_PAUSE, SE_STATE_NUM }; //! A class that represents something to play in orxonox. it is a container for worlds, movies, mission briefings, etc... class StoryEntity : virtual public BaseObject { ObjectListDeclaration(StoryEntity); public: StoryEntity (); virtual ~StoryEntity (); virtual void loadParams(const TiXmlElement* root); /* initialisation and loading */ /** initializes a Story Entity to the needed values */ virtual ErrorMessage init() { return ErrorMessage(); }; /** called to load the data into the StoryEntity*/ virtual ErrorMessage loadData() { return ErrorMessage(); }; /** function that unloads the data from the StoryEntity */ virtual ErrorMessage unloadData() { return ErrorMessage(); }; /* running, stopping and pausing */ /** starts the Entity. Starts the main cycle */ virtual bool start() = 0; /** Stops the entity. */ virtual bool stop() = 0; /** pauses the Entity, you can resume the game by calling the resume() function */ virtual bool pause() = 0; /** resumes a paused StoryEntity */ virtual bool resume() = 0; /** function that is been called when the StoryEntity is started via start() */ virtual void run() = 0; /* properties interface */ /** returns the state of this StoryEntity */ StoryEntityState getState(); /** 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() { return this->storyID; } void setLoadFile(const std::string& fileName); /** @returns the Filename this StoryEntity was loaded with */ const std::string& getLoadFile() const { return this->loadFile; } bool setNextStoryName(const std::string& nextStoryName); void setNextStoryID(int nextStoryID); /** gets the story id of the current entity @returns story id */ inline int getNextStoryID() const { return this->nextStoryID; } inline void setDescription(const std::string& description); /** @returns the description of this StoryEntity */ inline const std::string& getDescription() { return this->description; } void grabWorldInfo(); /** toggle the menu visibility: SimpleMenu specific */ inline void addToGameMenu(bool toggle) { this->bMenuEntry = toggle; } /** @returns true if the GameWorld should be contained in the SimpleMenu: SimpleMenu specific */ inline bool isContainedInMenu() { return this->bMenuEntry; } /** sets the menu item image of this StoryEntity @param name name */ inline void setMenuItemImage(const std::string& image); /** @returns the menu item image of this StoryEntity */ inline const std::string& getMenuItemImage() { return this->menuItemImage; } inline void setMenuScreenshoot(const std::string& image); /** @returns the menu screenshoot of this StoryEntity */ inline const std::string& getMenuScreenshoot() { return this->menuScreenshoot; } protected: bool bInit; //!< if the entity is initialized, this has to be true. bool bRunning; //!< is true if the entity is running bool bPaused; //!< is true if the entity is paused 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 std::string loadFile; //!< The file from which this world is loaded std::string description; //!< the description of the StoryEntity std::string menuItemImage; //!< the item image of the StoryEntity std::string menuScreenshoot; //!< the screenshoot of the StoryEntity bool bMenuEntry; //!< If true, this GameWorld apears in the SimpleMenu: SimpleMenu specific }; #endif /* _STORY_ENTITY_H */