Cafu Engine
cf::GameSys::ComponentCarriedWeaponT Class Reference

This component represents a weapon that a player can pick up and use. More...

#include "CompCarriedWeapon.hpp"

Inheritance diagram for cf::GameSys::ComponentCarriedWeaponT:

Public Member Functions

 ComponentCarriedWeaponT ()
 The constructor. More...
 
 ComponentCarriedWeaponT (const ComponentCarriedWeaponT &Comp)
 The copy constructor. More...
 
bool IsAvail () const
 Returns whether this weapon is available to the player. More...
 
ComponentCarriedWeaponTClone () const override
 The virtual copy constructor. More...
 
const char * GetName () const override
 Returns the name of this component. More...
 
void PreCache () override
 Initializes any resources that may be needed on the client or server ahead of time. More...
 
void OnPostLoad (bool OnlyStatic) override
 This method is called after all entities and their components have been loaded. More...
 
const cf::TypeSys::TypeInfoTGetType () const
 
- 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...
 
EntityTGetEntity () const
 Returns the parent entity that contains this component, or NULL if this component is currently not a part of any entity. More...
 
TypeSys::VarManTGetMemberVars ()
 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 BoundingBox3fT GetCullingBB () const
 This method returns a bounding-box that encloses the visual representation of this component. More...
 
virtual const
cf::ClipSys::ClipModelT
GetClipModel ()
 This method returns the clip model of this component, if any. More...
 
virtual bool Render (bool FirstPersonView, float LodDist) const
 This method implements the graphical output of this component. More...
 
virtual void PostRender (bool FirstPersonView)
 This method provides an opportunity for another render pass. 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 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::MethsDocT DocCallbacks []
 
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 &)
 
RefCountedToperator= (const RefCountedT &)
 

Detailed Description

This component represents a weapon that a player can pick up and use.

Constructor & Destructor Documentation

ComponentCarriedWeaponT::ComponentCarriedWeaponT ( )

The constructor.

ComponentCarriedWeaponT::ComponentCarriedWeaponT ( const ComponentCarriedWeaponT Comp)

The copy constructor.

Parameters
CompThe component to create a copy of.

Member Function Documentation

ComponentCarriedWeaponT * ComponentCarriedWeaponT::Clone ( ) const
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.

const char* cf::GameSys::ComponentCarriedWeaponT::GetName ( ) const
inlineoverridevirtual

Returns the name of this component.

Reimplemented from cf::GameSys::ComponentBaseT.

bool cf::GameSys::ComponentCarriedWeaponT::IsAvail ( ) const
inline

Returns whether this weapon is available to the player.

A weapon is usually available to the player only after it has been picked up in the world. Alternatively, it is possible to configure the player prototype to spawn the player with the weapon readily available. Only weapons that are available can be selected and drawn.

void ComponentCarriedWeaponT::OnPostLoad ( bool  OnlyStatic)
overridevirtual

This method is called after all entities and their components have been loaded.

It is called only once when the static part of world initializatzion is complete, i.e. after the initial values of all entities and their components have been set. Components can override this method in order act / do something / add custom behaviour at that time.

For example, a choice component can use it to set the associated text component to the initial selection, a script component can forward it to the script by calling a related script function, a component that for backwards-compatibility supports reading old variables can convert to new ones, etc.

Parameters
OnlyStatictrue if only the loading of static data is desired, e.g. when the world is instantiated in the Map Editor, false if also user-defined scripts with custom, initial behaviour should be loaded. Also see WorldT::InitFlagsT::InitFlag_OnlyStatic for related information.

Reimplemented from cf::GameSys::ComponentBaseT.

void ComponentCarriedWeaponT::PreCache ( )
overridevirtual

Initializes any resources that may be needed on the client or server ahead of time.

The goal is to avoid in-game disruptions on frame-rate caused by lazily loaded assets.

Reimplemented from cf::GameSys::ComponentBaseT.

Member Data Documentation

const cf::TypeSys::MethsDocT ComponentCarriedWeaponT::DocCallbacks
staticprotected
Initial value:
=
{
{ "IsIdle",
"This method is called in order to learn if this weapon is currently idle.",
"boolean", "" },
{ "Draw",
"This method is called in order to let this weapon know that it is drawn.",
"", "" },
{ "Holster",
"This method is called in order to have this weapon holstered.",
"boolean", "" },
{ "FirePrimary",
"This method is called in order to have this weapon emit primary fire.",
"", "(boolean ThinkingOnServerSide)" },
{ "FireSecondary",
"This method is called in order to have this weapon emit secondary fire.",
"", "(boolean ThinkingOnServerSide)" },
{ "PreCache",
"This method is called in order to have the weapon pre-cache its resources.",
"", "" },
{ NULL, NULL, NULL, NULL }
}
const char * ComponentCarriedWeaponT::DocClass
staticprotected
Initial value:
=
"This component represents a weapon that a player can pick up and use."
const cf::TypeSys::MethsDocT ComponentCarriedWeaponT::DocMethods
staticprotected
Initial value:
=
{
META_toString,
{ NULL, NULL, NULL, NULL }
}
const cf::TypeSys::VarsDocT ComponentCarriedWeaponT::DocVars
staticprotected
Initial value:
=
{
{ "Label", "A short informational name for this weapon. Used for reference e.g. in the Map Editor, in log output, or in script code (therefore, changing it for existing weapons may require a review of the related script code)." },
{ "IsAvail", "Is this weapon available to the player? Normally `false` when the player spawns. Switched to `true` when the player picks up the weapon for the first time, whereupon it can be selected and drawn." },
{ "Script", "The filename of the script that implements the behaviour of this weapon." },
{ "PrimaryAmmo", "The current amount of ammo for the primary fire of this weapon." },
{ "MaxPrimaryAmmo", "The maximum amount of ammo for the primary fire of this weapon." },
{ "SecondaryAmmo", "The current amount of ammo for the secondary fire of this weapon." },
{ "MaxSecondaryAmmo", "The maximum amount of ammo for the secondary fire of this weapon." },
{ NULL, NULL }
}
const luaL_Reg ComponentCarriedWeaponT::MethodsList
staticprotected
Initial value:
=
{
{ "__tostring", toString },
{ NULL, NULL }
}

The list of Lua methods for this class.


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