Class ParticleSystemSimulation
Namespace: ValveResourceFormat.Particles
Assembly: ValveResourceFormat.dll
Child systems: creation, group selection and group restarts.
public class ParticleSystemSimulationInheritance
object ← ParticleSystemSimulation
Constructors
ParticleSystemSimulation(ParticleSystem, IFileLoader, ILogger?, ParticleSnapshot?, ParticleSystemState?)
Builds a runnable system from its definition.
public ParticleSystemSimulation(ParticleSystem particleSystem, IFileLoader fileLoader, ILogger? logger = null, ParticleSnapshot? particleSnapshot = null, ParticleSystemState? parentSystemState = null)Parameters
particleSystem ParticleSystem
The system definition, read through its upgraded tree.
fileLoader IFileLoader
Resolves the child systems and snapshots the definition names.
logger ILogger?
Receives warnings about unimplemented classes and fields. Omit to run silently.
particleSnapshot ParticleSnapshot?
A snapshot to publish to the system, when it runs off one.
parentSystemState ParticleSystemState?
The state of the system running this one as a child.
Properties
BehaviorVersion
The behavior version the definition was authored against, which gates several behaviours.
public int BehaviorVersion { get; }Property Value
int
Children
The systems this one runs as children, in definition order.
public IReadOnlyList<ParticleSystemSimulation> Children { get; }Property Value
IReadOnlyList<ParticleSystemSimulation>
Definition
The upgraded definition this system was built from.
public KVObject Definition { get; }Property Value
KVObject
DepthSortBias
Units added to the camera distance the system is sorted by among translucent objects (m_flDepthSortBias). Positive values sort it as if it were further away.
public float DepthSortBias { get; }Property Value
float
IsScreenSpaceEffect
Whether the system is drawn over the screen rather than in the world (m_bScreenSpaceEffect). Its particles are laid out in a fixed view around the world origin, while its control points stay where the system is placed. Each system in a tree carries its own.
public bool IsScreenSpaceEffect { get; }Property Value
bool
LocalBoundingBox
The box containing the system's particles and those of its children, relative to its first control point. Empty at that control point while there is nothing to bound, and unbounded before the first frame.
public AABB LocalBoundingBox { get; }Property Value
MainControlPoint
Control point 0, which places the system in the world.
public ControlPoint MainControlPoint { get; set; }Property Value
MaxDrawDistanceSquared
The squared camera distance from which the system is not drawn (m_flMaxDrawDistance), or float.MaxValue when it draws at any distance. Only the root of a tree is measured, and it culls the whole tree.
public float MaxDrawDistanceSquared { get; }Property Value
float
Name
The file the system was loaded from, used in warnings.
public string Name { get; set; }Property Value
string
NoDrawTimeToGoToSleep
Seconds the system keeps simulating after it was last drawn (m_flNoDrawTimeToGoToSleep).
public float NoDrawTimeToGoToSleep { get; }Property Value
float
Observer
Set by the drawing layer watching this system, or null when nothing draws it.
public IParticleSystemObserver? Observer { get; set; }Property Value
Particles
This system's live particles.
public ParticleCollection Particles { get; }Property Value
RenderState
The state every function of this system reads it through.
public ParticleSystemState RenderState { get; }Property Value
SortOverridePositionControlPoint
Control point whose position the system is sorted by among translucent objects (m_nSortOverridePositionCP), or -1 to sort by the bounds of the system.
public int SortOverridePositionControlPoint { get; }Property Value
int
StartFadeDistanceSquared
The squared camera distance from which the system fades out, reaching zero alpha at ParticleSystemSimulation.MaxDrawDistanceSquared (m_flStartFadeDistance), or float.MaxValue when it never fades. Only the root of a tree is measured.
public float StartFadeDistanceSquared { get; }Property Value
float
Methods
FreezeChildren()
Freezes every system below this one. Operators.EndCapTimedFreeze freezes the system it runs in directly and the rest of the tree through here.
public void FreezeChildren()GetControlPoint(int)
Gets one of the system's control points.
public ControlPoint GetControlPoint(int cp)Parameters
cp int
The control point index.
Returns
HasFinishedEmitting(bool, bool)
Whether the system has run out: no emitter can create more particles and, unless emissionEndIsEnough, every particle dies within the current step. An endcap child always counts as finished. PreEmissionOperators.PlayEndCapWhenFinished tests this to decide when to start the endcap.
public bool HasFinishedEmitting(bool emissionEndIsEnough, bool includeChildren)Parameters
emissionEndIsEnough bool
includeChildren bool
Returns
bool
IsFinished()
Whether the system is done: its first frame has run, it and its children hold no particles, its clock has started, no emitter can create more, and every child is finished. An endcap child only counts once its endcap has started.
public bool IsFinished()Returns
bool
PlayEndCap()
Stops emission on the system and its children and plays the endcap.
public void PlayEndCap()PlayEndCapOnly()
Plays the endcap by itself: the system is rewound and stopped with its endcap before a particle of its own can live, so only the endcap children play.
public void PlayEndCapOnly()Replay()
Replays the system from scratch, as if it had just been created, discarding the particles still alive first. The random seed is kept, so the draws continue, and the control points keep what functions wrote to them. A pinned seed (ParticleSystemSimulation.PinRandomSeed) starts the draws over and puts those control points back.
public void Replay()Restart()
Restarts the system and its children without destroying the particles alive or rewinding the clock: functions restart their running state and the fade windows count from now. The endcap ends and instantaneous and maintain emitters resume emitting, but a frozen system stays frozen. An endcap child goes back to waiting for an endcap.
public void Restart()SetCameraPosition(Vector3)
Publishes the render camera position to this system and every child for camera-dependent particle inputs.
public void SetCameraPosition(Vector3 position)Parameters
position Vector3
SetDetailLevel(ParticleDetailLevel)
Sets the particle detail tier for this system; child systems inherit it.
public void SetDetailLevel(ParticleDetailLevel level)Parameters
level ParticleDetailLevel
SetNamedValue(string, float)
Sets a float named value on this system and every system below it. The value is read by the next simulation step; after each step the system goes back to the value it held the step before, so a value meant to hold is set again before every update.
public bool SetNamedValue(string name, float value)Parameters
name string
The named value, as the definition's m_NamedValueLocals or its inputs name it.
value float
The value.
Returns
bool
Whether this system declares the name with a type the value converts to.
SetNamedValue(string, Vector3)
Sets a float named value on this system and every system below it. The value is read by the next simulation step; after each step the system goes back to the value it held the step before, so a value meant to hold is set again before every update.
public bool SetNamedValue(string name, Vector3 value)Parameters
name string
The named value, as the definition's m_NamedValueLocals or its inputs name it.
value Vector3
The value.
Returns
bool
Whether this system declares the name with a type the value converts to.
Remarks
A transform named value takes the vector as its position, with no rotation.
SetNamedValue(string, Vector3, Quaternion)
Sets a float named value on this system and every system below it. The value is read by the next simulation step; after each step the system goes back to the value it held the step before, so a value meant to hold is set again before every update.
public bool SetNamedValue(string name, Vector3 position, Quaternion rotation)Parameters
name string
The named value, as the definition's m_NamedValueLocals or its inputs name it.
position Vector3
The transform's position.
rotation Quaternion
The transform's rotation. A vector named value takes only the position.
Returns
bool
Whether this system declares the name with a type the value converts to.
ShouldRunAsChildOf(ParticleSystemState)
Whether this child is currently allowed to run under parentState: it has started, and its detail tier is active.
public bool ShouldRunAsChildOf(ParticleSystemState parentState)Parameters
parentState ParticleSystemState
The parent system's state.
Returns
bool
Start()
Lets the system and its children emit again after a stop. Endcap children keep waiting for an endcap.
public void Start()Stop()
Stops emission on the system and its children, leaving live particles to finish. The system enters the endcap phase without starting its endcap children.
public void Stop()TryGetRenderBlend(out float)
Gets how far to blend from ParticleCollection.PreviousStep toward ParticleCollection.Current to draw the system at the time it was asked to reach. A minimum time step can carry the simulation past that time, and the blend draws it where it would have been. Particles created during the step are not drawn in the blend.
public bool TryGetRenderBlend(out float fraction)Parameters
fraction float
0 for the previous step, 1 for the current one.
Returns
bool
Whether the last step overshot and the blend applies.
Update(float, float)
Advances the system by one frame, in as many substeps as the definition's time step needs.
public void Update(float frameTime, float worldTime)Parameters
frameTime float
Seconds since the last update, scaled by ParticleSystemState.TimeScale.
worldTime float
Seconds the containing world has been running.

