VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
VoltMod::Controller Class Reference

A player's identity behind a slot: name, money, team, scoreboard row. It survives death and respawn; the body is Pawn(). Its own CBaseEntity fields, such as Health, mean nothing for gameplay. More...

#include <Controller.hpp>

+ Inheritance diagram for VoltMod::Controller:

Public Member Functions

 Controller ()=default
 
 Controller (EntitySystem &entities, CEntityInstance *raw, int slot)
 
 Controller (const Controller &)=default
 
Controller & operator= (const Controller &)=delete
 
int Slot () const noexcept
 
VoltMod::Pawn Pawn () const
 
VoltMod::Pawn InputPawn () const
 
uint64_t Buttons () const
 
int Money () const
 
void SetMoney (int amount) const
 
void Kick (std::string_view reason) const
 
void ExecuteCommand (std::string_view command) const
 
void ChangeTeam (VoltMod::Team team) const
 
Status Respawn () const
 
- Public Member Functions inherited from VoltMod::Entity
 Entity () noexcept
 
 Entity (EntitySystem &entities, CEntityInstance *raw) noexcept
 
 Entity (const Entity &)=default
 
Entity & operator= (const Entity &)=delete
 
 operator bool () const noexcept
 
CEntityInstance * Raw () const noexcept
 
int Index () const
 
EntityRef Ref () const
 
std::string_view ClassName () const
 
Pawn AsPawn () const
 
Vector Origin () const
 
QAngle Angles () const
 
void Teleport (std::optional< Vector > origin, std::optional< QAngle > angles, std::optional< Vector > velocity) const
 
Schema::MoveType_t MoveType () const
 
void SetMoveType (Schema::MoveType_t type) const
 
void Spawn (KeyValues &values) const
 
void AcceptInput (std::string_view input, std::string_view value={}, const Entity &activator={}) const
 
void Remove () const
 
void RemoveAfter (float seconds) const
 
void EmitSound (std::string_view soundEvent, float volume=1.0f) const
 
void EmitSound (std::string_view soundEvent, IRecipientFilter &recipients, float volume=1.0f) const
 
void StopSound (std::string_view soundEvent) const
 
void SetModel (std::string_view path) const
 
void SetScale (float scale) const
 
void SetRender (Schema::RenderMode_t mode, Color color) const
 
void SetVisible (bool visible, uint8_t alpha=0) const
 
void PlayAnimation (std::string_view animation, std::string_view idle={}) const
 

Additional Inherited Members

- Protected Attributes inherited from VoltMod::Entity
EntitySystem * _sys = nullptr
 
CEntityInstance * _e = nullptr
 

Detailed Description

A player's identity behind a slot: name, money, team, scoreboard row. It survives death and respawn; the body is Pawn(). Its own CBaseEntity fields, such as Health, mean nothing for gameplay.

Definition at line 19 of file Controller.hpp.

Constructor & Destructor Documentation

◆ Controller() [1/3]

VoltMod::Controller::Controller ( )
default

◆ Controller() [2/3]

VoltMod::Controller::Controller ( EntitySystem &  entities,
CEntityInstance *  raw,
int  slot 
)

Prefer runtime.Entities.Controller(slot).

Definition at line 20 of file Controller.cpp.

References VoltMod::ReadFile().

◆ Controller() [3/3]

VoltMod::Controller::Controller ( const Controller &  )
default

Member Function Documentation

◆ Buttons()

uint64_t VoltMod::Controller::Buttons ( ) const

Held buttons as IN_* bits, read from InputPawn so they arrive while dead too.

Definition at line 35 of file Controller.cpp.

References InputPawn(), and VoltMod::ReadFile().

◆ ChangeTeam()

void VoltMod::Controller::ChangeTeam ( VoltMod::Team  team) const

Does nothing for a team outside Spectator..CT or when the vtable slot did not bind.

Definition at line 109 of file Controller.cpp.

References VoltMod::Entity::_e, VoltMod::Entity::_sys, VoltMod::EntitySystem::Bindings(), VoltMod::Bindings::ChangeTeam, VoltMod::IsPlaying(), VoltMod::ReadFile(), and VoltMod::Spectator.

◆ ExecuteCommand()

void VoltMod::Controller::ExecuteCommand ( std::string_view  command) const

Run one console command as this player, server-side and without a chat echo; plugins hooking ISource2GameClients::ClientCommand see it. Refuses and logs ; and newlines.

Definition at line 78 of file Controller.cpp.

References VoltMod::Entity::_e, VoltMod::Entity::_sys, VoltMod::Interfaces::CVar, VoltMod::EntitySystem::Interfaces(), VoltMod::IsValidSlot(), VoltMod::ReadFile(), VoltMod::Interfaces::ServerGameClients, VoltMod::TokenizeOneCommand(), and VoltMod::Log::Warn().

◆ InputPawn()

VoltMod::Pawn VoltMod::Controller::InputPawn ( ) const

The pawn the player's input drives: Pawn while alive, the observer pawn while dead or spectating.

Definition at line 30 of file Controller.cpp.

References VoltMod::Entity::_sys, VoltMod::EntitySystem::Get(), and VoltMod::Entity::Raw().

Referenced by Buttons(), and VoltMod::ObserverTarget().

◆ Kick()

void VoltMod::Controller::Kick ( std::string_view  reason) const

◆ Money()

int VoltMod::Controller::Money ( ) const

The buy-menu balance; 0 when unavailable.

Definition at line 42 of file Controller.cpp.

References VoltMod::ReadFile().

◆ operator=()

Controller & VoltMod::Controller::operator= ( const Controller &  )
delete

◆ Pawn()

VoltMod::Pawn VoltMod::Controller::Pawn ( ) const

The living body; falsy while dead.

Definition at line 25 of file Controller.cpp.

References VoltMod::Entity::_sys.

Referenced by VoltMod::EntitySystem::Pawn().

◆ Respawn()

◆ SetMoney()

void VoltMod::Controller::SetMoney ( int  amount) const

Does nothing when the money services are unavailable.

Definition at line 48 of file Controller.cpp.

References VoltMod::ReadFile().

◆ Slot()

int VoltMod::Controller::Slot ( ) const
inlinenoexcept

The slot, or -1.

Definition at line 37 of file Controller.hpp.


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