UnderlyingAction - Ellpeck/TinyLifeExampleMod Wiki

Original URL: https://github.com/Ellpeck/TinyLifeExampleMod/wiki/UnderlyingAction

Tiny Life

TinyLife.Actions

UnderlyingAction Class

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, GameSpeed), Validate(Person) and especially OnCompleted(CompletionType) have to be called in the appropriate places.

public class UnderlyingAction

Inheritance System.Object 🡒 UnderlyingAction

Properties

UnderlyingAction.Action Property

The underlying action.
This should be initialized using Initialize(ActionType, ActionInfo, bool, bool).

public TinyLife.Actions.Action Action { get; set; }

Property Value

Action

Methods

UnderlyingAction.Initialize(ActionType, ActionInfo, bool, bool) Method

Initializes the underlying action of this action

public TinyLife.Actions.Action Initialize(TinyLife.Actions.ActionType type, TinyLife.Actions.ActionInfo info, bool automatic=false, bool force=true);

Parameters

type ActionType
The type of action to initialize

info ActionInfo
The info to pass to the action

automatic System.Boolean
Whether the action should be considered StartedAutomatically

force System.Boolean
Whether the action should be created even if CanExecute(ActionInfo, bool) returns false

Returns

Action

UnderlyingAction.OnCompleted(CompletionType) Method

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 void OnCompleted(TinyLife.Actions.Action.CompletionType type);

Parameters

type CompletionType
The completion type

UnderlyingAction.Update(GameTime, TimeSpan, GameSpeed) Method

Updates the Action, if it exists.
This action should be called at the end of Update(GameTime, TimeSpan, GameSpeed) or any derived methods.

public void Update(Microsoft.Xna.Framework.GameTime time, System.TimeSpan passedInGame, TinyLife.GameSpeed speed);

Parameters

time Microsoft.Xna.Framework.GameTime
The current game time

passedInGame System.TimeSpan
The amount of time that has passed, in game time

speed GameSpeed
The game's current speed setting

UnderlyingAction.Validate(Person) Method

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

public void Validate(TinyLife.Objects.Person person);

Parameters

person Person