Skip to main content

TriggerZone

A class in Root.Township, ATT.Triggers.

Client: a box zone that fires its zone events when the local player leaves it (or teleports through it, or logs out inside it), passing how long they were inside.

Constructors​

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

Fields​

5 private and internal fields
MemberWhat it is
private int enterTimeStampInSecondsReal time the player entered, in whole seconds.
private Bounds localBoundsThe zone box in local space.
private ZoneEvent[] onExitTriggersZone events fired on exit.
private TriggerEventData triggerEventDataData (such as the event name) passed to the zone events.
private bool wasPlayerInsideZoneWhether the player was inside at the last position change.

Methods​

MemberWhat it is
void OnTriggerTeleportedThrough(IPlayer _)Fires the exit events when a teleport passes through the zone.
10 private and internal methods
MemberWhat it is
private void ActivateExitEvent()Fires every exit trigger with the event data and time spent, then clears the entry time.
private bool CheckInside(Vector3 worldPosition)True if a world position is inside the local bounds.
private int GetDuration()Seconds since the player entered, or 0 if no entry was recorded.
private void LoggedOut()Fires the exit events if the player was inside.
private void OnDisable()Unhooks the player, position and logout listeners.
private void OnDrawGizmosSelected()Draws the zone box in the editor.
private void OnEnable()Hooks the local player now, or when it is set.
private void OnLocalPlayerSet(PlayerController playerController)Listens to the local player's position changes and to logout.
private void OnPlayerPositionChanged(PlayerController playerController, Vector3 oldPosition, Vector3 newPosition, LocomotionFunction function)Records the entry time on entering and fires the exit events on leaving.
private void SetEntryTimeStamp()Stores the current real time as the entry time.