| 1 | /* |
|---|
| 2 | ================================================================================= |
|---|
| 3 | This file is part of Cafu, the open-source game engine and graphics engine |
|---|
| 4 | for multiplayer, cross-platform, real-time 3D action. |
|---|
| 5 | Copyright (C) 2002-2012 Carsten Fuchs Software. |
|---|
| 6 | |
|---|
| 7 | Cafu is free software: you can redistribute it and/or modify it under the terms |
|---|
| 8 | of the GNU General Public License as published by the Free Software Foundation, |
|---|
| 9 | either version 3 of the License, or (at your option) any later version. |
|---|
| 10 | |
|---|
| 11 | Cafu is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
|---|
| 12 | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|---|
| 13 | PURPOSE. See the GNU General Public License for more details. |
|---|
| 14 | |
|---|
| 15 | You should have received a copy of the GNU General Public License |
|---|
| 16 | along with Cafu. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 17 | |
|---|
| 18 | For support and more information about Cafu, visit us at <http://www.cafu.de>. |
|---|
| 19 | ================================================================================= |
|---|
| 20 | */ |
|---|
| 21 | |
|---|
| 22 | #ifndef CAFU_ENTITY_CLASS_HPP_INCLUDED |
|---|
| 23 | #define CAFU_ENTITY_CLASS_HPP_INCLUDED |
|---|
| 24 | |
|---|
| 25 | #include "Math3D/BoundingBox.hpp" |
|---|
| 26 | #include "Templates/Array.hpp" |
|---|
| 27 | #include "wx/wx.h" |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | class EntClassVarT; |
|---|
| 31 | class GameConfigT; |
|---|
| 32 | struct lua_State; |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | class HelperInfoT |
|---|
| 36 | { |
|---|
| 37 | public: |
|---|
| 38 | |
|---|
| 39 | wxString Name; |
|---|
| 40 | ArrayT<wxString> Parameters; |
|---|
| 41 | }; |
|---|
| 42 | |
|---|
| 43 | |
|---|
| 44 | class EntityClassT |
|---|
| 45 | { |
|---|
| 46 | public: |
|---|
| 47 | |
|---|
| 48 | class InitErrorT { }; |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | /// The constructor. It creates a new entity class instance from the contents of the given Lua stack. |
|---|
| 52 | /// At Lua stack index -2, the name of the entity class is provided. |
|---|
| 53 | /// At Lua stack index -1, there is a table with the variables and meta-information for this class. |
|---|
| 54 | /// @param GameConfig The game configuration that this entity class is for. |
|---|
| 55 | /// @param LuaState The representation of the Lua stack from whose contents the EntityClassT instance is created. |
|---|
| 56 | EntityClassT(const GameConfigT& GameConfig, lua_State* LuaState); |
|---|
| 57 | |
|---|
| 58 | /// The constructor for creating an entity class that is *unknown/undefined* in the game config. |
|---|
| 59 | /// Instances of such entity classes are kept in the map document (vs. the game config). |
|---|
| 60 | EntityClassT(const GameConfigT& GameConfig, const wxString& Name, bool HasOrigin); |
|---|
| 61 | |
|---|
| 62 | /// The destructor. |
|---|
| 63 | ~EntityClassT(); |
|---|
| 64 | |
|---|
| 65 | const GameConfigT& GetGameConfig() const { return m_GameConfig; } |
|---|
| 66 | bool IsInGameConfig() const; ///< Returns whether this class is defined/known in the game config. When false, this is an undefined class from importing a map file that was made for another game or game config. |
|---|
| 67 | wxString GetName() const { return m_Name; } |
|---|
| 68 | wxString GetDescription() const { return m_Description=="" ? m_Name : m_Description; } ///< Returns the description of this entity class. |
|---|
| 69 | wxColour GetColor() const { return m_Color; } ///< Returns the (render) color of this entity class. |
|---|
| 70 | |
|---|
| 71 | /// Returns the substitutional bounding-box for entities of this class. |
|---|
| 72 | /// Usually used for entities that have no other representation (e.g. brushes or patches), |
|---|
| 73 | /// that is, for "point entities", not for "solid entities". |
|---|
| 74 | const BoundingBox3fT& GetBoundingBox() const { return m_BoundingBox; } |
|---|
| 75 | |
|---|
| 76 | bool IsSolidClass() const { return m_Solid; } |
|---|
| 77 | |
|---|
| 78 | const EntClassVarT* FindVar(const wxString& Name, unsigned long* Index=NULL) const; |
|---|
| 79 | const ArrayT<const EntClassVarT*>& GetVariables() const { return m_Variables; } |
|---|
| 80 | |
|---|
| 81 | const ArrayT<const HelperInfoT*>& GetHelpers() const { return m_Helpers; } |
|---|
| 82 | |
|---|
| 83 | |
|---|
| 84 | private: |
|---|
| 85 | |
|---|
| 86 | const GameConfigT& m_GameConfig; ///< The game config this entity class is (or should be!) defined in. |
|---|
| 87 | wxString m_Name; ///< Name of this class. |
|---|
| 88 | wxString m_Description; ///< Description of this class. |
|---|
| 89 | wxColour m_Color; ///< Color of entity. |
|---|
| 90 | BoundingBox3fT m_BoundingBox; ///< Bounding box for representing entities of this class that have no other representation ("point entities"). |
|---|
| 91 | |
|---|
| 92 | bool m_Solid; ///< Tied to solids only. |
|---|
| 93 | bool m_Point; ///< Point class, not tied to solids. |
|---|
| 94 | |
|---|
| 95 | ArrayT<const EntClassVarT*> m_Variables; ///< Variables for this class. |
|---|
| 96 | ArrayT<const HelperInfoT*> m_Helpers; ///< Helpers for this class. |
|---|
| 97 | }; |
|---|
| 98 | |
|---|
| 99 | #endif |
|---|