Skip to main content

DeathEffect

A class in Root.Township, Alta.Creatures.

Plays a creature's death dissolve: swaps its materials for ash materials and animates them, then the server destroys the entity. Headless servers just wait out the duration.

Constructors​

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

Fields​

13 private and internal fields
MemberWhat it is
private static readonly string _AtlasingSwitchShader keyword _ATLAS turned on for atlased creatures.
private static readonly int _ColorShader property ID for _Color.
private static readonly int _ColorA1Shader property ID for _ColorA1.
private static readonly int _MainTexShader property ID for _MainTex.
private static readonly int _ProgressShader property ID for the dissolve progress.
private NetworkEntity entityThe entity the server destroys when the effect ends.
private bool isAtlasedWhether the ash materials use the atlas shader keyword.
private DeathEvent onEndRaised when the effect finishes.
private DeathEvent onStartRaised when the effect starts, after the delay.
private RendererGroup renderersRenderers that dissolve.
private DeathAnimationSettings settingsDeath animation settings: ash material and duration.
private float startDelaySeconds to wait before the effect starts.
private Dictionary<Material, Material> uniqueMaterialsAsh material made for each original material.

Methods​

MemberWhat it is
void PlayAnimation()On non-headless builds, gives each enabled renderer ash materials, grows skinned bounds and turns off shadows, then starts the animation.
3 private and internal methods
MemberWhat it is
private IEnumerator Animation() (iterator)Coroutine: waits the start delay, raises onStart, animates progress over the duration, destroys the entity on the server and raises onEnd.
private Texture GetMaterialFromColor(Material original)Makes a texture from a material's _Color or _ColorA1, or a blank one with a warning.
private void SetMaterial(Material original, Material newMaterial)Copies the original material's main texture (or a colour texture) onto the ash material.