Skip to main content

PooledFireEffect

A class in Root.Township, the global namespace.

Client: the pooled fire visual for a heat source: particles plus a platform light that fades in when lit and dies down on release.

Constructors​

MemberWhat it is
PooledFireEffect()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

17 private and internal fields
MemberWhat it is
private List<GameObject> aditionalParticleSystemsExtra particle copies made for a FireDissolve's other renderers.
private float baseIntensityThe light's intensity from the prefab.
private Dictionary<ParticleSystem, ParticleSystemShapeType> baseShapesEach particle system's original shape type, restored when not on a FireDissolve.
private FireSettings currentSettingsThe fire settings from the last heat source.
private bool hasModifiedShapesTrue once particle shapes have been changed for a FireDissolve.
private bool isLitBacking field for IsLit.
private bool isWarmedUpBacking field for IsWarmedUp.
private AnimationCurve lightEndMultiplierCurve for the light fading out.
private AnimationCurve lightStartMultiplierCurve for the light fading in.
private Coroutine litCoroutineThe running FadeLight coroutine.
private float multiplierBacking field for Multiplier.
private UnityEvent OnReleasedUnity event run when the effect is released.
private UnityEvent OnRequestedUnity event run when the effect is taken from the pool.
private Transform particlesParentParent of the fire's particle systems.
private Dictionary<ParticleSystem, Vector2> systemsInitialSystemsEach particle system's starting emission rate and start size.
private PlatformLight targetThe light the effect controls.
private float unmultipliedIntensityLight intensity before Multiplier is applied.

Properties​

MemberWhat it is
float Duration { get; private set; }The longest particle start lifetime, used as the fade out time on release.
bool IsLit { get; set; }Setting it to true plays the particles and fades the light in. Setting false only stores the value.
bool IsWarmedUp { get; set; }Turns prewarm on or off for all the particle systems.
float Multiplier { get; set; }Light intensity multiplier. Setting it updates the light at once.

Methods​

MemberWhat it is
override void Release()Stops emitting, runs OnReleased and starts DelayRelease instead of releasing at once.
void UpdateMultiplier(float multiplier)Scales every particle system's emission rate and start size from their starting values.
void UpdateProgress(float progress)Changes light brightness and particle scale from the fire settings' curves at a burn progress.
virtual void UpdateSettings(HeatSourceBase heatSource)Applies a heat source's fire settings to the light and particles. For a FireDissolve, copies the particles onto each of its renderers.
9 private and internal methods
MemberWhat it is
private void ApplySystemsShape(Transform parent, MeshRenderer renderer)Makes every particle system under a transform emit from a mesh renderer's shape.
private void Awake()Records each particle system's emission rate, size, shape and longest lifetime, and turns the light off.
private IEnumerator DelayRelease() (iterator)Coroutine that fades the light out, waits for particles to finish, then returns the effect to the pool.
private IEnumerator FadeLight() (iterator)Coroutine that runs the light along the start curve (or end curve when unlit) from its current level.
private float FindClosestTime(AnimationCurve curve, float value, int steps)Finds the time on a curve whose value is closest to a target, in a set number of steps.
private void OnDisable()Empty.
private void Play()Plays every particle system.
private void RequestedStart(PooledObject pooledObject)Turns the component on and runs OnRequested when taken from the pool.
private void Reset()Sets the multiplier to 1 and turns the light off.

Used in​

Members of other types that take, return or hold a PooledFireEffect: