Entities with this component are associated with a client connection at whose ends is a human player who provides input to control the entity. More...
#include "CompHumanPlayer.hpp"
Public Member Functions | |
ComponentHumanPlayerT () | |
The constructor. More... | |
ComponentHumanPlayerT (const ComponentHumanPlayerT &Comp) | |
The copy constructor. More... | |
~ComponentHumanPlayerT () | |
The destructor. More... | |
ArrayT< PlayerCommandT > & | GetPlayerCommands () |
A temporary method for compatibility with old code. More... | |
Vector3dT | GetPlayerVelocity () const |
Returns the player's current velocity (as learned from its PlayerPhysics component). More... | |
Vector3dT | GetCameraOriginWS () const |
Returns the origin of the entity's camera, in world-space. More... | |
Vector3dT | GetCameraViewDirWS (double Random=0.0) const |
Returns the view (forward) vector of the entity's camera, in world space, optionally deviated by some random amount. More... | |
bool | TraceCameraRay (const Vector3dT &Dir, Vector3dT &HitPoint, ComponentBaseT *&HitComp) const |
Traces a ray that originates at the player camera's origin in the given direction through the world. More... | |
void | CheckGUIs (bool ThinkingOnServerSide, bool HaveButtonClick) const |
A helper function for Think(). More... | |
void | Think (const PlayerCommandT &PlayerCommand, bool ThinkingOnServerSide) |
A helper method (that does the actual work) for DoServerFrame() and the (re-)prediction in the client. More... | |
IntrusivePtrT < ComponentCarriedWeaponT > | GetActiveWeapon () const |
Returns the ComponentCarriedWeaponT component of the currently active weapon, or NULL if currently no weapon is active. More... | |
void | SelectWeapon (uint8_t NextWeaponNr, bool Force=false) |
This method initiates the holstering of the currently active weapon and the subsequent drawing of the given weapon. More... | |
void | SelectNextWeapon () |
This method draws the next weapon as previously prepared by SelectWeapon(). More... | |
unsigned int | GetRandom (unsigned int n) |
Returns a pseudo-random integer in range `0 ... More... | |
double | GetRandom () |
Returns a pseudo-random double in range [0.0, 1.0] (inclusive). More... | |
ComponentHumanPlayerT * | Clone () const override |
The virtual copy constructor. More... | |
const char * | GetName () const override |
Returns the name of this component. More... | |
BoundingBox3fT | GetCullingBB () const override |
This method returns a bounding-box that encloses the visual representation of this component. More... | |
void | PostRender (bool FirstPersonView) override |
This method provides an opportunity for another render pass. More... | |
void | DoServerFrame (float t) override |
Derived classes override this method in order to implement the real work proposed by OnServerFrame(), which explicitly calls this method for this purpose. More... | |
void | DoClientFrame (float t) override |
Derived classes override this method in order to implement the real work proposed by OnClientFrame(), which explicitly calls this method for this purpose. More... | |
const cf::TypeSys::TypeInfoT * | GetType () const override |
Public Member Functions inherited from cf::GameSys::ComponentBaseT | |
ComponentBaseT () | |
The constructor. More... | |
ComponentBaseT (const ComponentBaseT &Comp) | |
The copy constructor. More... | |
virtual | ~ComponentBaseT () |
The virtual destructor. More... | |
EntityT * | GetEntity () const |
Returns the parent entity that contains this component, or NULL if this component is currently not a part of any entity. More... | |
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. More... | |
template<class T > | |
void | SetMember (const char *Name, const T &Value) |
Sets the member variable with the given name to the given value. More... | |
ArrayT< ApproxBaseT * > & | GetInterpolators () |
Returns the interpolators that have been registered with this component. More... | |
bool | InitClientApprox (const char *VarName) |
Registers the member variable with the given name for interpolation over client frames in order to bridge the larger intervals between server frames. More... | |
void | Serialize (cf::Network::OutStreamT &Stream) const |
Writes the current state of this component into the given stream. More... | |
void | Deserialize (cf::Network::InStreamT &Stream, bool IsIniting) |
Reads the state of this component from the given stream, and updates the component accordingly. More... | |
bool | CallLuaMethod (const char *MethodName, int NumExtraArgs, const char *Signature="",...) |
Calls the given Lua method of this component. More... | |
virtual void | UpdateDependencies (EntityT *Entity) |
This method is called whenever something "external" to this component has changed: More... | |
virtual unsigned int | GetEditorColor () const |
Returns a color that the Map Editor can use to render the representation of this component's entity. More... | |
virtual BoundingBox3fT | GetEditorBB () const |
Returns a bounding-box that the Map Editor can use to render the representation of this component's entity and for related hit tests in the 2D and 3D views after mouse clicks. More... | |
virtual const cf::ClipSys::ClipModelT * | GetClipModel () |
This method returns the clip model of this component, if any. More... | |
virtual void | PreCache () |
Initializes any resources that may be needed on the client or server ahead of time. More... | |
virtual bool | Render (bool FirstPersonView, float LodDist) const |
This method implements the graphical output of this component. More... | |
virtual void | OnPostLoad (bool OnlyStatic) |
This method is called after all entities and their components have been loaded. More... | |
virtual bool | OnInputEvent (const CaKeyboardEventT &KE) |
This method handles keyboard input events. More... | |
virtual bool | OnInputEvent (const CaMouseEventT &ME, float PosX, float PosY) |
This method handles mouse input events. More... | |
void | OnServerFrame (float t) |
Advances the component one frame (one "clock-tick") on the server. More... | |
void | OnClientFrame (float t) |
Advances the component one frame (one "clock-tick") on the client. 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 cf::GameSys::ComponentBaseT | |
static void * | CreateInstance (const cf::TypeSys::CreateParamsT &Params) |
Static Public Attributes | |
static const cf::TypeSys::TypeInfoT | TypeInfo |
Static Public Attributes inherited from cf::GameSys::ComponentBaseT | |
static const cf::TypeSys::TypeInfoT | TypeInfo |
Static Protected Member Functions | |
static int | GetActiveWeapon (lua_State *LuaState) |
static int | SelectWeapon (lua_State *LuaState) |
static int | SelectNextWeapon (lua_State *LuaState) |
static int | FireRay (lua_State *LuaState) |
static int | GetRandom (lua_State *LuaState) |
static int | SpawnWeaponChild (lua_State *LuaState) |
static int | RegisterParticle (lua_State *LuaState) |
static int | toString (lua_State *LuaState) |
Static Protected Member Functions inherited from cf::GameSys::ComponentBaseT | |
static int | Get (lua_State *LuaState) |
static int | Set (lua_State *LuaState) |
static int | GetExtraMessage (lua_State *LuaState) |
static int | Interpolate (lua_State *LuaState) |
static int | GetEntity (lua_State *LuaState) |
static int | InitClientApprox (lua_State *LuaState) |
static int | toString (lua_State *LuaState) |
Static Protected Attributes | |
static const luaL_Reg | MethodsList [] |
The list of Lua methods for this class. More... | |
static const char * | DocClass |
static const cf::TypeSys::MethsDocT | DocMethods [] |
static const cf::TypeSys::VarsDocT | DocVars [] |
Static Protected Attributes inherited from cf::GameSys::ComponentBaseT | |
static const luaL_Reg | MethodsList [] |
The list of Lua methods for this class. More... | |
static const char * | DocClass |
static const cf::TypeSys::MethsDocT | DocMethods [] |
static const cf::TypeSys::MethsDocT | DocCallbacks [] |
Additional Inherited Members | |
Protected Member Functions inherited from RefCountedT | |
RefCountedT (const RefCountedT &) | |
RefCountedT & | operator= (const RefCountedT &) |
Entities with this component are associated with a client connection at whose ends is a human player who provides input to control the entity.
ComponentHumanPlayerT::ComponentHumanPlayerT | ( | ) |
The constructor.
ComponentHumanPlayerT::ComponentHumanPlayerT | ( | const ComponentHumanPlayerT & | Comp | ) |
The copy constructor.
Comp | The component to create a copy of. |
ComponentHumanPlayerT::~ComponentHumanPlayerT | ( | ) |
The destructor.
void ComponentHumanPlayerT::CheckGUIs | ( | bool | ThinkingOnServerSide, |
bool | HaveButtonClick | ||
) | const |
A helper function for Think().
|
overridevirtual |
The virtual copy constructor.
Callers can use this method to create a copy of this component without knowing its concrete type. Overrides in derived classes use a covariant return type to facilitate use when the concrete type is known. The newly cloned component is initially not a part of any entity, even if the source component was.
Reimplemented from cf::GameSys::ComponentBaseT.
|
overridevirtual |
Derived classes override this method in order to implement the real work proposed by OnClientFrame(), which explicitly calls this method for this purpose.
(This follows the "Non-Virtual Interface Idiom" as described by Scott Meyers in "Effective C++, 3rd Edition", item 35 ("Consider alternatives to virtual functions.").)
Reimplemented from cf::GameSys::ComponentBaseT.
|
overridevirtual |
Derived classes override this method in order to implement the real work proposed by OnServerFrame(), which explicitly calls this method for this purpose.
(This follows the "Non-Virtual Interface Idiom" as described by Scott Meyers in "Effective C++, 3rd Edition", item 35 ("Consider alternatives to virtual functions.").)
Reimplemented from cf::GameSys::ComponentBaseT.
IntrusivePtrT< ComponentCarriedWeaponT > ComponentHumanPlayerT::GetActiveWeapon | ( | ) | const |
Returns the ComponentCarriedWeaponT component of the currently active weapon, or NULL if currently no weapon is active.
Vector3dT ComponentHumanPlayerT::GetCameraOriginWS | ( | ) | const |
Returns the origin of the entity's camera, in world-space.
Vector3dT ComponentHumanPlayerT::GetCameraViewDirWS | ( | double | Random = 0.0 | ) | const |
Returns the view (forward) vector of the entity's camera, in world space, optionally deviated by some random amount.
|
overridevirtual |
This method returns a bounding-box that encloses the visual representation of this component.
It is used to determine if the entity is in the view-frustum of a camera, how large a region must be updated in the 2D views of a Map Editor, if the entity is in the potentially-visibility-set (PVS) of another entity, and similar purposes.
The returned bounding-box is in local space, i.e. typically centered around the origin (0, 0, 0). If the component doesn't have a visual representation, the returned bounding-box may be uninitialized (!IsInited()
). Also see EntityT::GetCullingBB() for additional details.
Reimplemented from cf::GameSys::ComponentBaseT.
|
inlineoverridevirtual |
Returns the name of this component.
Reimplemented from cf::GameSys::ComponentBaseT.
|
inline |
A temporary method for compatibility with old code.
Vector3dT ComponentHumanPlayerT::GetPlayerVelocity | ( | ) | const |
Returns the player's current velocity (as learned from its PlayerPhysics component).
unsigned int ComponentHumanPlayerT::GetRandom | ( | unsigned int | n | ) |
Returns a pseudo-random integer in range `0 ...
n-1`.
The important aspect of this method is that it returns pseudo-random numbers that are reproducible in the context of the "client prediction" feature of the Cafu Engine. All random numbers that are used in human player code must be obtained from one of the GetRandom() methods in this class.
double ComponentHumanPlayerT::GetRandom | ( | ) |
Returns a pseudo-random double in range [0.0, 1.0]
(inclusive).
The important aspect of this method is that it returns pseudo-random numbers that are reproducible in the context of the "client prediction" feature of the Cafu Engine. All random numbers that are used in human player code must be obtained from one of the GetRandom() methods in this class.
|
overridevirtual |
This method provides an opportunity for another render pass.
Reimplemented from cf::GameSys::ComponentBaseT.
void ComponentHumanPlayerT::SelectNextWeapon | ( | ) |
This method draws the next weapon as previously prepared by SelectWeapon().
It is intended to be called at the end of the holstering sequence of the previous weapon, either directly from SelectWeapon() when it found that holstering can entirely be skipped, or indirectly when SelectWeapon() calls the previous weapon's Holster()
callback, the end of the holster sequence is detected in the OnSequenceWrap_Sv()
script callback, and its implementation in turn calls this method.
void ComponentHumanPlayerT::SelectWeapon | ( | uint8_t | NextWeaponNr, |
bool | Force = false |
||
) |
This method initiates the holstering of the currently active weapon and the subsequent drawing of the given weapon.
If the current weapon is none, unknown or not available to the player (e.g. because it has never been picked up), or if it turns out that the weapon does not support holstering (e.g. because there is no holstering sequence available), the holstering is skipped and the next weapon is drawn immediately. If the current weapon is fine but is not idle at the time that this method is called (e.g. reloading or firing), the call is ignored, that is, the weapon is not changed.
NextWeaponNr | The index number into the CarriedWeapon components of this entity, starting at 1. Use 0 to select "no" weapon. |
Force | If true , forces the drawing of the next weapon immediately, ignoring the idle state and holstering sequence of the current weapon. This is normally only used if, for example, the last hand grenade has been thrown and bare-handed animation sequences for idle and holster are not available. |
void ComponentHumanPlayerT::Think | ( | const PlayerCommandT & | PlayerCommand, |
bool | ThinkingOnServerSide | ||
) |
A helper method (that does the actual work) for DoServerFrame() and the (re-)prediction in the client.
bool ComponentHumanPlayerT::TraceCameraRay | ( | const Vector3dT & | Dir, |
Vector3dT & | HitPoint, | ||
ComponentBaseT *& | HitComp | ||
) | const |
Traces a ray that originates at the player camera's origin in the given direction through the world.
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
The list of Lua methods for this class.