ActionComponent
An abstract class in Root.Township, Alta.Intelligence.
Base for a creature action set up as a component on a creature's AI prefab. Holds the weighting and cancel rules, and builds the action with target operations found in child objects named Base Required, Base Preferred, Target Required and Target Preferred.
- Listed in Creatures and AI
- Inherits or implements
MonoBehaviour,IActionSettings - Derived types
AgentDelayEnterSetSettings,AgentDeletedSettings,AgentDisabledSettings,AgentEatSettings,AgentFaceTargetSettings,AgentMoveCloserSettings,AgentNavigationSettings,AgentRollUpInPlaceSettings,AgentSwapActionSetSettings,AiHook,RandomTimedActionComponent,SchmeecheeFleeSettings,SchmeecheeFlipSettings,SchmeecheePlaySettings,TimedActionComponent,WyrmSpinSettings - Documented in Actions and decisions
Constructors
| Member | What it is |
|---|---|
protected ActionComponent() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
14 private and internal fields
| Member | What it is |
|---|---|
private IAction action | The action built by GetStaticAction, cached so every agent shares it. |
private float baseWeightingMultiplier | Base part of Multiplier. 1 by default. |
private bool canCancelSelfWithSameTarget | Backing field for CanCancelSelfWithSameTarget. If false, picking the same action and target restarts it instead. |
private int cancelPriority | Backing field for CancelPriority. |
private float extraRandomMultiplier | When above 0, a random amount up to this is added to Multiplier each time it is read. |
private bool isAddingBasePreferred | Editor button that adds a "Base Preferred" child object. |
private bool isAddingBaseRequired | Editor button that adds a "Base Required" child object. |
private bool isAddingTargetPreferred | Editor button that adds a "Target Preferred" child object. |
private bool isAddingTargetRequired | Editor button that adds a "Target Required" child object. |
private bool isCancellable | Backing field for IsCancellable. Agents don't re-pick while running an action that can't be cancelled. |
private bool isUsed | Set the first time the action is used, when the IAiHook components on it are initialized. |
private static Logger logger | NLog logger for this class. |
private int minimumCancelPriority | Backing field for MinimumCancelPriority: lowest priority a new action needs to replace this one. |
private float minimumCancelWeighting | Backing field for MinimumCancelWeighting: lowest weighting a new action needs to replace this one. |
Properties
Events
| Member | What it is |
|---|---|
event ActionSettingsUsedHandler Used | Raised each time an active action of this component starts. |
Methods
| Member | What it is |
|---|---|
IAction GetStaticAction() | Builds the action once (with its target operations from the named child objects) and returns the cached one after that. |
void HandleUsed(IActiveAction active) | Called each time the action starts. On first use it initializes IAiHook components on the object, then raises Used. |
protected abstract IAction GetAction() | Subclasses create the IAction for this component here. |
protected virtual void OnValidate() | Empty editor hook for subclasses. |
1 private and internal method
| Member | What it is |
|---|---|
private void AddChildrenTo(string childName, List<TargetOperation> operations) | Adds the target operations from a named child object (such as "Base Required") to one of the action's operation lists. |
Used in
Members of other types that take, return or hold a ActionComponent:
Agent.DoAction, Agent<TThis>.actions, Agent<TThis>.DoAction, AgentInteractApproachSettings.canReach, AgentInteractApproachSettings.CanReach, AgentInteractApproachSettings.cantReach, AgentInteractApproachSettings.CantReach, Babu.stunnedAction, Dragonfly.stunnedAction, Dragonfly.stunnedActionMap, Gotera.stunnedAction, Gotera.stunnedActionMap, GreaterGotera.stunnedAction, GreaterGotera.stunnedActionMap, IAgent.DoAction, Phantom.actionTargetMap, Phantom.deMaterializeAction, Phantom.materializeAction, Phantom.materializedHitAction, PickupAgent.pickedUpActionComponent, Spriggull.flailAction, Turabada.stunnedAction, Turabada.stunnedActionMap.