Table of Contents

Class ActionBehavior

Namespace
TinyLife.Actions.Behaviors
Assembly
Tiny Life.dll

An action behavior is a generic, non-serialized set of things that a PersonLike does throughout an action. This class is intended to be used with BehaviorAction, which is a MultiAction that makes use of a behavior. Note that action behaviors do not have the DataContractAttribute, which means they are not saved to disk. This differentiates them from the various action handlers in TinyLife.Actions.Handlers.

public abstract class ActionBehavior
Inheritance
ActionBehavior
Derived
Inherited Members
Extension Methods

Constructors

ActionBehavior(Action)

Creates a new action behavior with the given underlying action. To create an action behavior of a given type automatically, use CreateDefaultInstance(Type, Action).

protected ActionBehavior(Action action)

Parameters

action Action

The action that this behavior is acting upon

Fields

Action

The action that this behavior is acting upon

protected readonly Action Action

Field Value

Action

Properties

FullyInProgress

Returns whether this action behavior is fully in progress. This is the action behavior version of FullyInProgress.

public virtual bool FullyInProgress { get; }

Property Value

bool

Methods

CanMultitask(Action)

Return true on this method if this action can be multi-tasked along with the passed Action. A multi-tasking is an action that is currently active along with another action. By default, multi-tasking is disallowed for any action.

public virtual bool CanMultitask(Action other)

Parameters

other Action

The action to multi-task with

Returns

bool

Whether this action can be multi-tasked

CreateDefaultInstance(Type, Action)

Creates a default instance of the type type, using the default constructor ActionBehavior(Action). If the type used doesn't have a default constructor, this method throws an InvalidOperationException.

public static ActionBehavior CreateDefaultInstance(Type type, Action action)

Parameters

type Type

The type of the behavior to construct

action Action

The action that is constructing this behavior

Returns

ActionBehavior

The behavior instance constructed

Exceptions

InvalidOperationException

Thrown if the type does not have a default constructor

CreateFirstActions()

Creates a set of actions that should be executed before the main Action starts. This method is automatically called when using BehaviorAction in CreateFirstActions().

public abstract IEnumerable<Action> CreateFirstActions()

Returns

IEnumerable<Action>

CreateLastActions()

Creates a set of actions that should be executed after the main Action finished. This method is automatically called when using BehaviorAction in CreateLastActions().

public virtual IEnumerable<Action> CreateLastActions()

Returns

IEnumerable<Action>

GetIconObject()

Returns this action behavior's icon object. This method is automatically called when using BehaviorAction in GetIconObject(). By default, this method returns the underlying ActionInfo's GetActionObject<T>(bool).

public virtual MapObject GetIconObject()

Returns

MapObject

The icon object

GetNextAction(CompletionType)

Returns the action that should be executed after this action behavior's underlying Action completes. This method is automatically called when using BehaviorAction in GetNextAction(CompletionType).

public virtual Action GetNextAction(CompletionType completion)

Parameters

completion CompletionType

The underlying action's completion type

Returns

Action

The action that should be executed next, or null

Initialize()

Initializes this action behavior. This method is automatically called when using BehaviorAction in AndThenInitialize().

public virtual void Initialize()

OnCompleted(CompletionType)

Causes any activities that this action behavior executes to be marked as completed. This method is automatically called when using BehaviorAction in OnCompleted(CompletionType).

public virtual void OnCompleted(CompletionType completion)

Parameters

completion CompletionType

Update(GameTime, TimeSpan, float)

Updates this action behavior every update frame. This method is automatically called when using BehaviorAction in AndThenUpdate(GameTime, TimeSpan, float).

public virtual void Update(GameTime time, TimeSpan passedInGame, float speedMultiplier)

Parameters

time GameTime

The game time

passedInGame TimeSpan

The amount of time that has passed since the last update frame

speedMultiplier float

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