Class EntitySystem
Namespace: ValveResourceFormat.Renderer.Entities
Assembly: Renderer.dll
The entity context for a : the world every simulated entity lives in. It owns the list of living entities, runs them on a fixed tick, and carries the entity I/O queue between them.
public sealed class EntitySystemInheritance
Remarks
Entities tick at rather than once per rendered frame. A frame runs as many ticks as it owes, up to , so a hitch cannot leave the world simulating for longer than it takes to draw.
Constructors
EntitySystem(Scene)
Initializes an entity system for a scene. Prefer over constructing one directly; a scene has exactly one world.
public EntitySystem(Scene scene)Parameters
scene Scene
Fields
MaxTicksPerFrame
The most ticks one frame may run before the leftover time is dropped.
public const int MaxTicksPerFrame = 8Field Value
TickInterval
The fixed simulation tick, matching the engine's default 64 tick.
public const float TickInterval = 0.015625Field Value
Properties
CurrentTime
Gets the current simulation time in seconds, the engine's curtime.
public float CurrentTime { get; }Property Value
Enabled
Gets or sets whether the world is simulated. Switching it off holds every entity where it stands: the ticks stop, so nothing thinks, moves, touches, or fires entity I/O. What is already spawned stays in the scene and stays drawn.
public bool Enabled { get; set; }Property Value
Entities
Gets every living entity, in spawn order.
public IReadOnlyList<BaseEntity> Entities { get; }Property Value
FileLoader
Gets the loader entities use to pull their models and physics.
public IFileLoader FileLoader { get; }Property Value
InterpolationFraction
Gets how far the current frame sits between the last two simulated ticks, in [0, 1). Entities interpolate their render transform across that span so movement is smooth at any framerate rather than stepping at the tick rate.
public float InterpolationFraction { get; }Property Value
Logger
Gets the logger for entity problems.
public ILogger Logger { get; }Property Value
Player
Gets the player, once one has been spawned into this world.
public PlayerEntity? Player { get; }Property Value
Scene
Gets the scene the entities render into.
public Scene Scene { get; }Property Value
TickCount
Gets the number of ticks simulated so far.
public int TickCount { get; }Property Value
Methods
Activate()
Runs on every entity, once the whole map has spawned.
public void Activate()Clear()
Drops every entity and resets the clock. The scene nodes themselves are the scene's to clean up; this is what calls once it has done that.
public void Clear()CreateEntity(Entity, Matrix4x4, string?)
Creates the entity for a map entity's keyvalues and puts it in the world. Returns null when the classname is not one the entity system implements, in which case the caller keeps ownership of it.
public BaseEntity? CreateEntity(EntityLump.Entity data, Matrix4x4 parentTransform, string? layerName)Parameters
data EntityLump.Entity
parentTransform Matrix4x4
layerName string?
Returns
The spawned entity, or null if the classname is not implemented.
FindAllByTargetName(string)
Finds every entity whose targetname matches.
public IEnumerable<BaseEntity> FindAllByTargetName(string pattern)Parameters
pattern string
Returns
FindTargets(EntityIOTarget, BaseEntity?, BaseEntity?)
Resolves what an authored connection addresses: the ! names that stand for an entity in the firing chain, then names and classnames.
public IEnumerable<BaseEntity> FindTargets(EntityIOTarget target, BaseEntity? activator = null, BaseEntity? caller = null)Parameters
target EntityIOTarget
activator BaseEntity?
caller BaseEntity?
Returns
The entities the target stands for, which may be none.
QueueInput(BaseEntity, string, string?, BaseEntity?, BaseEntity?, float)
Fires an entity I/O input at one entity, after a delay in seconds.
public void QueueInput(BaseEntity target, string inputName, string? parameter = null, BaseEntity? activator = null, BaseEntity? caller = null, float delay = 0)Parameters
target BaseEntity
inputName string
parameter string?
activator BaseEntity?
caller BaseEntity?
delay float
QueueInputByTargetName(string, string, string?, BaseEntity?, BaseEntity?, float)
Fires an entity I/O input at every entity whose targetname matches, * and ? wildcards included, after a delay in seconds.
public void QueueInputByTargetName(string targetName, string inputName, string? parameter = null, BaseEntity? activator = null, BaseEntity? caller = null, float delay = 0)Parameters
targetName string
inputName string
parameter string?
activator BaseEntity?
caller BaseEntity?
delay float
Remove(BaseEntity)
Removes an entity from the world and takes its nodes out of the scene.
public void Remove(BaseEntity entity)Parameters
entity BaseEntity
SnapToTick(float)
Rounds a time onto the tick it lands nearest, the way the engine's TIME_TO_TICKS does.
public static float SnapToTick(float time)Parameters
time float
Returns
The time of the nearest tick.
Remarks
Scheduling to the first tick at or after the time would round every interval up: a repeating 0.1s think would run every 7 ticks instead of 6, about a sixth slow.
SpawnPlayer(IPlayerController)
Puts the player into the world, so triggers have something to touch. Replaces any player already spawned.
public PlayerEntity SpawnPlayer(IPlayerController controller)Parameters
controller IPlayerController
Returns
The player entity.
TraceAABB(Vector3, Vector3, Vector3, bool, ref TraceResult)
Sweeps an axis-aligned box against every solid entity, narrowing result to the nearest hit.
public bool TraceAABB(Vector3 from, Vector3 to, Vector3 halfExtents, bool detectStartSolid, ref Rubikon.TraceResult result)Parameters
from Vector3
to Vector3
halfExtents Vector3
detectStartSolid bool
result Rubikon.TraceResult
Returns
true when an entity produced the nearest hit.
TriggerOutput(BaseEntity, string, BaseEntity?, string?)
Fires one of an entity's authored outputs, delivering it to every connection with that name. Source's FireOutput. The value is what the output reports, for the ones that carry a reading; a connection authored with its own parameter overrides it, as in the engine.
public void TriggerOutput(BaseEntity source, string outputName, BaseEntity? activator = null, string? value = null)Parameters
source BaseEntity
outputName string
activator BaseEntity?
value string?
Update(float)
Advances the world by a rendered frame's worth of time, running whole ticks.
public void Update(float frameTime)Parameters
frameTime float

