Table of Contents

Class UnderlyingActionHandler

Namespace
TinyLife.Actions.Handlers
Assembly
Tiny Life.dll

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, Person) 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 Action

The 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

Action

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 Action

The 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 ActionType

The type of action to initialize

info ActionInfo

The info to pass to the action

force bool

Whether 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 CompletionType

The 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 GameTime

The current game time

passedInGame TimeSpan

The amount of time that has passed, in game time

speedMultiplier float

The game speed multiplier, which represents how fast things should happen, which is usually determined by Speed

Validate(Action, Person)

Validates this action container and its Action. This method should be called in Validate(Person).

public bool Validate(Action containingAction, Person person)

Parameters

containingAction Action

The action that contains this underlying action handler.

person Person

The person that is passed to the containingAction's Validate(Person) method.

Returns

bool

Whether this underlying action handler is still valid.