7 #ifndef CAFU_GAMESYS_ENTITY_HPP_INCLUDED
8 #define CAFU_GAMESYS_ENTITY_HPP_INCLUDED
10 #include "CompBasics.hpp"
11 #include "CompTransform.hpp"
13 #include "Templates/Array.hpp"
14 #include "Templates/Pointer.hpp"
23 namespace cf {
namespace TypeSys {
class TypeInfoT; } }
24 namespace cf {
namespace TypeSys {
class TypeInfoManT; } }
25 namespace cf {
namespace TypeSys {
class CreateParamsT; } }
26 namespace cf {
namespace TypeSys {
class MethsDocT; } }
33 class EntityCreateParamsT;
81 WorldT& GetWorld()
const {
return m_World; }
86 unsigned int GetID()
const {
return m_ID; }
290 bool CallLuaMethod(
const char* MethodName,
int NumExtraArgs,
const char* Signature=
"", ...);
303 static int GetID(lua_State* LuaState);
304 static int AddChild(lua_State* LuaState);
306 static int GetParent(lua_State* LuaState);
307 static int GetRoot(lua_State* LuaState);
309 static int FindByID(lua_State* LuaState);
310 static int FindByName(lua_State* LuaState);
312 static int GetBasics(lua_State* LuaState);
315 static int RmvComponent(lua_State* LuaState);
318 static int toString(lua_State* LuaState);
321 static const char* DocClass;
328 void UpdateAllDependencies();
329 void operator = (
const EntityT&);
332 const unsigned int m_ID;
bool RemoveChild(IntrusivePtrT< EntityT > Child)
Removes the given entity from the children of this entity.
Definition: Entity.cpp:167
This class implements smart (reference-counted) pointers.
Definition: Pointer.hpp:43
virtual bool OnInputEvent(const CaKeyboardEventT &KE)
Keyboard input event handler.
Definition: Entity.cpp:556
const ArrayT< IntrusivePtrT< ComponentBaseT > > & GetComponents() const
Returns the components that this entity is composed of.
Definition: Entity.hpp:148
bool AddChild(IntrusivePtrT< EntityT > Child, unsigned long Pos=0xFFFFFFFF)
Adds the given entity to the children of this entity, and sets this entity as the parent of the child...
Definition: Entity.cpp:143
Creation parameters for a game entity.
Definition: EntityCreateParams.hpp:21
void SetApp(IntrusivePtrT< ComponentBaseT > App)
Sets the application component for this entity. See GetApp() for details.
Definition: Entity.cpp:222
This struct describes a mouse event.
Definition: OpenGLWindow.hpp:185
EntityT(const EntityCreateParamsT &Params)
The normal constructor.
Definition: Entity.cpp:55
virtual ~EntityT()
The virtual destructor. Deletes this entity and all its children.
Definition: Entity.cpp:112
IntrusivePtrT< ComponentBasicsT > GetBasics() const
Returns the "Basics" component of this entity.
Definition: Entity.hpp:138
This class represents game entities, which are the basic elements of a world.
Definition: Entity.hpp:53
bool AddComponent(IntrusivePtrT< ComponentBaseT > Comp, unsigned long Index=ULONG_MAX)
Adds the given component to this entity.
Definition: Entity.cpp:283
virtual EntityT * Clone(bool Recursive=false) const
The virtual copy constructor.
Definition: Entity.cpp:106
IntrusivePtrT< ComponentBaseT > GetApp()
Returns the application component of this entity.
Definition: Entity.hpp:128
void DeleteComponent(unsigned long CompNr)
Deletes the component at the given index from this entity.
Definition: Entity.cpp:297
const ArrayT< IntrusivePtrT< EntityT > > & GetChildren() const
Returns the immediate children of this entity.
Definition: Entity.hpp:93
This class is used for reading data from a StateT instance (deserialization).
Definition: State.hpp:207
bool RenderComponents(bool FirstPersonView, float LodDist) const
Renders the components of this entity.
Definition: Entity.cpp:532
BoundingBox3fT GetCullingBB(bool WorldSpace) const
Returns a bounding-box that encloses the visual representation of this entity.
Definition: Entity.cpp:364
IntrusivePtrT< ComponentBaseT > GetComponent(const std::string &TypeName, unsigned int n=0) const
Returns the (n-th) component of the given (type) name.
Definition: Entity.cpp:234
This class manages the type infos.
Definition: TypeSys.hpp:145
IntrusivePtrT< EntityT > GetRoot()
Returns the top-most parent of this entity, that is, the root of the hierarchy that this entity is in...
Definition: Entity.cpp:211
void OnClientFrame(float t)
Advances the entity one frame (one "clock-tick") on the client.
Definition: Entity.cpp:612
unsigned int GetID() const
Returns the ID of this entity.
Definition: Entity.hpp:86
This class is used for writing data into a StateT instance (serialization).
Definition: State.hpp:81
This struct describes a keyboard event.
Definition: OpenGLWindow.hpp:20
void OnServerFrame(float t)
Advances the entity one frame (one "clock-tick") on the server.
Definition: Entity.cpp:599
IntrusivePtrT< const ComponentBaseT > GetApp() const
The const variant of the GetApp() method above. See GetApp() for details.
Definition: Entity.hpp:131
IntrusivePtrT< EntityT > FindID(unsigned int WantedID)
Finds the entity with the given ID in the hierachy tree of this entity.
Definition: Entity.cpp:309
bool CallLuaMethod(const char *MethodName, int NumExtraArgs, const char *Signature="",...)
Calls the Lua method with name MethodName of this entity.
Definition: Entity.cpp:625
This class holds the hierarchy of game entities that populate a game world.
Definition: World.hpp:39
void Deserialize(cf::Network::InStreamT &Stream, bool IsIniting)
Reads the state of this entity from the given stream, and updates the entity accordingly.
Definition: Entity.cpp:435
void GetAll(ArrayT< IntrusivePtrT< EntityT > > &List)
Traverses the hierarchy (sub-tree) that is rooted at this entity in depth-first order and records all...
Definition: Entity.cpp:202
IntrusivePtrT< EntityT > GetParent() const
Returns the parent entity of this entity.
Definition: Entity.hpp:89
void FindByComponent(const std::string &TypeName, ArrayT< IntrusivePtrT< EntityT > > &Result)
Finds all entities in the hierachy tree of this entity that have at least one component of the given ...
Definition: Entity.cpp:341
IntrusivePtrT< EntityT > Find(const std::string &WantedName)
Finds the entity with the name WantedName in the hierachy tree of this entity.
Definition: Entity.cpp:325
bool Has(IntrusivePtrT< EntityT > Ent) const
Returns whether the given entity is in the hierarchy (sub-tree) of this entity.
Definition: Entity.cpp:351
Definition: Renderer.hpp:16
void Serialize(cf::Network::OutStreamT &Stream, bool WithChildren=false) const
Writes the current state of this entity into the given stream.
Definition: Entity.cpp:403
Definition: TypeSys.hpp:52
Definition: TypeSys.hpp:57
This class keeps type information (about an entity class that occurs in the game).
Definition: TypeSys.hpp:79
IntrusivePtrT< ComponentTransformT > GetTransform() const
Returns the "Transform" component of this entity.
Definition: Entity.hpp:142
A base class for objects that are reference-counted with IntrusivePtrTs.
Definition: Pointer.hpp:13
static const luaL_Reg MethodsList[]
List of methods registered with Lua.
Definition: Entity.hpp:320