Class UnderlyingActionHandler
An UnderlyingAction is a class that can instantiate a single Action that will be executed as part of the action it is used in. Note that, when using this class, Update(GameTime, TimeSpan, float), Validate(Action, PersonLike, AppliedMigrations) and especially OnCompleted(CompletionType) have to be called in the appropriate places.
[DataContract]
public class UnderlyingActionHandler
- Inheritance
-
UnderlyingActionHandler
- Inherited Members
- Extension Methods
Constructors
UnderlyingActionHandler(Action)
Creates a new UnderlyingActionHandler with the given containing action.
public UnderlyingActionHandler(Action containingAction)
Parameters
containingAction
ActionThe action that contains this underlying action handler.
Properties
Action
The underlying action. This should be initialized using Initialize<T>(ActionType, ActionInfo, bool).
[DataMember]
public Action Action { get; }
Property Value
Methods
InitializeExact(Action)
Initializes the underlying action of this action using the given Action. If CanExecuteAction(ActionType, ActionInfo, bool) should be tested, Initialize<T>(ActionType, ActionInfo, bool) can be used instead.
public void InitializeExact(Action action)
Parameters
action
ActionThe action to initialize
Initialize<T>(ActionType, ActionInfo, bool)
Initializes the underlying action of this action
public T Initialize<T>(ActionType type, ActionInfo info, bool force = true) where T : Action
Parameters
type
ActionTypeThe type of action to initialize
info
ActionInfoThe info to pass to the action
force
boolWhether the action should be created even if CanExecuteAction(ActionType, ActionInfo, bool) returns false
Returns
- T
Type Parameters
T
IsCompleted()
Returns whether the current Action is completed, or returns Completed if there is no current or previously executed action.
public CompletionType IsCompleted()
Returns
- CompletionType
Whether this underlying action handler is completed.
OnCompleted(CompletionType)
Calls this underlying action's OnCompleted(CompletionType) method. This should be called for any completion type that the action that uses this underlying action experiences, even Canceled and Failed. If the underlying action is null or already completed, this method has no effect.
public bool OnCompleted(CompletionType type)
Parameters
type
CompletionTypeThe completion type
Returns
- bool
Whether the completion type was consumed by this underlying action handler
Update(GameTime, TimeSpan, float)
Updates the Action, if it exists. This action should be called at the end of Update(GameTime, TimeSpan, float) or any derived methods.
public 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(Action, PersonLike, AppliedMigrations)
Validates this action container and its Action. This method should be called in Validate(PersonLike, AppliedMigrations).
public bool Validate(Action containingAction, PersonLike person, AppliedMigrations appliedMigrations)
Parameters
containingAction
ActionThe action that contains this underlying action handler.
person
PersonLikeThe person that is passed to the
containingAction
's Validate(PersonLike, AppliedMigrations) method.appliedMigrations
AppliedMigrationsThe set of migrations that have already been applied on this object.
Returns
- bool
Whether this underlying action handler is still valid.