Cafu Engine
DeathMatch::BaseEntityT Class Reference
Inheritance diagram for DeathMatch::BaseEntityT:

Public Member Functions

virtual ~BaseEntityT ()
 The destructor. More...
 
void Serialize (cf::Network::OutStreamT &Stream) const
 The implementation calls DoSerialize(), that derived classes override to add their own data. More...
 
void Deserialize (cf::Network::InStreamT &Stream, bool IsIniting)
 The implementation calls DoDeserialize(), that derived classes override to read their own data. More...
 
virtual void NotifyLeaveMap ()
 Let the entity know that it is about to be removed from the map. More...
 
virtual const BoundingBox3dTGetDimensions () const
 Returns the dimensions of this entity. More...
 
virtual void GetBodyOrientation (unsigned short &h, unsigned short &p, unsigned short &b) const
 Returns the orientation angles of the entity itself. More...
 
virtual void NotifyTouchedBy (BaseEntityT *Entity)
 This SERVER-SIDE function is used to notify this entity that it was touched by another entity. More...
 
virtual void OnTrigger (BaseEntityT *Activator)
 This SERVER-SIDE method is called whenever another entity walked into one of our trigger volumes (trigger brushes). More...
 
virtual void TakeDamage (BaseEntityT *Entity, char Amount, const VectorT &ImpactDir)
 This SERVER-SIDE function is used to have this entity take damage. More...
 
void PostEvent (unsigned int EventType)
 This SERVER-SIDE function is used for posting an event of the given type. More...
 
virtual void ProcessEvent (unsigned int EventType, unsigned int NumEvents)
 This CLIENT-SIDE function is called to process events on the client. More...
 
virtual bool GetLightSourceInfo (unsigned long &DiffuseColor, unsigned long &SpecularColor, VectorT &Position, float &Radius, bool &CastsShadows) const
 This CLIENT-SIDE function is called in order to retrieve light source information about this entity. More...
 
virtual void Draw (bool FirstPersonView, float LodDist) const
 This CLIENT-SIDE function is called by the client in order to get this entity drawn. More...
 
virtual void Interpolate (float FrameTime)
 This CLIENT-SIDE function is called by the client in order to advance all values of this entity that have been registered for interpolation. More...
 
virtual void PostDraw (float FrameTime, bool FirstPersonView)
 This CLIENT-SIDE function is called once per frame, for each entity, after the regular rendering (calls to 'Draw()') is completed, in order to provide entities an opportunity to render the HUD, employ simple "mini-prediction", triggers sounds, register particles, do other server-independent eye-candy, and so on. More...
 
virtual const
cf::TypeSys::TypeInfoT
GetType () const
 Returns the proper type info for this entity. More...
 
- Public Member Functions inherited from GameEntityI
virtual ~GameEntityI ()
 The virtual destructor. More...
 
- Public Member Functions inherited from RefCountedT
unsigned int GetRefCount () const
 

Static Public Member Functions

static void * CreateInstance (const cf::TypeSys::CreateParamsT &Params)
 
static int GetName (lua_State *L)
 

Public Attributes

const std::map< std::string,
std::string > 
Properties
 The properties of this entities from the map file. More...
 
IntrusivePtrT
< cf::GameSys::EntityT
m_Entity
 The associated entity in the cf::GameSys::WorldT. More...
 

Static Public Attributes

static const cf::TypeSys::TypeInfoT TypeInfo
 The type info object for (objects/instances of) this class. More...
 

Protected Member Functions

 BaseEntityT (const EntityCreateParamsT &Params, const BoundingBox3dT &Dimensions, const unsigned int NUM_EVENT_TYPES)
 Protected constructor such that only concrete entities can call this for creating a BaseEntityT, but nobody else. More...
 
void Register (ApproxBaseT *Interp)
 Concrete entities call this method in their constructors in order to have us automatically interpolate the value that has been specified with the Interp instance. More...
 
- Protected Member Functions inherited from RefCountedT
 RefCountedT (const RefCountedT &)
 
RefCountedToperator= (const RefCountedT &)
 

Protected Attributes

BoundingBox3dT m_Dimensions
 The bounding box of this entity (relative to the origin). More...
 

Constructor & Destructor Documentation

BaseEntityT::~BaseEntityT ( )
virtual

The destructor.

