20 if (!_interfaces.GameResourceService)
22 return std::unexpected(
Error::NotReady(
"IGameResourceService not available"));
24 if (!_bindings.CreateEntityByName || !_bindings.DispatchSpawn)
26 return std::unexpected(
Error::Unsupported(
"CreateEntityByName or DispatchSpawn did not bind"));
38 return {*
this, _bindings.CreateEntityByName(std::string(className).c_str(), -1)};
60 {.Model = model, .Origin = target.
Origin(), .Solid =
false, .CastsShadow =
false, .Glow = glow},
true);
61 outline.
Follow(target,
true);
71 .
Set(
"solid",
static_cast<int>(prop.
Solid ? SOLID_VPHYSICS : SOLID_NONE));
72 if (!prop.
Skin.empty())
78 values.
Set(
"disableshadows", 1);
82 const PropGlow& glow = *prop.
Glow;
84 values.
Set(
"glowcolor", glow.Color)
85 .
Set(
"glowrange", glow.Range)
86 .
Set(
"glowteam", team)
94 Entity entity =
Create(
"prop_dynamic");
98 entity.SetOwnerEntity(prop.
Owner);
100 entity.Spawn(values);
102 if (entity && !prop.
Solid)
104 entity.AcceptInput(
"DisableCollision");
106 if (entity && prop.
Scale != 1.0f)
108 entity.SetScale(prop.
Scale);
120 values.
Set(
"effect_name", effect).
Set(
"start_active", 1).
Set(
"origin", origin).
Set(
"angles", angles);
121 return Spawn(
"info_particle_system", values);
140 values.
Set(
"effect_name", effect).
Set(
"start_active", 1).
Set(
"origin", from);
183 values.
Set(
"origin", from);
Entity Create(std::string_view className)
Entity SpawnProp(const PropSpec &prop)
Entity SpawnBeam(const Vector &from, const Vector &to, float width, Color color)
Entity Spawn(std::string_view className, KeyValues &values)
Entity SpawnLine(std::string_view effect, const Vector &from, EntityRef end)
Entity SpawnParticle(std::string_view effect, const Vector &origin, const QAngle &angles={0.0f, 0.0f, 0.0f})
Entity SpawnOutline(const Entity &target, std::string_view model, const PropGlow &glow)
A live entity, valid for this frame only.
void SetParent(const Entity &parent, std::string_view attachment={}) const
void SetRender(Schema::RenderMode_t mode, Color color) const
void Follow(const Entity &parent, bool copyBones) const
void Spawn(KeyValues &values) const
CEntityInstance * Raw() const noexcept
Spawn keyvalues such as "origin", "spawnflags" or "effect_name".
KeyValues & Set(std::string_view key, std::string_view value)
void SetEndWidth(float value) const
void SetEndPos(Vector value) const
void SetWidth(float value) const
void SetControlPointRef(size_t index, EntityRef value) const
static constexpr int TargetSentToClients
static constexpr int GlowStateAlwaysOn
static constexpr int GlowTeamAny
std::expected< void, Error > Status
static constexpr int OutlineRenderAmount
An RGBA color in the engine's byte order, as m_clrRender and glow colors hold it.
static Error Unsupported(std::string detail)
static Error NotReady(std::string detail)
std::optional< PropGlow > Glow