root/cafu/trunk/CaWE/EntityClass.hpp

Revision 457, 4.4 KB (checked in by Carsten, 4 months ago)

Using UltraEdit's multi-line search-and-replace-in-files feature, replaced


^#ifndef _(CAFU|CF|CFS|CA)_(.*)_$
^#define _\1_\2_$

with

#ifndef CAFU_\2_INCLUDED
#define CAFU_\2_INCLUDED

and


^#ifndef _(.*)_HPP_$
^#define _\1_HPP_$

with

#ifndef CAFU_\1_HPP_INCLUDED
#define CAFU_\1_HPP_INCLUDED

Closes #91.

Line 
1/*
2=================================================================================
3This file is part of Cafu, the open-source game engine and graphics engine
4for multiplayer, cross-platform, real-time 3D action.
5Copyright (C) 2002-2012 Carsten Fuchs Software.
6
7Cafu is free software: you can redistribute it and/or modify it under the terms
8of the GNU General Public License as published by the Free Software Foundation,
9either version 3 of the License, or (at your option) any later version.
10
11Cafu is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13PURPOSE. See the GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with Cafu. If not, see <http://www.gnu.org/licenses/>.
17
18For 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
30class EntClassVarT;
31class GameConfigT;
32struct lua_State;
33
34
35class HelperInfoT
36{
37    public:
38
39    wxString         Name;
40    ArrayT<wxString> Parameters;
41};
42
43
44class 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
Note: See TracBrowser for help on using the browser.