[1505] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * > www.orxonox.net < |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
| 23 | * Fabian 'x3n' Landau |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | /** |
---|
| 30 | @file BaseObject.h |
---|
| 31 | @brief Definition of the BaseObject class. |
---|
| 32 | |
---|
| 33 | The BaseObject is the parent of all classes representing an instance in the game. |
---|
| 34 | */ |
---|
| 35 | |
---|
| 36 | #ifndef _BaseObject_H__ |
---|
| 37 | #define _BaseObject_H__ |
---|
| 38 | |
---|
| 39 | #include "CorePrereqs.h" |
---|
| 40 | |
---|
[1747] | 41 | #include "Super.h" |
---|
| 42 | #include "OrxonoxClass.h" |
---|
[1841] | 43 | #include "XMLIncludes.h" |
---|
[1505] | 44 | |
---|
| 45 | namespace orxonox |
---|
| 46 | { |
---|
[2019] | 47 | class Scene; |
---|
| 48 | class Gametype; |
---|
| 49 | |
---|
[1505] | 50 | //! The BaseObject is the parent of all classes representing an instance in the game. |
---|
| 51 | class _CoreExport BaseObject : virtual public OrxonoxClass |
---|
| 52 | { |
---|
[1558] | 53 | friend class WorldEntity; |
---|
| 54 | |
---|
[1505] | 55 | public: |
---|
[2019] | 56 | BaseObject(BaseObject* creator); |
---|
[1505] | 57 | virtual ~BaseObject(); |
---|
| 58 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
| 59 | |
---|
[1558] | 60 | /** @brief Returns if the object was initialized (passed the object registration). @return True was the object is initialized */ |
---|
| 61 | inline bool isInitialized() const { return this->bInitialized_; } |
---|
| 62 | |
---|
[1505] | 63 | /** @brief Sets the name of the object. @param name The name */ |
---|
[1950] | 64 | inline void setName(const std::string& name) { this->oldName_ = this->name_; this->name_ = name; this->changedName(); } |
---|
| 65 | /** @brief Returns the name of the object. */ |
---|
[1505] | 66 | inline const std::string& getName() const { return this->name_; } |
---|
[1950] | 67 | /** @brief Returns the old name of the object. */ |
---|
| 68 | inline const std::string& getOldName() const { return this->oldName_; } |
---|
[1505] | 69 | /** @brief This function gets called if the name of the object changes. */ |
---|
| 70 | virtual void changedName() {} |
---|
| 71 | |
---|
| 72 | /** @brief Sets the state of the objects activity. @param bActive True = active */ |
---|
[1608] | 73 | inline void setActive(bool bActive) { this->bActive_ = bActive; this->changedActivity(); } |
---|
[1505] | 74 | /** @brief Returns the state of the objects activity. @return The state of the activity */ |
---|
[1558] | 75 | inline bool isActive() const { return this->bActive_; } |
---|
[1505] | 76 | /** @brief This function gets called if the activity of the object changes. */ |
---|
| 77 | virtual void changedActivity() {} |
---|
| 78 | |
---|
| 79 | /** @brief Sets the state of the objects visibility. @param bVisible True = visible */ |
---|
[1608] | 80 | inline void setVisible(bool bVisible) { this->bVisible_ = bVisible; this->changedVisibility(); } |
---|
[1505] | 81 | /** @brief Returns the state of the objects visibility. @return The state of the visibility */ |
---|
[1558] | 82 | inline bool isVisible() const { return this->bVisible_; } |
---|
[1505] | 83 | /** @brief This function gets called if the visibility of the object changes. */ |
---|
| 84 | virtual void changedVisibility() {} |
---|
| 85 | |
---|
[2010] | 86 | /** @brief Sets a pointer to the xml file that loaded this object. @param file The pointer to the XMLFile */ |
---|
| 87 | inline void setFile(const XMLFile* file) { this->file_ = file; } |
---|
| 88 | /** @brief Returns a pointer to the XMLFile that loaded this object. @return The XMLFile */ |
---|
| 89 | inline const XMLFile* getFile() const { return this->file_; } |
---|
| 90 | const std::string& getFilename() const; |
---|
[1505] | 91 | |
---|
[1989] | 92 | void addTemplate(const std::string& name); |
---|
| 93 | void addTemplate(Template* temp); |
---|
| 94 | /** @brief Returns the set of all aplied templates. */ |
---|
| 95 | inline const std::set<Template*>& getTemplates() const |
---|
| 96 | { return this->templates_; } |
---|
| 97 | |
---|
[1505] | 98 | virtual inline void setNamespace(Namespace* ns) { this->namespace_ = ns; } |
---|
| 99 | inline Namespace* getNamespace() const { return this->namespace_; } |
---|
| 100 | |
---|
[2019] | 101 | inline void setCreator(BaseObject* creator) { this->creator_ = creator; } |
---|
| 102 | inline BaseObject* getCreator() const { return this->creator_; } |
---|
| 103 | |
---|
| 104 | inline void setScene(Scene* scene) { this->scene_ = scene; } |
---|
| 105 | inline Scene* getScene() const { return this->scene_; } |
---|
| 106 | |
---|
| 107 | inline void setGametype(Gametype* gametype) { this->oldGametype_ = this->gametype_; this->gametype_ = gametype; this->changedGametype(); } |
---|
| 108 | inline Gametype* getGametype() const { return this->gametype_; } |
---|
| 109 | inline Gametype* getOldGametype() const { return this->oldGametype_; } |
---|
| 110 | virtual inline void changedGametype() {} |
---|
| 111 | |
---|
[1505] | 112 | /** @brief Sets the indentation of the debug output in the Loader. @param indentation The indentation */ |
---|
| 113 | inline void setLoaderIndentation(const std::string& indentation) { this->loaderIndentation_ = indentation; } |
---|
| 114 | /** @brief Returns the indentation of the debug output in the Loader. @return The indentation */ |
---|
| 115 | inline const std::string& getLoaderIndentation() const { return this->loaderIndentation_; } |
---|
| 116 | |
---|
[1940] | 117 | protected: |
---|
[1505] | 118 | std::string name_; //!< The name of the object |
---|
[1950] | 119 | std::string oldName_; //!< The old name of the object |
---|
[1505] | 120 | bool bActive_; //!< True = the object is active |
---|
| 121 | bool bVisible_; //!< True = the object is visible |
---|
[1940] | 122 | |
---|
| 123 | private: |
---|
[1989] | 124 | Template* getTemplate(unsigned int index) const; |
---|
| 125 | |
---|
[2019] | 126 | bool bInitialized_; //!< True if the object was initialized (passed the object registration) |
---|
| 127 | const XMLFile* file_; //!< The XMLFile that loaded this object |
---|
| 128 | std::string loaderIndentation_; //!< Indentation of the debug output in the Loader |
---|
| 129 | Namespace* namespace_; |
---|
| 130 | BaseObject* creator_; |
---|
| 131 | Scene* scene_; |
---|
| 132 | Gametype* gametype_; |
---|
| 133 | Gametype* oldGametype_; |
---|
[1989] | 134 | std::set<Template*> templates_; |
---|
[1505] | 135 | }; |
---|
[1747] | 136 | |
---|
| 137 | SUPER_FUNCTION(0, BaseObject, XMLPort, false); |
---|
| 138 | SUPER_FUNCTION(2, BaseObject, changedActivity, false); |
---|
| 139 | SUPER_FUNCTION(3, BaseObject, changedVisibility, false); |
---|
[1505] | 140 | } |
---|
| 141 | |
---|
| 142 | #endif /* _BaseObject_H__ */ |
---|