Cafu Engine
CompGameEntity.hpp
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
6 
7 #ifndef CAFU_COMPONENT_GAME_ENTITY_HPP_INCLUDED
8 #define CAFU_COMPONENT_GAME_ENTITY_HPP_INCLUDED
9 
10 #include "GameSys/CompBase.hpp"
11 #include "GameSys/Entity.hpp" // For GetGameEnt() only.
12 
13 
14 class StaticEntityDataT;
15 
16 
17 /// This component houses the "engine-specific" parts of its entity.
18 /// It is intended for use by the implementing applications only (map compilers, engine), that is,
19 /// as the "App" component of `cf::GameSys::EntityT`s. It is not intended for use in game scripts.
20 /// As such, it doesn't integrate with the TypeSys, and thus isn't available for scripting and
21 /// whereever else we need the related meta-data.
23 {
24  public:
25 
26  /// The constructor.
28 
29  /// The copy constructor. It creates a new component as a copy of another component.
30  /// @param Comp The component to copy-construct this component from.
31  CompGameEntityT(const CompGameEntityT& Comp);
32 
33  /// The destructor.
35 
36  const StaticEntityDataT* GetStaticEntityData() const { return m_StaticEntityData; }
37  StaticEntityDataT* GetStaticEntityData() { return m_StaticEntityData; }
38 
39  // Base class overrides.
40  CompGameEntityT* Clone() const;
41  const char* GetName() const { return "GameEntity"; }
44  const cf::ClipSys::ClipModelT* GetClipModel() override { UpdateClipModel(); return m_ClipModel; }
45 
46 
47  private:
48 
49  void DoDeserialize(cf::Network::InStreamT& Stream, bool IsIniting) override;
50  void DoServerFrame(float t) override;
51  void UpdateClipModel();
52 
53  StaticEntityDataT* m_StaticEntityData;
54  const bool m_DeleteSED;
55 
56  cf::ClipSys::ClipModelT* m_ClipModel; ///< The clip model for the m_StaticEntityData->m_CollModel (the collision model made of the map primitives), NULL for none.
57  Vector3fT m_ClipPrevOrigin;
58  cf::math::QuaternionfT m_ClipPrevQuat;
59 };
60 
61 
63 {
64  return dynamic_pointer_cast<CompGameEntityT>(Entity->GetApp());
65 }
66 
67 #endif
This class implements smart (reference-counted) pointers.
Definition: Pointer.hpp:43
A clip model represents an object in the world against which clipping queries can be performed...
Definition: ClipModel.hpp:31
~CompGameEntityT()
The destructor.
Definition: CompGameEntity.cpp:52
const cf::ClipSys::ClipModelT * GetClipModel() override
This method returns the clip model of this component, if any.
Definition: CompGameEntity.hpp:44
This class represents game entities, which are the basic elements of a world.
Definition: Entity.hpp:53
IntrusivePtrT< ComponentBaseT > GetApp()
Returns the application component of this entity.
Definition: Entity.hpp:128
CompGameEntityT * Clone() const
The virtual copy constructor.
Definition: CompGameEntity.cpp:62
This class is used for reading data from a StateT instance (deserialization).
Definition: State.hpp:207
const char * GetName() const
Returns the name of this component.
Definition: CompGameEntity.hpp:41
CompGameEntityT(StaticEntityDataT *SED=NULL)
The constructor.
Definition: CompGameEntity.cpp:26
Definition: World.hpp:61
void UpdateDependencies(cf::GameSys::EntityT *Entity)
This method is called whenever something "external" to this component has changed: ...
Definition: CompGameEntity.cpp:68
This component houses the "engine-specific" parts of its entity.
Definition: CompGameEntity.hpp:22
BoundingBox3fT GetCullingBB() const
This method returns a bounding-box that encloses the visual representation of this component...
Definition: CompGameEntity.cpp:82
This class represents an axis-aligned bounding-box ("AABB") in 3-dimensional space.
Definition: BoundingBox.hpp:23
This is the base class for the components that an entity is composed/aggregated of.
Definition: CompBase.hpp:54