Class BaseEntity
Namespace: ValveResourceFormat.Renderer.Entities
Assembly: Renderer.dll
The base of the simulated entities. Ticks inside BaseEntity.EntitySystem and owns the scene nodes that draw it.
public abstract class BaseEntityInheritance
object ← BaseEntity
Derived
AmbientGeneric, BaseModelEntity, DotaLightInfo, EnvCubemapFog, EnvExplosion, EnvFogController, EnvGlobalLight, EnvGradientFog, EnvLightingVolume, EnvSky, EnvSoundscape, EnvTonemapController, EnvVolumetricFogController, EnvVolumetricFogVolume, FilterActivatorModel, FilterActivatorTeam, GenericEntity, InfoDynamicShadowHint, InfoMapParameters, InfoParticleSystem, InfoSpawnGroupLoadUnload, InfoVisibilityBox, InfoWorldLayer, LightEntity, LogicAuto, LogicBranch, LogicBranchListener, LogicCase, LogicCompare, LogicRelay, LogicTimer, MathCounter, PathParticleRopeEntity, PathTrack, PlayerEntity, PointCamera, PointClientUIWorldPanel, PointEntityFader, PointSoundEvent, PointTeleport, PointTemplate, SkyCameraVolume, SkyCameraVolumeTarget, SkyboxReference, SpawnPoint, WorldEntity
Remarks
Entities move on the fixed tick rather than the render frame, so think intervals and ramps do not depend on framerate. An entity is not a scene node; it owns BaseEntity.RootNode and places it each frame.
Constructors
BaseEntity(EntitySystem, EntitySpawnInfo)
Initializes the entity from its keyvalues.
protected BaseEntity(EntitySystem system, EntitySpawnInfo spawnInfo)Parameters
system EntitySystem
spawnInfo EntitySpawnInfo
BaseEntity(EntitySystem, Scene, string)
Initializes an entity created at runtime, which has no keyvalues and starts at the world origin.
protected BaseEntity(EntitySystem system, Scene scene, string classname)Parameters
system EntitySystem
The entity world it lives in.
scene Scene
The scene its nodes render into.
classname string
The classname it reports.
Properties
Angles
Gets or sets the orientation relative to the move parent frame, as a QAngle (pitch, yaw, roll) in degrees. Setting it rebuilds BaseEntity.Transform.
public Vector3 Angles { get; set; }Property Value
AngularVelocity
Gets or sets the angular velocity as a QAngle in degrees per second, about the entity's own axes unless BaseEntity.TurnsByAngleComponents says otherwise.
public Vector3 AngularVelocity { get; set; }Property Value
Classname
Gets the entity's classname.
public string Classname { get; }Property Value
string
Collider
Gets the collision shape, or null when it has none. Built by BaseModelEntity from the model's physics and moved with the entity every tick.
public EntityCollider? Collider { get; protected set; }Property Value
Data
Gets the keyvalues as authored in the map, or null for an entity created at runtime. Names in it still carry their fixup markers; BaseEntity.SpawnData has the spawned names.
public EntityLump.Entity? Data { get; }Property Value
EntityScale
Gets the authored scales, which movement never changes.
public Vector3 EntityScale { get; }Property Value
EntitySystem
Gets the world this entity lives in.
public EntitySystem EntitySystem { get; }Property Value
HasVPhysicsSolid
Gets whether this entity collides as a physics mesh, as nearly every model does. A turning one pushes the player by the motion of the corner of their box that leads into the turn, rather than by the motion of their origin.
protected virtual bool HasVPhysicsSolid { get; }Property Value
bool
IsCollidable
Gets whether the entity currently takes part in collision traces, which are only made in the main world group's physics world.
public bool IsCollidable { get; }Property Value
bool
IsDrawn
Gets or sets whether the game draws the entity's geometry. Every node it owns follows through SceneNode.Visible, unless a stopped EntitySystem.Enabled keeps it shown.
public bool IsDrawn { get; set; }Property Value
bool
IsPusher
Gets whether this entity pushes the player out of its way as it moves. Doors, buttons, rotating brushes and trains opt in.
protected virtual bool IsPusher { get; }Property Value
bool
IsRemoved
Gets whether this entity has been removed from the world and is awaiting cleanup.
public bool IsRemoved { get; }Property Value
bool
IsShown
Gets whether the entity's geometry ends up shown, which in an editor it is even while the game hides it.
public bool IsShown { get; }Property Value
bool
IsSolid
Gets or sets whether the entity collides with the player. false keeps the shape but takes the entity out of traces.
public bool IsSolid { get; set; }Property Value
bool
IsTrigger
Gets or sets whether the entity is a trigger volume, which reports touches instead of blocking.
public bool IsTrigger { get; set; }Property Value
bool
IsUnblockableByPlayer
Gets whether the player can never block this pusher: the player is moved the whole way, through the world if need be, and the pusher keeps going.
protected virtual bool IsUnblockableByPlayer { get; }Property Value
bool
KeyValues
Gets BaseEntity.SpawnData, throwing for an entity created at runtime. A class that can be either reads BaseEntity.SpawnData instead.
protected EntityLump.Entity KeyValues { get; }Property Value
ModelName
Gets the model the map authored. An entity that draws it derives from BaseModelEntity.
public string? ModelName { get; protected set; }Property Value
string?
MoveDoneTime
Gets the time BaseEntity.MoveDone() next runs on the entity's own move clock, or -1 when no move is scheduled. Pushing entities step their movement state machines with it.
public float MoveDoneTime { get; }Property Value
float
Remarks
The clock only runs while a move is pending and winds back when a push is blocked, so a move lasts exactly as long as scheduled, whenever in the tick it was scheduled.
MoveParent
Gets the entity this one moves with (parentname), a different link than BaseEntity.Owner. A door's handle rides its door through this.
public BaseEntity? MoveParent { get; }Property Value
MovesWithoutPushing
Gets or sets whether this pusher moves through whatever is in its way without pushing it or being blocked, the MoveWithoutPushingBlockers attribute.
protected bool MovesWithoutPushing { get; set; }Property Value
bool
NameFixup
Gets what the spawning group put in place of the markers in this entity's names.
public EntityNameFixup NameFixup { get; }Property Value
NextThink
Gets the time BaseEntity.Think() next runs, in EntitySystem.CurrentTime seconds, or -1 when the entity is not thinking.
public float NextThink { get; }Property Value
float
ObjectCaps
Gets what this entity can do, which the player's use trace checks.
public virtual EntityCapability ObjectCaps { get; }Property Value
Origin
Gets or sets the origin in the move parent frame, the world origin for an entity without one. Movement works in this. Setting it rebuilds BaseEntity.Transform.
public Vector3 Origin { get; set; }Property Value
Owner
Gets or sets the owning entity. Null only on the root WorldEntity.
public BaseEntity? Owner { get; set; }Property Value
PushesPlayerAsTrain
Gets whether a player in the way of anything parented under this entity is pushed as a train pushes them: slid along the push and lifted out of whatever it left them in, and never able to block it.
protected virtual bool PushesPlayerAsTrain { get; }Property Value
bool
RigidTransform
Gets the world transform at the current tick, without BaseEntity.EntityScale, for anything the scale must not stretch, such as collision.
public Matrix4x4 RigidTransform { get; }Property Value
RootNode
Gets the node this entity is drawn as, from BaseEntity.CreateRootNode().
public SceneNode? RootNode { get; }Property Value
Scene
Gets the scene that holds the nodes of this entity.
public Scene Scene { get; }Property Value
SpawnData
Gets BaseEntity.Data with BaseEntity.NameFixup applied to every name, or null for an entity created at runtime.
public EntityLump.Entity? SpawnData { get; }Property Value
SpawnFlags
Gets the entity's spawnflags, which some entities change at runtime.
public uint SpawnFlags { get; protected set; }Property Value
uint
SpawnGroup
Gets the spawn group that owns the entity and removes it when it unloads, or null for an entity created at runtime.
public SpawnGroup? SpawnGroup { get; }Property Value
SpawnTransform
Gets the placement of the template or spawn group that spawned this entity, already applied to its pose. Identity for map entities.
public Matrix4x4 SpawnTransform { get; }Property Value
TargetName
Gets the entity's targetname, the name entity I/O addresses it by.
public string? TargetName { get; }Property Value
string?
TouchingEntities
Gets the entities currently inside this one's volume.
public IReadOnlyCollection<BaseEntity> TouchingEntities { get; }Property Value
IReadOnlyCollection<BaseEntity>
Transform
Gets the world transform the entity is drawn at, interpolated between ticks.
public Matrix4x4 Transform { get; }Property Value
TurnsByAngleComponents
Gets whether a turn adds BaseEntity.AngularVelocity onto the QAngle components rather than turning about the body's own axes. Doors and other toggle brushes do, so their travel between two authored angles is a straight line through the components and lands where it was aimed.
protected virtual bool TurnsByAngleComponents { get; }Property Value
bool
Velocity
Gets or sets the linear velocity in units per second, in the move parent frame.
public Vector3 Velocity { get; set; }Property Value
WorldAngles
Gets or sets the world orientation at the current tick. Setting it turns the local angles to match.
public Vector3 WorldAngles { get; set; }Property Value
WorldOrigin
Gets or sets the world origin at the current tick. Setting it moves the local origin to match.
public Vector3 WorldOrigin { get; set; }Property Value
Methods
AcceptInput(string, EntityInputData)
Handles an entity I/O input by running the handler declared with EntityInputAttribute. Override only to intercept inputs that cannot be a fixed method, and call the base to fall back to the table.
public virtual bool AcceptInput(string inputName, EntityInputData data)Parameters
inputName string
data EntityInputData
Returns
bool
true when the input was handled.
AcceptsTouchFrom(BaseEntity)
Whether this entity accepts a touch from other. Refusing keeps the touch link from opening, which is where a trigger's filters belong.
protected virtual bool AcceptsTouchFrom(BaseEntity other)Parameters
other BaseEntity
Returns
bool
Activate()
Called once every entity of its spawn group has spawned, to resolve other entities by name.
public virtual void Activate()AddNode(SceneNode, bool)
Adds a node to the scene and takes ownership of its lifetime, visibility and, by default, placement. A model entity also owns the collision hulls its model was compiled with.
protected void AddNode(SceneNode node, bool followsEntity = true)Parameters
node SceneNode
The node to own.
followsEntity bool
Whether the entity places the node at itself. Pass false for a node placed some other way, such as an effect whose control point 0 belongs to another entity.
AngleMod(float)
Wraps an angle into 0, 360), quantized to 65536 steps as in game, so comparisons against a stored angle behave the same.
public static float AngleMod(float degrees)Parameters
degrees [float
Returns
float
CreateEditorNode(ObjectTypeFlags)
Builds the stand-in the tool draws this entity as, through EntitySystem.ToolVisuals. null without one, and for an entity created at runtime, which was never authored.
protected SceneNode? CreateEditorNode(ObjectTypeFlags flags = ObjectTypeFlags.None)Parameters
flags ObjectTypeFlags
Flags for the node.
Returns
The node, or null.
CreateEffect(string?, ParticleSnapshot?, bool)
Loads an effect at the entity on the particles layer. The caller decides through BaseEntity.AddNode(SceneNode, bool) whether the entity owns and places it.
protected ParticleSceneNode? CreateEffect(string? effectName, ParticleSnapshot? snapshot = null, bool playedByEntity = true)Parameters
effectName string?
The effect, or null or empty for none.
snapshot ParticleSnapshot?
A snapshot the effect starts from, such as a rope's points.
playedByEntity bool
Whether the entity sets the control points, rather than the effect's own configuration.
Returns
The effect, or null when there is none or it failed to load.
CreateRootNode()
Builds the node this entity is drawn as, or returns null for one that draws nothing.
protected virtual SceneNode? CreateRootNode()Returns
The node, or null to own none.
Remarks
The default is the tool's stand-in, BaseEntity.CreateEditorNode(ObjectTypeFlags). A class with real geometry overrides this, so the stand-in is never built for one that has geometry.
GetSurfaceVelocity(Vector3)
The velocity of this entity's surface at a world position: linear plus the angular sweep.
public Vector3 GetSurfaceVelocity(Vector3 at)Parameters
at Vector3
Returns
HasSpawnFlags<TSpawnFlags>(TSpawnFlags)
Tests whether any of the given spawnflags bits are set. Each entity class declares its flags as a FlagsAttribute enum backed by uint.
public bool HasSpawnFlags<TSpawnFlags>(TSpawnFlags flags) where TSpawnFlags : struct, EnumParameters
flags TSpawnFlags
Returns
bool
Type Parameters
TSpawnFlags
The entity class's spawnflags enum.
InputFireUser1(EntityInputData)
Fires the OnUser1 output; every entity answers FireUser1.
[EntityInput("FireUser1")]
protected void InputFireUser1(EntityInputData data)Parameters
data EntityInputData
InputFireUser2(EntityInputData)
Fires the OnUser2 output.
[EntityInput("FireUser2")]
protected void InputFireUser2(EntityInputData data)Parameters
data EntityInputData
InputFireUser3(EntityInputData)
Fires the OnUser3 output.
[EntityInput("FireUser3")]
protected void InputFireUser3(EntityInputData data)Parameters
data EntityInputData
InputFireUser4(EntityInputData)
Fires the OnUser4 output.
[EntityInput("FireUser4")]
protected void InputFireUser4(EntityInputData data)Parameters
data EntityInputData
InputKill(EntityInputData)
Removes the entity from the world.
[EntityInput("Kill")]
protected void InputKill(EntityInputData data)Parameters
data EntityInputData
JumpTo(Vector3, Vector3)
Jumps to a pose in the move parent frame without interpolating across, like a teleport.
protected void JumpTo(Vector3 origin, Vector3 angles)Parameters
origin Vector3
angles Vector3
MoveDone()
Runs when BaseEntity.MoveDoneTime comes due, after the tick's movement was applied.
public virtual void MoveDone()OnBlocked(BaseEntity)
Runs on every tick a push is blocked, after the tick's motion was taken back.
protected virtual void OnBlocked(BaseEntity blocker)Parameters
blocker BaseEntity
What the push could not move.
OnEndBlocked()
Runs on the first push that is no longer blocked.
protected virtual void OnEndBlocked()OnEndTouch(BaseEntity)
Runs on the tick other leaves this entity's volume.
protected virtual void OnEndTouch(BaseEntity other)Parameters
other BaseEntity
OnRemove()
Called as the entity leaves the world, before its nodes leave the scene. Release anything the entity started here, such as a playing sound.
protected virtual void OnRemove()OnStartBlocked(BaseEntity)
Runs on the first tick a push is blocked by blocker.
protected virtual void OnStartBlocked(BaseEntity blocker)Parameters
blocker BaseEntity
What the push could not move.
OnStartTouch(BaseEntity)
Runs on the tick other enters this entity's volume.
protected virtual void OnStartTouch(BaseEntity other)Parameters
other BaseEntity
OnTouch(BaseEntity)
Runs every tick other is inside this entity's volume, the tick it entered included, and on a tick the player ran into this solid entity while moving.
protected virtual void OnTouch(BaseEntity other)Parameters
other BaseEntity
PhysicsSimulate(float)
Integrates this tick's movement: advances BaseEntity.Origin by BaseEntity.Velocity and turns by BaseEntity.AngularVelocity.
protected virtual void PhysicsSimulate(float tickInterval)Parameters
tickInterval float
Remarks
Turning is chosen per class by BaseEntity.TurnsByAngleComponents. By default it is about the entity's own axes, so a brush authored on its side spins about its own up axis. Doors and other toggle brushes add the rate onto the QAngle components instead. The two only differ for an entity the map already rotated.
RoundStart()
Runs when the host starts a round, via EntitySystem.StartRound().
public virtual void RoundStart()SetMoveDoneTime(float)
Schedules BaseEntity.MoveDone() to run after a delay in seconds. A negative delay cancels the scheduled move.
public void SetMoveDoneTime(float delay)Parameters
delay float
SetNextThink(float)
Schedules BaseEntity.Think() to run at an absolute EntitySystem.CurrentTime in seconds; -1 stops thinking.
public void SetNextThink(float time)Parameters
time float
SetOriginAndAngles(Vector3, Vector3)
Sets origin and angles together so the transform is rebuilt once; an unchanged write does nothing.
protected void SetOriginAndAngles(Vector3 newOrigin, Vector3 newAngles)Parameters
newOrigin Vector3
newAngles Vector3
SetWorldOriginAndAngles(Vector3, Vector3)
Puts the entity at a world origin and orientation, whatever frame it moves in.
protected void SetWorldOriginAndAngles(Vector3 newOrigin, Vector3 newAngles)Parameters
newOrigin Vector3
newAngles Vector3
SnapInterpolation()
Drops the interpolation history, so the entity is drawn at its current state instead of sliding there. Call it after a teleport or any other jump that is not movement.
protected void SnapInterpolation()Spawn()
Sets up the entity (model, class keyvalues, first think). Called once its spawn group has created all of its entities, after its move parent has spawned.
public virtual void Spawn()Remarks
An override calls this first: it builds the node from BaseEntity.CreateRootNode() and snaps the entity onto its parent's attachment, which the rest of the override reads.
Teleport(Vector3, Vector3?)
Moves the entity outright rather than by travelling there. Null angles keep the current ones.
public virtual void Teleport(Vector3 origin, Vector3? angles)Parameters
origin Vector3
angles Vector3?
Think()
Runs when BaseEntity.NextThink comes due.
public virtual void Think()TryGetTouchBounds(out Vector3, out Vector3)
Reports the box this entity occupies for touch tests, by default the world bounds of its collision shape. Without a shape it occupies no space and cannot be touched.
public virtual bool TryGetTouchBounds(out Vector3 center, out Vector3 halfExtents)Parameters
center Vector3
halfExtents Vector3
Returns
bool
true when this entity occupies space.
Remarks
A box rather than the real shape, because that is what trigger volumes test against.
TurnBody(Vector3, Vector3)
Turns a QAngle by a delta given in the body's own frame, and reports where that lands as a QAngle.
protected static Vector3 TurnBody(Vector3 from, Vector3 bodyDelta)Parameters
from Vector3
bodyDelta Vector3
Returns
UpdateColliderTransform()
Moves the collision shape onto the entity's current tick state.
protected void UpdateColliderTransform()Remarks
Collision uses the tick state, not the interpolated one drawn this frame. The transform is rigid, without BaseEntity.EntityScale, because the shape's sweeps assume distances do not change in its local space.
UpdateRenderTransform(float)
Rebuilds BaseEntity.Transform for drawing, somewhere between the last two ticks.
protected virtual void UpdateRenderTransform(float fraction)Parameters
fraction float
Remarks
Drawing between the two most recent tick states instead of the newest renders slightly in the past but stays smooth at any framerate. Angles slerp along the shortest arc. Only what is drawn changes; the tick state stays authoritative.
UpdateTransform()
Rebuilds BaseEntity.Transform from the current scale, angles, and origin.
protected void UpdateTransform()Use(BaseEntity?)
Runs when something presses this entity. Use type and value are not distinguished.
public virtual void Use(BaseEntity? activator)Parameters
activator BaseEntity?

