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 (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 SpawnOutline (const Entity &target, std::string_view model, const PropGlow &glow)
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 SpawnLine (std::string_view effect, const Vector &from, const Vector &to)
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 51 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 24 of file EntitySystem.cpp.

Referenced by EntitySystem(), and operator=().

◆ EntitySystem() [2/2]

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

References EntitySystem().

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 18 of file EntitySystemSpawn.cpp.

References VoltMod::Error::NotReady(), and VoltMod::Error::Unsupported().

Referenced by Create().

◆ Bindings()

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

What the wrappers' verbs call the engine through.

Definition at line 118 of file EntitySystem.hpp.

◆ Controller()

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

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

Definition at line 118 of file EntitySystem.cpp.

Referenced by VoltMod::CollectHiddenPlayer(), VoltMod::ObserverTarget(), and Pawn().

◆ 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 31 of file EntitySystemSpawn.cpp.

References Available().

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

◆ Find()

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

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

Definition at line 133 of file EntitySystem.cpp.

References Raw().

Referenced by VoltMod::GameRules().

◆ 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 146 of file EntitySystem.cpp.

References Raw().

◆ Get()

Entity VoltMod::EntitySystem::Get ( EntityRef ref)

What ref points at; falsy when it is unset, or its entity is gone or replaced.

Definition at line 83 of file EntitySystem.cpp.

References VoltMod::EntityRef::Handle, and Raw().

Referenced by VoltMod::AddHandleVector(), VoltMod::Controller::Controller(), VoltMod::ObserverTarget(), and Pawn().

◆ Interfaces()

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

Definition at line 119 of file EntitySystem.hpp.

◆ OnServerStartup()

void VoltMod::EntitySystem::OnServerStartup ( )

Re-read the system for the new map.

Definition at line 57 of file EntitySystem.cpp.

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

◆ operator=()

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

References EntitySystem().

◆ 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 128 of file EntitySystem.cpp.

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

◆ Pawn() [2/2]

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

The living body of slot's player; falsy when there is none.

Definition at line 123 of file EntitySystem.cpp.

References Controller(), and VoltMod::Controller::Pawn().

◆ Raw()

CGameEntitySystem * VoltMod::EntitySystem::Raw ( )

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

Definition at line 72 of file EntitySystem.cpp.

Referenced by Find(), FindAll(), Get(), and OnServerStartup().

◆ 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 41 of file EntitySystemSpawn.cpp.

References Create(), and VoltMod::Entity::Spawn().

Referenced by SpawnLine(), and SpawnParticle().

◆ SpawnBeam()

◆ SpawnLine() [1/2]

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

As above, to the fixed point to. The far end is an entity parented to the effect, so removing the effect removes both.

Definition at line 145 of file EntitySystemSpawn.cpp.

References VoltMod::Entity::Ref(), VoltMod::Entity::Remove(), VoltMod::KeyValues::Set(), VoltMod::Entity::SetParent(), Spawn(), SpawnLine(), and VoltMod::TargetSentToClients.

◆ SpawnLine() [2/2]

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 124 of file EntitySystemSpawn.cpp.

References Create(), VoltMod::Entity::Raw(), VoltMod::KeyValues::Set(), VoltMod::Schema::CParticleSystem::SetControlPointRef(), and VoltMod::Entity::Spawn().

Referenced by SpawnLine().

◆ SpawnOutline()

Entity VoltMod::EntitySystem::SpawnOutline ( const Entity & target,
std::string_view model,
const PropGlow & glow )

glow drawn around target without changing its look: an invisible copy of model, its model, that follows target in its pose. Remove it to take the outline off.

Definition at line 53 of file EntitySystemSpawn.cpp.

References VoltMod::Entity::Follow(), VoltMod::Entity::Origin(), and SpawnProp().

◆ 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 113 of file EntitySystemSpawn.cpp.

References 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 48 of file EntitySystemSpawn.cpp.

References SpawnProp().

Referenced by SpawnOutline(), and SpawnProp().


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