Skip to main content

EffectHandler

A class in Root.Township, Alta.Alchemy.

Component next to a HealthObject that receives potion and alchemy effects: poison over time, teleporting and reveal. Reach it through HealthObject.EffectHandler; players use the PlayerEffectController subclass.

Constructors​

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

Fields​

MemberWhat it is
protected bool isTeleportableFalse during the teleport cooldown.
9 private and internal fields
MemberWhat it is
private NetworkEntity entityBacking field for Entity.
private HealthObject healthBacking field for Health.
private EffectHandler.EffectTypes immuneToFlags for effects this handler ignores: poison, teleport and reveal.
private Coroutine poisonCoroutineThe running RunPoison coroutine, or null when not poisoned.
private float poisonFrequencySeconds between poison damage ticks. 1 by default.
private float poisonMultiplierPoison damage multiplier, taken from the health object's poison attack type multiplier.
private float poisonStrengthDamage per poison tick: the highest strength among active stacks. Reset to 0 when the last stack ends.
private StatManager statManagerBacking field for StatManager.
private Dictionary<EffectDefinition, ValueTuple<Queue<EffectHandler.EffectOverTimeData>, AltaCoroutine>> unitsToRegenPer effect definition, the queue of pending over-time effects and the coroutine working through it.

Properties​

MemberWhat it is
NetworkEntity Entity { get; }The NetworkEntity this handler belongs to.
HealthObject Health { get; }The health object poison damages.
int PoisonStacks { get; protected set; }How many poison effects are active. Poison stops when it reaches 0.
StatManager StatManager { get; }The stat manager that stat effects change.

Events​

MemberWhat it is
event Action OnRevealRaised by Reveal. Phantoms listen to it to become visible.

Methods​

MemberWhat it is
virtual void PoisonOverTime(float strength)A positive strength adds a poison stack (damage each second at the strongest strength so far); zero or less removes one.
virtual void Reveal()Raises OnReveal, unless immune to reveal.
virtual void Teleport(Vector3 position, float strength, EffectHandler.TeleportType teleportType = 0)Moves the object to a position (the move happens on the server), then blocks further teleports for 2 seconds. Ignored if immune.
protected IEnumerator TeleportCooldown() (iterator)Coroutine that re-enables teleporting after 2 seconds.
4 private and internal methods
MemberWhat it is
internal void EffectOverTime(EffectDefinition effectToModify, float strength, int duration, Action<EffectHandler, EffectDefinition, float> handleUpdate)Queues an effect that applies its strength spread over duration seconds, starting the loop for that effect if needed.
private IEnumerator EffectOverTimeLoop(Queue<EffectHandler.EffectOverTimeData> queue) (iterator)Coroutine that works through queued over-time effects one at a time, ticking once a second.
private IEnumerator RunPoison() (iterator)Coroutine that deals poison damage every poisonFrequency seconds while health is above 0.
private void Start()Reads the health object's poison multiplier into poisonMultiplier.

Used in​

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