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

Public Types

enum  EventTypesT { EVENT_TYPE_PRIMARY_FIRE, EVENT_TYPE_SECONDARY_FIRE, NUM_EVENT_TYPES }
 

Public Member Functions

 EntHumanPlayerT (const EntityCreateParamsT &Params)
 
EntityStateTGetState ()
 
const EntityStateTGetState () const
 
unsigned short GetPitch () const
 
unsigned short GetBank () const
 
const btRigidBody * GetRigidBody () const
 
void AddFrag (int NumFrags=1)
 Increases the frag count of this entity by the given number. More...
 
void TakeDamage (BaseEntityT *Entity, char Amount, const VectorT &ImpactDir)
 This SERVER-SIDE function is used to have this entity take damage. More...
 
void ProcessConfigString (const void *ConfigData, const char *ConfigString)
 THIS FUNCTION IS DEPRECATED! TRY TO AVOID TO USE IT! This DEPRECATED, SERVER-SIDE function is called in order to "communicate" with this entity. More...
 
void Think (float FrameTime, unsigned long ServerFrameNr)
 This SERVER-SIDE function is called by the server in order to advance the world one clock-tick. More...
 
void ProcessEvent (unsigned int EventType, unsigned int NumEvents)
 This CLIENT-SIDE function is called to process events on the client. More...
 
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...
 
void Draw (bool FirstPersonView, float LodDist) const
 This CLIENT-SIDE function is called by the client in order to get this entity drawn. More...
 
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...
 
void getWorldTransform (btTransform &worldTrans) const
 
void setWorldTransform (const btTransform &worldTrans)
 
const cf::TypeSys::TypeInfoTGetType () const
 Returns the proper type info for this entity. More...
 
- Public Member Functions inherited from DeathMatch::BaseEntityT
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 unsigned long GetID () const
 Returns the (map unique) ID of this entity. More...
 
virtual cf::GameSys::GameWorldIGetGameWorld () const
 Returns the game world that this entity is in. More...
 
virtual const Vector3dTGetOrigin () const
 Returns the origin point of this entity. More...
 
virtual const BoundingBox3dTGetDimensions () const
 Returns the dimensions of this entity. More...
 
virtual void GetCameraOrientation (unsigned short &h, unsigned short &p, unsigned short &b) const
 Returns the camera orientation angles 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...
 
unsigned short GetHeading () const
 Returns the heading of this entity. More...
 
float GetProp (const std::string &Key, float Default=0.0f) const
 
double GetProp (const std::string &Key, double Default=0.0) const
 
int GetProp (const std::string &Key, int Default=0) const
 
std::string GetProp (const std::string &Key, std::string Default="") const
 
Vector3fT GetProp (const std::string &Key, Vector3fT Default=Vector3fT()) const
 
Vector3dT GetProp (const std::string &Key, Vector3dT Default=Vector3dT()) const
 
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 OnPush (ArrayT< BaseEntityT * > &Pushers, const Vector3dT &PushVector)
 This SERVER-SIDE method is called whenever another entity pushes us. More...
 
void PostEvent (unsigned int EventType)
 This SERVER-SIDE function is used for posting an event of the given type. 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...
 
- 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 Public Member Functions inherited from DeathMatch::BaseEntityT
static void * CreateInstance (const cf::TypeSys::CreateParamsT &Params)
 
static int GetName (lua_State *L)
 
static int GetOrigin (lua_State *L)
 
static int SetOrigin (lua_State *L)
 

Static Public Attributes

static const cf::TypeSys::TypeInfoT TypeInfo
 
- Static Public Attributes inherited from DeathMatch::BaseEntityT
static const cf::TypeSys::TypeInfoT TypeInfo
 The type info object for (objects/instances of) this class. More...
 

Additional Inherited Members

- Public Attributes inherited from DeathMatch::BaseEntityT
const unsigned long ID
 
const std::map< std::string,
std::string > 
Properties
 The properties of this entities from the map file. More...
 
unsigned long ParentID
 
IntrusivePtrT
< cf::GameSys::EntityT
m_Entity
 The associated entity in the cf::GameSys::WorldT. More...
 
cf::GameSys::GameWorldIGameWorld
 Pointer to the game world implementation. More...
 
const
cf::ClipSys::CollisionModelT
CollisionModel
 The collision model of this entity, NULL for none. More...
 
cf::ClipSys::ClipModelT ClipModel
 The clip model of this entity. Note that clip models can take NULL collision model pointers, so that the ClipModel instance is always non-NULL and available. More...
 
- Protected Member Functions inherited from DeathMatch::BaseEntityT
 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 inherited from DeathMatch::BaseEntityT
Vector3dT m_Origin
 World coordinate of (the eye of) this entity. More...
 
BoundingBox3dT m_Dimensions
 The bounding box of this entity (relative to the origin). More...
 
unsigned short m_Heading
 Heading (north is along the ??-axis). More...
 
unsigned short m_Pitch
 Pitch (for looking up/down). More...
 
unsigned short m_Bank
 Bank (e.g. used when dead and lying on the side). More...
 

Member Function Documentation

void EntHumanPlayerT::AddFrag ( int  NumFrags = 1)

Increases the frag count of this entity by the given number.

void EntHumanPlayerT::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.

Reimplemented from DeathMatch::BaseEntityT.

bool EntHumanPlayerT::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().)

Reimplemented from DeathMatch::BaseEntityT.

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

Returns the proper type info for this entity.

Reimplemented from DeathMatch::BaseEntityT.

void EntHumanPlayerT::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.

Reimplemented from DeathMatch::BaseEntityT.

void EntHumanPlayerT::ProcessConfigString ( const void *  ConfigData,
const char *  ConfigString 
)
virtual

THIS FUNCTION IS DEPRECATED! TRY TO AVOID TO USE IT! This DEPRECATED, SERVER-SIDE function is called in order to "communicate" with this entity.

It is probably a (bad) replacement for additional, missing member functions, so don't use it! Mostly used for setting/querying the properties of specific, concrete entities, e.g. the player names, player model names, player commands, or if something is solid, alive or was picked up (and is thus "invisible" for a while), and so on. This should most certainly be resolved as soon as possible, requires careful design considerations, however. At a first glance, the related methods are only called from the server (like passing in player commands), or from within the Think() functions, but never on the client side.

Reimplemented from DeathMatch::BaseEntityT.

void EntHumanPlayerT::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()" ??

Reimplemented from DeathMatch::BaseEntityT.

void EntHumanPlayerT::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.)

Reimplemented from DeathMatch::BaseEntityT.

void EntHumanPlayerT::Think ( float  FrameTime,
unsigned long  ServerFrameNr 
)
virtual

This SERVER-SIDE function is called by the server in order to advance the world one clock-tick.

That is, basing on the present (old) state, it is called for computing the next (new) state. 'FrameTime' is the time of the clock-tick, in seconds. 'ServerFrameNr' is the number of the current server frame.

IMPORTANT NOTE: In truth, also the CLIENT-SIDE calls this function for the purpose of predicting the local human player entity! <<< As a consequence, special rules apply when this function is called for predicted entities (that is, human player entities). <<< For further details and examples, please refer to the EntHumanPlayerT::Think() function in HumanPlayer.cpp. <<<

Reimplemented from DeathMatch::BaseEntityT.


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