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
| Member | What it is |
|---|
ActiveNest() | Creates an ActiveNest with default values. |
Fields
4 private and internal fields
| Member | What it is |
|---|
private AltaCoroutine coroutine | The running CheckTimeOfDay coroutine. |
private float defaultDrag | Rigidbody drag before sleeping. Only set on arrival, so a cancel before that restores 0. |
private AnimatedBool isSleeping | Synced animator bool for sleeping. |
private Nest nest | The nest claimed for this sleep. |
Methods
| Member | What 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
| Member | What 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. |