7#include <checktransmitinfo.h>
9#include <entity2/entityinstance.h>
10#include <entityhandle.h>
11#include <tier1/utlvector.h>
27 CEntityInstance*
Pawn =
nullptr;
104 _slotListener =
slots.Changed += [
this](
int slot) {
110 std::erase_if(_private, [
slot](
const PrivateEntity&
e) {
return e.Viewer ==
slot; });
139 return std::unexpected(
Error::Unsupported(
"the CheckTransmitPlayerSlot offset did not bind"));
151 SetPrivate({.Entity =
entity, .Viewer =
slot});
161 SetPrivate({.Entity =
entity, .ShownTo =
team});
171 SetPrivate({.Entity =
entity, .HiddenFrom =
team});
174void Visibility::SetPrivate(
const PrivateEntity&
entry)
176 const auto found = std::ranges::find(_private,
entry.Entity, &PrivateEntity::Entity);
177 if (
found != _private.end())
183 _private.push_back(
entry);
189 std::erase_if(_private, [
entity](
const PrivateEntity&
e) {
return e.Entity ==
entity; });
194 return std::make_shared<GlowVision>(_entities, *
this,
viewerSlot, std::move(
config));
199 return std::make_shared<GlowVision>(_entities, *
this,
viewerTeam, std::move(
config));
218 for (
auto&
entry : _private)
223 std::erase_if(_private, [](
const PrivateEntity&
e) {
return e.Index <= 0; });
229 if (_private.empty() && std::ranges::none_of(_state, &SlotState::Any))
235 std::array<HiddenPlayer, MaxPlayers>
hidden;
249 if (!
info || !
info->m_pTransmitEntity)
268 for (
int n = 0;
n <
player.IndexCount; ++
n)
270 info->m_pTransmitEntity->Clear(
player.PawnIndices[
n]);
274 if (
player.ControllerIndex > 0)
276 info->m_pTransmitEntity->Clear(
player.ControllerIndex);
280 for (
const auto&
entry : _private)
284 info->m_pTransmitEntity->Clear(
entry.Index);
A player's identity behind a slot: name, money, team, scoreboard row. It survives death and respawn; ...
VoltMod::Pawn InputPawn() const
runtime.Entities: finds and creates entities. Everything it returns is valid for this frame only; see...
VoltMod::Controller Controller(int slot)
Entity Get(EntityRef ref)
A live entity, valid for this frame only.
CEntityInstance * Raw() const noexcept
T Read(const void *base) const
A player's body: health, armor, movement, aim, weapons. The engine replaces it on every spawn; the Co...
VoltMod::Controller Controller() const
"The occupant of this slot changed" - raised by PlayerManager, consumed below it.
void ShowOnlyToTeam(EntityRef entity, Team team)
Visibility(EntitySystem &entities, const Bindings &bindings, SlotEvents &slots)
void SetPawnHidden(int slot, bool hidden)
bool IsPawnHidden(int slot) const
void HideFromTeam(EntityRef entity, Team team)
void ShowToEveryone(EntityRef entity)
void SetControllerHidden(int slot, bool hidden)
std::shared_ptr< GlowVision > CreateGlow(int viewerSlot, GlowConfig config={})
void ShowOnlyTo(EntityRef entity, int slot)
void OnCheckTransmit(CCheckTransmitInfo **infoList, int infoCount)
constexpr bool IsPlaying(Team team)
static std::string ReadFile(const std::filesystem::path &path)
static void CollectHiddenPlayer(EntitySystem &entities, int slot, bool pawnHidden, bool controllerHidden, HiddenPlayer &out)
constexpr bool IsValidSlot(int slot)
CUtlVector< CEntityHandle > HandleVector
static CEntityInstance * ObserverTarget(EntitySystem &entities, int recipientSlot)
std::expected< void, Error > Status
static void AddHandleVector(EntitySystem &entities, HiddenPlayer &player, const void *vector)
static constexpr int MaxIndicesPerPlayer
static void AddIndex(HiddenPlayer &player, int index)
Offset< uint8_t > VisibilityRecipientSlot
static Error Unsupported(std::string detail)
std::array< int, MaxIndicesPerPlayer > PawnIndices