Fix issue in Rocket.lua script.
[Cafu-Engine.git] / Common / CompGameEntity.hpp
blob06268c6b02601c03655b704e50affa7554c449f1
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 */
7 #ifndef CAFU_COMPONENT_GAME_ENTITY_HPP_INCLUDED
8 #define CAFU_COMPONENT_GAME_ENTITY_HPP_INCLUDED
10 #include "GameSys/CompBase.hpp"
11 #include "GameSys/Entity.hpp" // For GetGameEnt() only.
14 class StaticEntityDataT;
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.
22 class CompGameEntityT : public cf::GameSys::ComponentBaseT
24 public:
26 /// The constructor.
27 CompGameEntityT(StaticEntityDataT* SED = NULL);
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);
33 /// The destructor.
34 ~CompGameEntityT();
36 const StaticEntityDataT* GetStaticEntityData() const { return m_StaticEntityData; }
37 StaticEntityDataT* GetStaticEntityData() { return m_StaticEntityData; }
39 // Base class overrides.
40 CompGameEntityT* Clone() const;
41 const char* GetName() const { return "GameEntity"; }
42 void UpdateDependencies(cf::GameSys::EntityT* Entity);
43 BoundingBox3fT GetCullingBB() const;
44 const cf::ClipSys::ClipModelT* GetClipModel() override { UpdateClipModel(); return m_ClipModel; }
47 private:
49 void DoDeserialize(cf::Network::InStreamT& Stream, bool IsIniting) override;
50 void DoServerFrame(float t) override;
51 void UpdateClipModel();
53 StaticEntityDataT* m_StaticEntityData;
54 const bool m_DeleteSED;
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;
62 inline IntrusivePtrT<CompGameEntityT> GetGameEnt(IntrusivePtrT<cf::GameSys::EntityT> Entity)
64 return dynamic_pointer_cast<CompGameEntityT>(Entity->GetApp());
67 #endif