Class DeferredAction
A deferred action is an Action that, when started, invokes an underlying action using UnderlyingActionHandler. This is useful for situations where a MultiActionHandler would construct an action prematurely, before its ActionInfo is properly available.
public abstract class DeferredAction : Action, IGenericDataHolder
- Inheritance
-
JsonTypeSafeGenericDataHolderDeferredAction
- Implements
-
IGenericDataHolder
- Inherited Members
-
JsonTypeSafeGenericDataHolder.GetDataKeys()
- Extension Methods
Constructors
DeferredAction(ActionInfo)
Creates a new typeless action with the given action information.
protected DeferredAction(ActionInfo info)
Parameters
info
ActionInfoThe information for this action.
DeferredAction(ActionType, ActionInfo)
Creates a new action with the given action information.
protected DeferredAction(ActionType type, ActionInfo info)
Parameters
type
ActionTypeThe type for this action.
info
ActionInfoThe information for this action.
Properties
Action
The action that this deferred action is currently executing.
public Action Action { get; }
Property Value
FullyInProgress
Returns whether this action is currently "properly" in progress. This is used by MultiAction and SocialAction and returns true only once the first actions are completed or the conversation has started, respectively. By default, this property is true if InProgressTime is greater than Zero.
public override bool FullyInProgress { get; }
Property Value
- bool
Whether this action is fully in progress
InProgressTime
Represents the amount of time that this action has "properly" been in progress for. This is used by MultiAction and SocialAction and returns true only once the first actions are completed or the conversation has started, respectively. By default, ElapsedTime is returned.
public override TimeSpan InProgressTime { get; }
Property Value
- TimeSpan
The amount of time that this action has properly been in progress for
Methods
CanMultitask(Action)
Return true on this method if this action can be multi-tasked along with the passed Action. To actually check this property, CanMultitask(Action, Action) should be used as it compares both objects. A multi-tasking is an action that is currently active along with another action. By default, multi-tasking is disallowed for any action.
public override bool CanMultitask(Action other)
Parameters
other
ActionThe action to multi-task with
Returns
- bool
Whether this action can be multi-tasked
CreateAction()
Creates the action that this DeferredAction should execute. This method is called in Initialize().
protected abstract Action CreateAction()
Returns
- Action
The action to execute.
Initialize()
This method is called when the action is first started by a Person. Note that it is not called when the action gets added to the ActionQueue, but when it is moved to CurrentActions.
public override void Initialize()
IsCompleted()
This method is called every update frame by a Person if this action is currently active to check if it should be stopped. If this returns a result other than Completed, OnCompleted(CompletionType) will be called and the action is stopped. By default, only ForceResult modifies the completion type, otherwise Active is returned.
public override CompletionType IsCompleted()
Returns
- CompletionType
The current completion type of this action
OnCompleted(CompletionType)
This method is called when this action IsCompleted(), or if it is canceled from an outside source. Note that, if this method is called as a result of IsCompleted(), the CompletionType passed will be the same. By default, only OnActionCompleted(Action, CompletionType, bool) is called.
public override void OnCompleted(CompletionType type)
Parameters
type
CompletionTypeThe type that this action completed with
Update(GameTime, TimeSpan, float)
This method is called every update frame if this action is currently active. By default, only the ElapsedTime is modified in this method and ActionUpdate(Action, GameTime, TimeSpan, float, bool) is called.
public override void Update(GameTime time, TimeSpan passedInGame, float speedMultiplier)
Parameters
time
GameTimeThe current game time
passedInGame
TimeSpanThe amount of time that has passed, in game time
speedMultiplier
floatThe game speed multiplier, which represents how fast things should happen, which is usually determined by Speed
Validate(PersonLike, AppliedMigrations)
Validates this action's data. This is called when a map is loaded from disk. When returning false on this method, the action is removed from the Person.
public override bool Validate(PersonLike person, AppliedMigrations appliedMigrations)
Parameters
person
PersonLikeThe person that this action belongs to
appliedMigrations
AppliedMigrationsThe migrations that have been applied so far
Returns
- bool
Whether or not the action is still valid (or if it has invalid data)