Skip to main content

DurabilityStateChangeEffect

A class in Root.Township, the global namespace.

Pooled client effect that copies an item's mesh and plays a shader cut animation on it, with optional particles, when durability state changes. Spawned by DurabilityGlobalSettings.GetEffect.

Constructors​

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

Fields​

12 private and internal fields
MemberWhat it is
private static readonly int _ProgressShader property ID for _Progress.
private static readonly int _TriCutShader property ID for _TriCut.
private PooledObjectDefinition androidParticleDefinitionParticle definition meant for Android; it took over the old serialized particleDefinition data but is not read by this code.
private DurationCurve animationProgressDuration (and curve) of the animation.
private Coroutine animationRoutineThe running animation coroutine.
private Material currentMaterialThis effect's own material copy.
private MeshFilter filterToSetMesh filter that receives the copied mesh.
private PooledObjectDefinition particleDefinitionPooled particles spawned during the animation.
private float particleEffectDelayProgress (0 to 1) at which the particles spawn.
private PooledParticleSystemMeshEmision particleSystemThe particles spawned for this play.
private AnimationCurve progressToFullnessCurve from progress to the _TriCut value.
private MeshRenderer rendererToAnimateRenderer whose material is animated.

Properties​

1 private and internal property
MemberWhat it is
private PooledObjectDefinition ParticleDefinition { get; }The particle definition in use; always particleDefinition, never the Android one.

Methods​

MemberWhat it is
override void Release()Stops the animation early and returns the effect to the pool.
void SetMesh(Renderer renderer)Copies the mesh from the given renderer's mesh filter.
7 private and internal methods
MemberWhat it is
private IEnumerator Animate() (iterator)Coroutine that drives the shader progress over the curve's duration, spawns particles part way, then releases itself.
private void Awake()Makes a tracked copy of the material and hooks the pool's requested and released events.
private void CleanUp(PooledObject pooledObject)On release, releases the spawned particle system.
private void GetParticles()Spawns the pooled mesh particle system here and gives it the animated mesh.
private void OnRequested(PooledObject pooledObject)Starts the animation when the object is taken from the pool.
private void OnValidate()Empty.
private void SetMaterial(float progress)Sets the shader's _Progress and _TriCut values for a progress.