BaseEntityT::BaseEntityT ( const EntityCreateParamsT Params,
const BoundingBox3dT Dimensions,
const unsigned int  NUM_EVENT_TYPES 
)
protected

Protected constructor such that only concrete entities can call this for creating a BaseEntityT, but nobody else.

Concrete entities are created in the GameI::CreateGameEntity() method for both the server- and client-side.

Member Function Documentation

void BaseEntityT::Deserialize ( cf::Network::InStreamT Stream,
bool  IsIniting 
)
virtual

The implementation calls DoDeserialize(), that derived classes override to read their own data.

It also calls ProcessEvent() (overridden by derived classes) for any received events.

Implements GameEntityI.

void BaseEntityT::Draw ( bool  FirstPersonView,
float  LodDist 
) const
virtual

This CLIENT-SIDE function is called by the client in order to get this entity drawn.

Note that it is usually called several times per frame, in order to gather the individual terms of the lighting equation: there is a call for the ambient contribution (everything that is independent of a lightsource) and for each light source there is a call for the shadows, followed by another call for adding the lightsource-dependent contribution (diffuse and specular terms etc.).

Also note that the calling code has properly set up the Cafu Material Systems global lighting parameters before calling. That is, the ambient light color, light source position (in model space), radius, diff+spec color and the eye position (in model space) are set. However, normally only those parameters that are relevant for the current Material Systems rendering action are set: In the AMBIENT rendering action, only the ambient colors are set, in the STENCILSHADOW action only the light source position may be set, and in the LIGHTING action all parameters except for the ambient light color are set.

Parameters
FirstPersonViewis true when the engine has rendered the world from this entities viewpoint, e.g. because this is the local players entity.
LodDistis the world-space distance of the entity to the viewer, supposed to be used for level-of-detail reductions.

Implements GameEntityI.

virtual void DeathMatch::BaseEntityT::GetBodyOrientation ( unsigned short &  h,
unsigned short &  p,
unsigned short &  b 
) const
inlinevirtual

Returns the orientation angles of the entity itself.

Used for computing the light source and eye positions in entity (model) space. TODO: Both the signature as well as the implementation of this method are temporary, and fully expected to change later.

Implements GameEntityI.

virtual const BoundingBox3dT& DeathMatch::BaseEntityT::GetDimensions ( ) const
inlinevirtual

Returns the dimensions of this entity.

Implements GameEntityI.

bool BaseEntityT::GetLightSourceInfo ( unsigned long &  DiffuseColor,
unsigned long &  SpecularColor,
VectorT Position,
float &  Radius,
bool &  CastsShadows 
) const
virtual

This CLIENT-SIDE function is called in order to retrieve light source information about this entity.

Returns 'true' if this entity is a light source and 'DiffuseColor', 'SpecularColor', 'Position' (in world space!), 'Radius' and 'CastsShadows' have been set. Returns 'false' if this entity is no light source. (In theory, this function might also be called on server-side, from within Think().)

Implements GameEntityI.

const cf::TypeSys::TypeInfoT * BaseEntityT::GetType ( ) const
virtual

Returns the proper type info for this entity.

Implements GameEntityI.

Reimplemented in DeathMatch::EntInfoGenericT.

void BaseEntityT::Interpolate ( float  FrameTime)
virtual

This CLIENT-SIDE function is called by the client in order to advance all values of this entity that have been registered for interpolation.

Each concrete entity class determines itself which values are interpolated (e.g. the m_Origin) by calling Register() in its constructor: see Register() for details. Interpolation is used to "smooth" values in the client video frames between server updates.

Implements GameEntityI.

virtual void DeathMatch::BaseEntityT::NotifyLeaveMap ( )
inlinevirtual

Let the entity know that it is about to be removed from the map.

At this time, the only purpose of this method is to give the entity a chance to break cycles of IntrusivePtrT<> to itself that would otherwise prevent it from being destructed.

Implements GameEntityI.

void BaseEntityT::NotifyTouchedBy ( BaseEntityT Entity)
virtual

This SERVER-SIDE function is used to notify this entity that it was touched by another entity.

'Entity' is the entity that touches this one, and is usually the entity from which the call is made. Calls are only made from within other entities 'Think()' functions. (Unfortunately, this function cannot be declared as "protected": see "C++ FAQs, 2nd edition" by Cline, Lomow, Girou, pages 249f.)

