|
VoltMod
C++23 framework for CS2 server plugins
|
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 |
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.
| 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=().
|
delete |
References EntitySystem().
| 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().
|
inlinenoexcept |
What the wrappers' verbs call the engine through.
Definition at line 118 of file EntitySystem.hpp.
| 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().
| 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().
| 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().
| 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().
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().
|
inlinenoexcept |
Definition at line 119 of file EntitySystem.hpp.
| 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().
|
delete |
References EntitySystem().
| 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().
| 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().
| 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().
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().
| 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 168 of file EntitySystemSpawn.cpp.
References Create(), VoltMod::Schema::kRenderNormal, VoltMod::Entity::Raw(), VoltMod::KeyValues::Set(), VoltMod::Schema::CBeam::SetEndPos(), VoltMod::Schema::CBeam::SetEndWidth(), VoltMod::Entity::SetRender(), VoltMod::Schema::CBeam::SetWidth(), and VoltMod::Entity::Spawn().
| 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.
| 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().
| 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().
| 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().
A prop_dynamic; falsy when it did not spawn.
Definition at line 48 of file EntitySystemSpawn.cpp.
References SpawnProp().
Referenced by SpawnOutline(), and SpawnProp().