7#include <entity2/entityidentity.h>
8#include <entity2/entityinstance.h>
9#include <entity2/entitysystem.h>
10#include <entityhandle.h>
11#include <gameentitysystem.h>
12#include <interfaces/interfaces.h>
22static_assert(
MaxPlayers == ABSOLUTE_PLAYER_LIMIT);
25 : _interfaces(interfaces), _bindings(bindings)
27 if (_interfaces.GameResourceService)
33CGameEntitySystem* EntitySystem::ReadEntitySystemPointer()
41 CGameEntitySystem* system = ::GameEntitySystem();
43 if (system && !_isRealSystem)
46 _isRealSystem = !table ||
HasVtable(system, table);
50 "The resource service's entity system field is not a CGameEntitySystem; entity lookups are off.");
60 _interfaces.EntitySystem =
nullptr;
68 Log::Error(
"Entity system pointer could not be read from IGameResourceService.");
75 if (!_interfaces.EntitySystem)
77 _interfaces.EntitySystem = ReadEntitySystemPointer();
80 return _interfaces.EntitySystem;
92 return {*
this, system->GetEntityInstance(CEntityHandle(ref.
Handle))};
95CEntityInstance* EntitySystem::RawController(
int slot)
104 CEntityIdentity* identity = system->GetEntityIdentity(CEntityIndex(slot + 1));
115 return identity->m_pInstance;
120 return {*
this, RawController(slot), slot};
135 if (!
Raw() || className.empty())
141 const std::string name(className);
142 EntityInstanceByClassIter_t iter(
nullptr, name.c_str());
143 return {*
this, iter.Next()};
148 std::vector<Entity> found;
149 if (!
Raw() || className.empty())
154 const std::string name(className);
155 EntityInstanceByClassIter_t iter(
nullptr, name.c_str());
156 for (CEntityInstance* entity = iter.Next(); entity; entity = iter.Next())
158 found.emplace_back(*
this, entity);
A player's identity behind a slot: name, money, team, scoreboard row. It survives death and respawn; ...
VoltMod::Pawn Pawn() const
std::vector< Entity > FindAll(std::string_view className)
Entity Find(std::string_view className)
VoltMod::Controller Controller(int slot)
VoltMod::Pawn Pawn(int slot)
CGameEntitySystem * Raw()
Entity Get(EntityRef ref)
EntitySystem(VoltMod::Interfaces &interfaces, const VoltMod::Bindings &bindings)
A live entity, valid for this frame only.
A player's body: health, armor, movement, aim, weapons. The engine replaces it on every spawn; the Co...
void Error(std::format_string< Args... > fmt, Args &&... args)
void Info(std::format_string< Args... > fmt, Args &&... args)
static constexpr std::string_view ControllerClass
void * FindVirtualTable(std::string_view moduleName, std::string_view className)
bool HasVtable(const void *object, const void *table)
Centralized holder for all SDK interface pointers.
IGameResourceService * GameResourceService