void BaseEntityT::OnTrigger ( BaseEntityT Activator)
virtual

This SERVER-SIDE method is called whenever another entity walked into one of our trigger volumes (trigger brushes).

It is called once per frame as long as the other entity stays within our trigger volume.

Parameters
ActivatorThe entity that walked into our trigger volume and thus caused the call of this method.

Note that most entity classes just do nothing in their implementation of this method, usually because they never have trigger brushes anyway. Entity classes that are very likely to provide an implementation though are EntTriggerT (of course!) and the items like weapons, so they can e.g. detect being picked up. Calls to this method normally come from within the Activator->Think() method, because it are the activators themselves that detect that they entered a trigger volume (it are not the entities with the triggers that detect that something entered their volume). (Unfortunately, this function cannot be declared as "protected": see "C++ FAQs, 2nd edition" by Cline, Lomow, Girou, pages 249f.)

void BaseEntityT::PostDraw ( float  FrameTime,
bool  FirstPersonView 
)
virtual

This CLIENT-SIDE function is called once per frame, for each entity, after the regular rendering (calls to 'Draw()') is completed, in order to provide entities an opportunity to render the HUD, employ simple "mini-prediction", triggers sounds, register particles, do other server-independent eye-candy, and so on.

Parameters
FrameTimeis the time in seconds that it took to render the last (previous) frame.
FirstPersonViewis true when the engine has rendered the world from this entities viewpoint, e.g. because this is the local players entity.

As it is convenient for current code (dealing with the particle system...), it is guaranteed that there is exactly one call to this function with 'FirstPersonView==true', which occurs after the appropriate calls for all other entities. This behaviour may change in the future.

Implements GameEntityI.

void DeathMatch::BaseEntityT::PostEvent ( unsigned int  EventType)
inline

This SERVER-SIDE function is used for posting an event of the given type.

The event is automatically sent from the entity instance on the server to the entity instances on the clients, and causes a matching call to ProcessEvent() there. The meaning of the event type is specific to the concrete entity class. Note that events are fully predictable: they work well even in the presence of client prediction.

void BaseEntityT::ProcessEvent ( unsigned int  EventType,
unsigned int  NumEvents 
)
virtual

This CLIENT-SIDE function is called to process events on the client.

Events that have been posted via PostEvent() on the server (or in client prediction) are eventually received in Deserialize(), which automatically calls this method. In the call, Deserialize() indicates the number of new events since the last call (at least one, or it wouldn't call ProcessEvent() at all). This way, each event can be processed exactly once.

TODO: Move into private section below "DoDeserialize()" ??

void BaseEntityT::Register ( ApproxBaseT Interp)
protected

Concrete entities call this method in their constructors in order to have us automatically interpolate the value that has been specified with the Interp instance.

Interpolation occurs on the client only: it is advanced in the video frames between server updates. Each update received from the server (applied in DoDeserialize()) automatically updates the reference value for the interpolation in the next video frames.

void BaseEntityT::Serialize ( cf::Network::OutStreamT Stream) const
virtual

The implementation calls DoSerialize(), that derived classes override to add their own data.

Implements GameEntityI.

void BaseEntityT::TakeDamage ( BaseEntityT Entity,
char  Amount,
const VectorT ImpactDir 
)
virtual

This SERVER-SIDE function is used to have this entity take damage.

'Entity' is the entitiy that causes the damage (i.e., who fired a shot). It is usually the entity from which the call is made. 'Amount' is the amount of damage that was caused, and is usually subtracted from this entitys health. 'ImpactDir' is the direction from which we were hit. Calls are only made from within other entities 'Think()' functions. (Unfortunately, this function cannot be declared as "protected": see "C++ FAQs, 2nd edition" by Cline, Lomow, Girou, pages 249f.)

Member Data Documentation

BoundingBox3dT DeathMatch::BaseEntityT::m_Dimensions
protected

The bounding box of this entity (relative to the origin).

IntrusivePtrT<cf::GameSys::EntityT> DeathMatch::BaseEntityT::m_Entity

The associated entity in the cf::GameSys::WorldT.

const std::map<std::string, std::string> DeathMatch::BaseEntityT::Properties

The properties of this entities from the map file.

const cf::TypeSys::TypeInfoT BaseEntityT::TypeInfo
static

The type info object for (objects/instances of) this class.


The documentation for this class was generated from the following files: