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

runtime.Entities: finds and creates entities. Everything it returns is valid for this frame only; see Entity. More...

#include <EntitySystem.hpp>

Public Member Functions

 EntitySystem (VoltMod::Interfaces &interfaces, const VoltMod::Bindings &bindings)
 
 ~EntitySystem ()
 
 EntitySystem (const EntitySystem &)=delete
 
EntitySystem & operator= (const EntitySystem &)=delete
 
VoltMod::Controller Controller (int slot)
 
VoltMod::Pawn Pawn (int slot)
 
VoltMod::Pawn Pawn (EntityRef ref)
 
Entity Get (EntityRef ref)
 
Entity Find (std::string_view className)
 
std::vector< Entity > FindAll (std::string_view className)
 
Status Available () const
 
Entity Create (std::string_view className)
 
Entity Spawn (std::string_view className, KeyValues &values)
 
Entity SpawnProp (const PropSpec &prop)
 
Entity SpawnParticle (std::string_view effect, const Vector &origin, const QAngle &angles={0.0f, 0.0f, 0.0f})
 
Entity SpawnLine (std::string_view effect, const Vector &from, EntityRef end)
 
Entity SpawnBeam (const Vector &from, const Vector &to, float width, Color color)
 
Framework plumbing
void OnServerStartup ()
 
CGameEntitySystem * Raw ()
 
const VoltMod::Bindings & Bindings () const noexcept
 
const VoltMod::Interfaces & Interfaces () const noexcept
 

Detailed Description

runtime.Entities: finds and creates entities. Everything it returns is valid for this frame only; see Entity.

Definition at line 39 of file EntitySystem.hpp.

Constructor & Destructor Documentation

◆ EntitySystem() [1/2]

VoltMod::EntitySystem::EntitySystem ( VoltMod::Interfaces &  interfaces,
const VoltMod::Bindings &  bindings 
)

Reads the entity system, which is null before the first map. interfaces and bindings must outlive this service.

Definition at line 34 of file EntitySystem.cpp.

References VoltMod::Bindings::GameEntitySystem, VoltMod::Interfaces::GameResourceService, VoltMod::Log::Info(), Raw(), and VoltMod::Offset< T >::Value().

◆ ~EntitySystem()

VoltMod::EntitySystem::~EntitySystem ( )

Definition at line 44 of file EntitySystem.cpp.

References VoltMod::Interfaces::EntitySystem, and g_entitySystem.

◆ EntitySystem() [2/2]

VoltMod::EntitySystem::EntitySystem ( const EntitySystem &  )
delete

Member Function Documentation

◆ Available()

Status VoltMod::EntitySystem::Available ( ) const

An error when entity lookups can never work, or entities cannot be created or spawned. A missing system before the first map is fine: OnServerStartup picks it up.

Definition at line 13 of file EntitySystemSpawn.cpp.

References VoltMod::Bindings::CreateEntityByName, VoltMod::Bindings::DispatchSpawn, VoltMod::Bindings::GameEntitySystem, VoltMod::Interfaces::GameResourceService, VoltMod::Error::NotReady(), and VoltMod::Error::Unsupported().

Referenced by Create().

◆ Bindings()

◆ Controller()

VoltMod::Controller VoltMod::EntitySystem::Controller ( int  slot)

The controller in slot; falsy when the slot is empty.

Definition at line 143 of file EntitySystem.cpp.

References VoltMod::ReadFile().

Referenced by VoltMod::Pawn::Controller(), VoltMod::Player::Controller(), VoltMod::Player::Name(), and VoltMod::Visibility::OnCheckTransmit().

◆ Create()

Entity VoltMod::EntitySystem::Create ( std::string_view  className)

A new entity that has not spawned yet: set its fields, then call Entity::Spawn.

Definition at line 30 of file EntitySystemSpawn.cpp.

References Available(), VoltMod::Bindings::CreateEntityByName, and VoltMod::ReadFile().

Referenced by Spawn(), SpawnBeam(), SpawnLine(), and SpawnProp().

◆ Find()

Entity VoltMod::EntitySystem::Find ( std::string_view  className)

The first entity of className, such as "cs_gamerules"; * wildcards match.

Definition at line 158 of file EntitySystem.cpp.

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

◆ FindAll()

std::vector< Entity > VoltMod::EntitySystem::FindAll ( std::string_view  className)

Every entity of className, taken now, so removing them while looping is safe.

Definition at line 171 of file EntitySystem.cpp.

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

◆ Get()

◆ Interfaces()

const VoltMod::Interfaces & VoltMod::EntitySystem::Interfaces ( ) const
inlinenoexcept

◆ OnServerStartup()

void VoltMod::EntitySystem::OnServerStartup ( )

Re-read the system for the new map.

Definition at line 82 of file EntitySystem.cpp.

References VoltMod::Log::Error(), VoltMod::Log::Info(), and Raw().

◆ operator=()

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

◆ Pawn() [1/2]

VoltMod::Pawn VoltMod::EntitySystem::Pawn ( EntityRef  ref)

The player pawn ref points at; falsy when it is gone or not a player pawn.

Definition at line 153 of file EntitySystem.cpp.

References VoltMod::Entity::AsPawn(), VoltMod::Get, and VoltMod::ReadFile().

◆ Pawn() [2/2]

VoltMod::Pawn VoltMod::EntitySystem::Pawn ( int  slot)

◆ Raw()

CGameEntitySystem * VoltMod::EntitySystem::Raw ( )

The engine's entity system; null before the first map.

Definition at line 97 of file EntitySystem.cpp.

References VoltMod::Interfaces::EntitySystem.

Referenced by EntitySystem(), Find(), FindAll(), Get(), OnServerStartup(), and VoltMod::Entity::RemoveAfter().

◆ Spawn()

Entity VoltMod::EntitySystem::Spawn ( std::string_view  className,
KeyValues &  values 
)

Create and spawn; falsy on failure. The engine takes the keyvalues.

Definition at line 40 of file EntitySystemSpawn.cpp.

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

Referenced by SpawnParticle().

◆ SpawnBeam()

Entity VoltMod::EntitySystem::SpawnBeam ( const Vector &  from,
const Vector &  to,
float  width,
Color  color 
)

A straight line of width from from to to.

Definition at line 114 of file EntitySystemSpawn.cpp.

References Create(), VoltMod::Schema::kRenderNormal, VoltMod::ReadFile(), VoltMod::KeyValues::Set(), and VoltMod::Schema::CBeam::SetWidth().

◆ SpawnLine()

Entity VoltMod::EntitySystem::SpawnLine ( std::string_view  effect,
const Vector &  from,
EntityRef  end 
)

A running particle effect from from whose control point 1 follows end, such as a tracer to its target. Linked by handle, so neither entity needs a name.

Definition at line 93 of file EntitySystemSpawn.cpp.

References Create(), VoltMod::ReadFile(), VoltMod::KeyValues::Set(), and VoltMod::Schema::CParticleSystem::SetControlPointRef().

◆ SpawnParticle()

Entity VoltMod::EntitySystem::SpawnParticle ( std::string_view  effect,
const Vector &  origin,
const QAngle &  angles = {0.0f, 0.0f, 0.0f} 
)

A running particle effect such as "particles/explosion.vpcf"; empty for an empty name. Remove it to stop it.

Definition at line 82 of file EntitySystemSpawn.cpp.

References VoltMod::ReadFile(), VoltMod::KeyValues::Set(), and Spawn().

◆ SpawnProp()

Entity VoltMod::EntitySystem::SpawnProp ( const PropSpec &  prop)

A prop_dynamic; falsy when it did not spawn.

Definition at line 47 of file EntitySystemSpawn.cpp.

References Create(), VoltMod::ReadFile(), VoltMod::KeyValues::Set(), VoltMod::SolidNone, and VoltMod::SolidVPhysics.


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