]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - include/ientity.h
fixed blended-decal rendering in textured mode
[xonotic/netradiant.git] / include / ientity.h
1 /*
2 Copyright (C) 2001-2006, William Joseph.
3 All Rights Reserved.
4
5 This file is part of GtkRadiant.
6
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20 */
21
22 #if !defined(INCLUDED_IENTITY_H)
23 #define INCLUDED_IENTITY_H
24
25 #include "generic/constant.h"
26
27 #include "string/string.h"
28 #include "scenelib.h"
29
30 class EntityClass;
31
32 class Entity
33 {
34 public:
35   STRING_CONSTANT(Name, "Entity");
36
37   class Visitor
38   {
39   public:
40     virtual void visit(const char* key, const char* value) = 0;
41   };
42
43   virtual const EntityClass& getEntityClass() const = 0;
44   virtual void forEachKeyValue(Visitor& visitor) const = 0;
45   virtual void setKeyValue(const char* key, const char* value) = 0;
46   virtual const char* getKeyValue(const char* key) const = 0;
47   virtual bool isContainer() const = 0;
48 };
49
50 class EntityCopyingVisitor : public Entity::Visitor
51 {
52   Entity& m_entity;
53 public:
54   EntityCopyingVisitor(Entity& entity)
55     : m_entity(entity)
56   {
57   }
58
59   void visit(const char* key, const char* value)
60   {
61     if(!string_equal(key, "classname"))
62     {
63       m_entity.setKeyValue(key, value);
64     }
65   }
66 };
67
68 inline Entity* Node_getEntity(scene::Node& node)
69 {
70   return NodeTypeCast<Entity>::cast(node);
71 }
72
73
74 template<typename value_type>
75 class Stack;
76 template<typename Contained>
77 class Reference;
78
79 namespace scene
80 {
81   class Node;
82 }
83
84 typedef Reference<scene::Node> NodeReference;
85
86 namespace scene
87 {
88   typedef Stack<NodeReference> Path;
89 }
90
91 class Counter;
92
93 class EntityCreator
94 {
95 public:
96   INTEGER_CONSTANT(Version, 2);
97   STRING_CONSTANT(Name, "entity");
98
99   virtual scene::Node& createEntity(EntityClass* eclass) = 0;
100
101   typedef void (*KeyValueChangedFunc)();
102   virtual void setKeyValueChangedFunc(KeyValueChangedFunc func) = 0;
103
104   virtual void setCounter(Counter* counter) = 0;
105
106   virtual void connectEntities(const scene::Path& e1, const scene::Path& e2) = 0;
107
108   virtual void setLightRadii(bool lightRadii) = 0;
109   virtual bool getLightRadii() = 0;
110   virtual void setShowNames(bool showNames) = 0;
111   virtual bool getShowNames() = 0;
112   virtual void setShowAngles(bool showAngles) = 0;
113   virtual bool getShowAngles() = 0;
114
115   virtual void printStatistics() const = 0;
116 };
117
118 #include "modulesystem.h"
119
120 template<typename Type>
121 class GlobalModule;
122 typedef GlobalModule<EntityCreator> GlobalEntityModule;
123
124 template<typename Type>
125 class GlobalModuleRef;
126 typedef GlobalModuleRef<EntityCreator> GlobalEntityModuleRef;
127
128 inline EntityCreator& GlobalEntityCreator()
129 {
130   return GlobalEntityModule::getTable();
131 }
132
133 #endif