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
bool IsHeld (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
std::optional< WeaponData > FindWeaponData () 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 SetParent (const Entity &parent, std::string_view attachment={}) const
void ClearParent () const
void StopEffect (bool immediately) 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 EmitSoundTo (std::string_view soundEvent, int slot, float volume=1.0f) const
void StopSound (std::string_view soundEvent) const
void SetModel (std::string_view path) const
void Follow (const Entity &parent, bool copyBones) 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
void LoopAnimation (std::string_view animation) const
void SetPlaybackRate (float rate) const
void SetSkin (int skin) const
void SetBodygroup (std::string_view group, int value) 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]

◆ 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::Entity::Entity(), VoltMod::EntitySystem::Get(), and VoltMod::Entity::Raw().

◆ Controller() [3/3]

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

References Controller().

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 VoltMod::Schema::CPlayer_MovementServices::Buttons(), VoltMod::Schema::CInButtonState::ButtonStates(), and InputPawn().

Referenced by IsHeld().

◆ 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::IsPlaying(), and VoltMod::Spectator.

Referenced by VoltMod::HiddenPlayer::HiddenPlayer(), and VoltMod::HiddenPlayer::Show().

◆ 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::IsValidSlot(), 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.

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

◆ IsHeld()

bool VoltMod::Controller::IsHeld ( uint64_t buttons) const
inline

Whether any of the IN_* buttons is held.

Definition at line 50 of file Controller.hpp.

References Buttons().

◆ Kick()

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

Definition at line 57 of file Controller.cpp.

References VoltMod::Entity::_e, and VoltMod::Entity::_sys.

◆ Money()

int VoltMod::Controller::Money ( ) const

The buy-menu balance; 0 when unavailable.

Definition at line 42 of file Controller.cpp.

References VoltMod::Schema::CCSPlayerController_InGameMoneyServices::Account().

◆ operator=()

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

References Controller().

◆ 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::CollectHiddenPlayer(), and VoltMod::EntitySystem::Pawn().

◆ Respawn()

Status VoltMod::Controller::Respawn ( ) const

◆ 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::Schema::CCSPlayerController_InGameMoneyServices::SetAccount().

◆ 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: