IAgent
An interface in Root.Township, Alta.Intelligence.
The interface for an AI creature's brain, implemented by Agent. Decisions and actions run on the server; the server registers live agents with AgentUpdater.
- Listed in Creatures and AI
- Inherits or implements
ITarget,ITargetPointer,INetworkEntityBehaviour - Derived types
Agent,Babu,GreaterGotera,IInteractAgent,Spriggull
Properties
| Member | What it is |
|---|---|
float ActionDuration { get; } | Seconds since the current action was started (or last restarted). |
IActiveAction ActiveAction { get; } | The action the agent is running now, or null when idle. |
ColliderGroup Collision { get; } | The collider group for the creature's body. |
float CreationTime { get; } | Server: Time.time when the agent was initialised on the server. |
Director Director { get; } | The pathfinding Director used to walk, wander and face things. |
bool HasTarget { get; } | True when the current action uses a target and that target still exists. |
bool HasWalker { get; } | True when the prefab has a Walker assigned (set in the editor). |
Dictionary<ITarget, float> Hurt { get; } | How much each attacker has hurt this agent, as a fraction of max health. Decays over time; attackers are dropped when it reaches zero. |
bool IsActing { get; } | True while an action is running. |
NetworkAnimator NetworkAnimator { get; } | The synced animator for the creature. |
float NextUpdateProgress { get; } | 0 to 1 progress from the action start to the next time the agent re-decides. |
PopulationItem PopulationItem { get; } | Server: the PopulationItem on the entity's root, if it was spawned by a population. |
Rigidbody Rigidbody { get; } | The creature's main rigidbody. |
ITarget Target { get; } | The target of the current action. |
float UpdateInterval { get; } | Seconds between decision checks (default 0.1). Non-cancellable actions are not re-decided until they finish. |
Walker Walker { get; } | The Walker component that moves the creature along paths. |
Methods
| Member | What it is |
|---|---|
bool AddTarget(ITarget target) | Server: offers a target to the action decider. Returns false if it is the agent itself, already added, or still on an ignore timer from RemoveTarget. |
void CancelCurrentAction() | Cancels the running action, if any. The agent then picks a new one on its next update. |
void DoAction(ActionComponent action, ITarget target) | Starts a specific action from an ActionComponent against a target, replacing the current action. |
void FireChannelEvent(HookEventChannel channel, IActiveAction action) | Fires the UnityEvent set up for a hook channel. On the server, channels marked networked are also sent to clients in the chunk. |
void Initialize() | Network initialisation on both sides. Sets up the sync for networked channel events. |
void InitializeAsServer(SpawnData spawnData) | Server: records creation time, finds the PopulationItem, builds the AI and registers with AgentUpdater if alive. |
bool RemoveTarget(ITarget target, float duration) | Server: removes an added target. With a positive duration it instead ignores that target for that many seconds and returns false. |
void UseActionComponentSet(ActionComponentSet set) | Switches the set of possible actions the decider chooses from. |
Used in
Members of other types that take, return or hold a IAgent:
AnimatedBoolAiHook.booleans, AnimatedFloatAiHook.booleans, AnimatedFloatTransitionAiHook.floats, AnimatedLayerAiHook.weights, AttackDirectionCore.AttackDirectionCore, AttackDirectionCore.Disable, AttackDirectionCore.GetAnimation, AttackDirectionCore.Update, AttackDirectionCoreSettings.GetCore, AttackDirectionReactAIHook.actions, BasicActiveAction<TAgent>.GeneralTopic, BasicSense.Get, DistanceSense.Get, DistanceSense.GetInverseLerp, DistanceSquaredSense.Get, Facing2DSense.Get, Facing3DSense.Get, FixedStatChangeHook.addedExtras, FixedStatChangeHook.GetAffectedStat, FixedStatChangeHook.OperateOnStat, FixedStatChangeHook.RevertOperateOnStat, FixedStatChangeHook.SetAffectedStat, HookAction.HookAction, HookAction.topic, HurtSense.Get, IActiveAction.GeneralTopic, ProgressStatChangeHook.progresses, ProgressStatChangeHook.TopicProgress.TopicProgress, Sense.Get, Sense.GetInverseLerp, StatChangeHook.affectedStats, VelocitySense.Get, ViewConeSense.Get.