Element Effect
Last updated
Last updated
ElementEffect
public List<Effect> effects
: Represents the current list of effects applied to the element.
public ElementEffect(ElementWorker elementWorker)
: Initializes a new instance of the ElementEffect
class, assigning the ElementWorker
public void OnUpdate()
: Calls e ApplyEffects
method at each frame.
public void ApplyEffects()
: Iterates through each Effect
in the effects
list and applies it. This method ensures that each effect exerts its influence on the ElementWorker
. The application of effects is done by calling the Apply
method on each Effect
instance.
public void AddEffect(Effect effect)
: Adds a new Effect
to the effects
list. If the Effect
is null, the method returns early. After adding the Effect
to the list, it initiates a coroutine, RemoveEffect
, which will automatically remove the Effect
from the list once its duration (defined by effect.time
) is completed.
public IEnumerator RemoveEffect(Effect effect)
: A coroutine that waits for the duration of the Effect
(effect.time
) before removing it from the effects
list. This ensures that each effect only lasts for its intended duration.