Table of Contents

Class FXInstanceLifetime

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

Ends the life of a one-shot FX instance spawned by PlayFXAction.

[DisallowMultipleComponent]
public sealed class FXInstanceLifetime : MonoBehaviour
Inheritance
Object
Component
Behaviour
MonoBehaviour
FXInstanceLifetime
Inherited Members
MonoBehaviour.IsInvoking()
MonoBehaviour.CancelInvoke()
MonoBehaviour.StopCoroutine(Coroutine)
MonoBehaviour.StopAllCoroutines()
MonoBehaviour.destroyCancellationToken
MonoBehaviour.useGUILayout
MonoBehaviour.didStart
MonoBehaviour.didAwake
MonoBehaviour.runInEditMode
Behaviour.enabled
Behaviour.isActiveAndEnabled
Component.GetComponent<T>()
Component.TryGetComponent<T>(out T)
Component.GetComponentInChildren<T>()
Component.GetComponentsInChildren<T>()
Component.GetComponentInParent<T>()
Component.GetComponentsInParent<T>()
Component.GetComponents<T>()
Component.GetComponentIndex()
Component.CompareTag(TagHandle)
Component.transform
Component.transformHandle
Component.gameObject
Component.tag
Object.GetEntityId()
Object.GetInstanceID()
Object.GetHashCode()
Object.InstantiateAsync<T>(T)
Object.InstantiateAsync<T>(T, Transform)
Object.InstantiateAsync<T>(T, Vector3, Quaternion)
Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion, Transform)
Object.Instantiate(Object)
Object.Instantiate(Object, Scene)
Object.Instantiate<T>(T, InstantiateParameters)
Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)
Object.Instantiate(Object, Transform)
Object.Instantiate<T>(T)
Object.Instantiate<T>(T, Vector3, Quaternion)
Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
Object.Instantiate<T>(T, Transform)
Object.Destroy(Object)
Object.DestroyImmediate(Object)
Object.DontDestroyOnLoad(Object)
Object.DestroyObject(Object)
Object.FindObjectsOfType<T>()
Object.FindObjectsByType<T>(FindObjectsSortMode)
Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
Object.FindObjectOfType<T>()
Object.FindFirstObjectByType<T>()
Object.FindAnyObjectByType<T>()
Object.FindFirstObjectByType<T>(FindObjectsInactive)
Object.FindAnyObjectByType<T>(FindObjectsInactive)
Object.FindObjectsByType<T>()
Object.FindObjectsByType<T>(FindObjectsInactive)
Object.ToString()
Object.name
Object.hideFlags

Remarks

This exists because the action used to own no part of what it spawned. Execute(ICharacter, EventData) ended at a bare Instantiate(FXPrefab, position, rotation): no parent, no owner, no end. Every effect was therefore one prefab-authoring mistake away from being permanent, and the shipped content made that mistake — Fire.prefab, played by the impact effect of Lesser Fireball, Orc Firebolt and Scroll of Flame Impact, is a looping, prewarm ambient burn with stopAction: None. A looping system with no stop action never reaches an end, and nothing else was going to end it, so each hit left one particle system behind in the world on every client that saw the hit, for the whole session (issue #258, and issue #269 once a scene change made them obvious).

What is left behind is only the visuals. No AbilityObject is involved and none is spawned by this path, which is why walking into a leftover triggers no ability events: there is nothing there to hit. That is the whole of the defect — a particle system with no one to switch it off.

The fix belongs to the action, not to the prefab. "Every FX prefab despawns itself" is a rule nothing enforces and the action cannot check, and it makes each new effect's lifetime an authoring accident. The action instead attaches this component to the instance it created, which measures what the effect needs and then destroys the instance. A prefab that already despawns itself (Explosion.prefab's stopAction: Destroy) destroys the instance first, and this component goes with it.

Fields

LifetimePadding

Added to every measurement so the effect's own last frame is not cut off.

public const float LifetimePadding = 0.5

Field Value

float

MaximumLifetime

Longest life an instance can be given.

public const float MaximumLifetime = 60

Field Value

float

Remarks

A backstop, not a target: it only has to stop a prefab that reports something absurd from holding an instance for the rest of the session.

MinimumLifetime

Shortest life an instance can be given.

public const float MinimumLifetime = 1

Field Value

float

Remarks

A floor for an effect that measures as nothing at all — no particle system, no trail. It is deliberately not zero, so that "measurement found nothing to measure" cannot itself become an instant disappearance.

Properties

Lifetime

How long this instance lives, in seconds.

public float Lifetime { get; }

Property Value

float

Methods

Attach(GameObject)

Bounds a spawned FX instance, measuring its life if it does not have one.

public static FXInstanceLifetime Attach(GameObject instance)

Parameters

instance GameObject

The instance to bound. Null is tolerated so callers can inline it.

Returns

FXInstanceLifetime

The component now bounding the instance, or null if there was no instance.