7 #ifndef CAFU_GAMESYS_COMPONENT_BASE_HPP_INCLUDED
8 #define CAFU_GAMESYS_COMPONENT_BASE_HPP_INCLUDED
10 #include "Variables.hpp"
11 #include "Math3D/BoundingBox.hpp"
12 #include "Templates/Pointer.hpp"
18 namespace cf {
namespace ClipSys {
class ClipModelT; } }
19 namespace cf {
namespace TypeSys {
class TypeInfoT; } }
20 namespace cf {
namespace TypeSys {
class CreateParamsT; } }
21 namespace cf {
namespace TypeSys {
class MethsDocT; } }
22 namespace cf {
namespace TypeSys {
class VarsDocT; } }
78 virtual const char*
GetName()
const {
return "Base"; }
94 template<
class T>
void SetMember(
const char* Name,
const T& Value)
139 bool CallLuaMethod(
const char* MethodName,
int NumExtraArgs,
const char* Signature=
"", ...);
197 virtual bool Render(
bool FirstPersonView,
float LodDist)
const {
return false; }
260 static int Get(lua_State* LuaState);
261 static int Set(lua_State* LuaState);
262 static int GetExtraMessage(lua_State* LuaState);
263 static int Interpolate(lua_State* LuaState);
264 static int GetEntity(lua_State* LuaState);
266 static int toString(lua_State* LuaState);
269 static const char* DocClass;
277 struct InterpolationT
286 float GetCurrentValue()
const {
return StartValue + (EndValue-StartValue)*CurrentTime/TotalTime; }
313 virtual void DoServerFrame(
float t) { }
320 virtual void DoClientFrame(
float t) { }
324 TypeSys::VarManT m_MemberVars;
virtual BoundingBox3fT GetEditorBB() const
Returns a bounding-box that the Map Editor can use to render the representation of this component's e...
Definition: CompBase.hpp:173
This class is a simple container for pointers to VarBaseTs.
Definition: Variables.hpp:326
virtual bool OnInputEvent(const CaMouseEventT &ME, float PosX, float PosY)
This method handles mouse input events.
Definition: CompBase.hpp:228
virtual unsigned int GetEditorColor() const
Returns a color that the Map Editor can use to render the representation of this component's entity...
Definition: CompBase.hpp:155
A clip model represents an object in the world against which clipping queries can be performed...
Definition: ClipModel.hpp:31
virtual bool OnInputEvent(const CaKeyboardEventT &KE)
This method handles keyboard input events.
Definition: CompBase.hpp:221
bool CallLuaMethod(const char *MethodName, int NumExtraArgs, const char *Signature="",...)
Calls the given Lua method of this component.
Definition: CompBase.cpp:133
void OnServerFrame(float t)
Advances the component one frame (one "clock-tick") on the server.
Definition: CompBase.cpp:151
TypeSys::VarManT & GetMemberVars()
Returns the variable manager that keeps generic references to our member variables, providing a simple kind of "reflection" or "type introspection" feature.
Definition: CompBase.hpp:86
void Deserialize(cf::Network::InStreamT &Stream, bool IsIniting)
Reads the state of this component from the given stream, and updates the component accordingly...
Definition: CompBase.cpp:116
void Serialize(cf::Network::OutStreamT &Stream) const
Writes the current state of this component into the given stream.
Definition: CompBase.cpp:98
This struct describes a mouse event.
Definition: OpenGLWindow.hpp:185
virtual void OnPostLoad(bool OnlyStatic)
This method is called after all entities and their components have been loaded.
Definition: CompBase.hpp:216
This class represents game entities, which are the basic elements of a world.
Definition: Entity.hpp:53
This is a "wrapper" around a normal C++ variable.
Definition: SetCompVar.hpp:15
bool InitClientApprox(const char *VarName)
Registers the member variable with the given name for interpolation over client frames in order to br...
Definition: CompBase.cpp:71
virtual void PreCache()
Initializes any resources that may be needed on the client or server ahead of time.
Definition: CompBase.hpp:190
virtual ComponentBaseT * Clone() const
The virtual copy constructor.
Definition: CompBase.cpp:50
This class is used for reading data from a StateT instance (deserialization).
Definition: State.hpp:207
EntityT * GetEntity() const
Returns the parent entity that contains this component, or NULL if this component is currently not a ...
Definition: CompBase.hpp:82
ArrayT< ApproxBaseT * > & GetInterpolators()
Returns the interpolators that have been registered with this component.
Definition: CompBase.hpp:102
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 SetMember(const char *Name, const T &Value)
Sets the member variable with the given name to the given value.
Definition: CompBase.hpp:94
virtual ~ComponentBaseT()
The virtual destructor.
Definition: CompBase.cpp:56
virtual BoundingBox3fT GetCullingBB() const
This method returns a bounding-box that encloses the visual representation of this component...
Definition: CompBase.hpp:183
ComponentBaseT()
The constructor.
Definition: CompBase.cpp:32
virtual void PostRender(bool FirstPersonView)
This method provides an opportunity for another render pass.
Definition: CompBase.hpp:200
This is the common base class for the VarT classes.
Definition: Variables.hpp:113
virtual bool Render(bool FirstPersonView, float LodDist) const
This method implements the graphical output of this component.
Definition: CompBase.hpp:197
virtual void Set(const T &v)
Sets the value of this variable to the given value v.
Definition: Variables.hpp:189
void OnClientFrame(float t)
Advances the component one frame (one "clock-tick") on the client.
Definition: CompBase.cpp:194
virtual void UpdateDependencies(EntityT *Entity)
This method is called whenever something "external" to this component has changed: ...
Definition: CompBase.cpp:145
static const luaL_Reg MethodsList[]
The list of Lua methods for this class.
Definition: CompBase.hpp:268
virtual const char * GetName() const
Returns the name of this component.
Definition: CompBase.hpp:78
virtual const cf::ClipSys::ClipModelT * GetClipModel()
This method returns the clip model of this component, if any.
Definition: CompBase.hpp:186
Definition: Renderer.hpp:16
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
A base class for objects that are reference-counted with IntrusivePtrTs.
Definition: Pointer.hpp:13
This is the base class for the components that an entity is composed/aggregated of.
Definition: CompBase.hpp:54