1 | /*! |
---|
2 | * @file story_entity.h |
---|
3 | * holds the base class of everything that is playable - that is part of the story |
---|
4 | */ |
---|
5 | |
---|
6 | |
---|
7 | #ifndef _STORY_ENTITY_H |
---|
8 | #define _STORY_ENTITY_H |
---|
9 | |
---|
10 | #include "base_object.h" |
---|
11 | #include "story_def.h" |
---|
12 | #include "error.h" |
---|
13 | |
---|
14 | |
---|
15 | typedef enum StoryEntityState |
---|
16 | { |
---|
17 | SE_STATE_RUN = 0, |
---|
18 | SE_STATE_STOP, |
---|
19 | SE_STATE_PAUSE, |
---|
20 | |
---|
21 | SE_STATE_NUM |
---|
22 | }; |
---|
23 | |
---|
24 | |
---|
25 | //! A class that represents something to play in orxonox. it is a container for worlds, movies, mission briefings, etc... |
---|
26 | class StoryEntity : virtual public BaseObject { |
---|
27 | |
---|
28 | public: |
---|
29 | StoryEntity (); |
---|
30 | virtual ~StoryEntity (); |
---|
31 | |
---|
32 | virtual void loadParams(const TiXmlElement* root); |
---|
33 | |
---|
34 | /* initialisation and loading */ |
---|
35 | /** initializes a Story Entity to the needed values */ |
---|
36 | virtual ErrorMessage init() {}; |
---|
37 | /** called to load the data into the StoryEntity*/ |
---|
38 | virtual ErrorMessage loadData() {}; |
---|
39 | /** function that unloads the data from the StoryEntity */ |
---|
40 | virtual ErrorMessage unloadData() {}; |
---|
41 | |
---|
42 | /* running, stopping and pausing */ |
---|
43 | /** starts the Entity. Starts the main cycle */ |
---|
44 | virtual bool start() = 0; |
---|
45 | /** Stops the entity. */ |
---|
46 | virtual bool stop() = 0; |
---|
47 | /** pauses the Entity, you can resume the game by calling the resume() function */ |
---|
48 | virtual bool pause() = 0; |
---|
49 | /** resumes a paused StoryEntity */ |
---|
50 | virtual bool resume() = 0; |
---|
51 | /** function that is been called when the StoryEntity is started via start() */ |
---|
52 | virtual void run() = 0; |
---|
53 | |
---|
54 | /* properties interface */ |
---|
55 | /** returns the state of this StoryEntity */ |
---|
56 | StoryEntityState getState(); |
---|
57 | |
---|
58 | /** sets the story id of the current entity, this enables it to be identified in a global context. @param storyID the story id */ |
---|
59 | inline void setStoryID(int storyID) { this->storyID = storyID; } |
---|
60 | /** sets the story id of the current entity, this enables it to be identified in a global context. @returns the story id */ |
---|
61 | inline int getStoryID() { return this->storyID; } |
---|
62 | /** sets the id of the next story entity: StoryEntities can choose their following entity themselfs. |
---|
63 | * the entity id defined here will be startet after this entity ends. this can be convenient if you |
---|
64 | * want to have a non linear story with switches. |
---|
65 | * @param nextStoryID the story id of the next StoryEntity */ |
---|
66 | inline void setNextStoryID(int nextStoryID) { this->nextStoryID = nextStoryID; } |
---|
67 | /** gets the story id of the current entity @returns story id */ |
---|
68 | inline int getNextStoryID() { return this->nextStoryID; } |
---|
69 | inline void setDescription(const char* description); |
---|
70 | /** @returns the description of this StoryEntity */ |
---|
71 | inline const char* getDescription() { return this->description; } |
---|
72 | /** toggle the menu visibility: SimpleMenu specific */ |
---|
73 | inline void addToGameMenu(int toggle) { this->bMenuEntry = (bool)toggle; } |
---|
74 | /** @returns true if the GameWorld should be contained in the SimpleMenu: SimpleMenu specific */ |
---|
75 | inline bool isContainedInMenu() { return this->bMenuEntry; } |
---|
76 | /** sets the menu item image of this StoryEntity @param name name */ |
---|
77 | inline void setMenuItemImage(const char* image); |
---|
78 | /** @returns the menu item image of this StoryEntity */ |
---|
79 | inline const char* getMenuItemImage() { return this->menuItemImage; } |
---|
80 | inline void setMenuScreenshoot(const char* image); |
---|
81 | /** @returns the menu screenshoot of this StoryEntity */ |
---|
82 | inline const char* getMenuScreenshoot() { return this->menuScreenshoot; } |
---|
83 | |
---|
84 | |
---|
85 | protected: |
---|
86 | bool isInit; //!< if the entity is initialized, this has to be true. |
---|
87 | bool isRunning; //!< is true if the entity is running |
---|
88 | bool isPaused; //!< is true if the entity is paused |
---|
89 | |
---|
90 | |
---|
91 | private: |
---|
92 | int storyID; //!< this is the number of this entity, identifying it in a list/tree... |
---|
93 | int nextStoryID; //!< if this entity has finished, this entity shall be called |
---|
94 | char* description; //!< the description of the StoryEntity |
---|
95 | char* menuItemImage; //!< the item image of the StoryEntity |
---|
96 | char* menuScreenshoot; //!< the screenshoot of the StoryEntity |
---|
97 | bool bMenuEntry; //!< If true, this GameWorld apears in the SimpleMenu: SimpleMenu specific |
---|
98 | }; |
---|
99 | |
---|
100 | #endif /* _STORY_ENTITY_H */ |
---|