Skip to main content

ActiveNest

A class in Root.Township, Alta.Intelligence.

Night action: the agent walks to the nearest free Nest of its type and sleeps until the time of day passes StartTired. With no nest it wanders.

Constructors​

MemberWhat it is
ActiveNest()Creates an ActiveNest with default values.

Fields​

4 private and internal fields
MemberWhat it is
private AltaCoroutine coroutineThe running CheckTimeOfDay coroutine.
private float defaultDragRigidbody drag before sleeping. Only set on arrival, so a cancel before that restores 0.
private AnimatedBool isSleepingSynced animator bool for sleeping.
private Nest nestThe nest claimed for this sleep.

Methods​

MemberWhat it is
static IAction GetAction(AgentNestSettings settings)Builds the action, with its need rising from StartTired to FullTired by time of day.
protected override void OnStart()Claims the closest nest and walks to it, or wanders if none is in range.
protected override void TargetReached()Starts sleeping: sets the animator bool and asleep sense, raises drag to 1 and starts CheckTimeOfDay.
2 private and internal methods
MemberWhat it is
private IEnumerator CheckTimeOfDay() (iterator)Coroutine that checks every 10 seconds, waits until it's no longer sleep time, then wakes, frees the nest and finishes.
private void HandleCancelled(IActiveAction action)Clears the asleep sense, restores drag, stops the coroutine and frees the nest.