Skip to main content

RepeatIfHasTarget

A class in Root.Township, Alta.Intelligence.

Component that fires a prefab event at a fixed rate while its creature has a target. Server only; it disables itself on clients.

Constructors​

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

Fields​

5 private and internal fields
MemberWhat it is
private Agent agentThe creature whose target is checked.
private float baseRateBacking field for BaseRate (default 2).
private Timeline.IEntry entryThe repeating Timeline entry, or null when stopped.
private float nextTickUnused.
private AltaEvent tickedThe event invoked on each tick with a target.

Properties​

MemberWhat it is
float BaseRate { get; set; }Ticks per second. Only read in OnEnable, so a change applies the next time the component is enabled.
float RateMultiplier { get; set; }Scales the rate (default 1). Only read in OnEnable.

Methods​

MemberWhat it is
protected virtual void Tick()Invokes ticked if the creature has a target. Virtual, so subclasses can change it.
2 private and internal methods
MemberWhat it is
private void OnDisable()Stops the repeating timer.
private void OnEnable()Server: ticks once, then schedules a repeating tick on Timeline every 1 / (BaseRate x RateMultiplier) seconds. Disables itself on clients.