Class ActionBehavior
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(BehaviorAction)
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(BehaviorAction containingAction)
Parameters
containingActionBehaviorActionThe action that this behavior is acting upon
Fields
ContainingAction
The action that this behavior is acting upon
protected readonly BehaviorAction ContainingAction
Field Value
Properties
FullyInProgress
Whether this action behavior is fully in progress. By default, this is the same as TinyLife.Actions.BehaviorAction.BaseFullyInProgress, which is the fully in progress state of the underlying action.
public virtual bool FullyInProgress { get; }
Property Value
InProgressTime
The amount of time that this action behavior is in progress. By default, this is the same as the TinyLife.Actions.BehaviorAction.BaseInProgressTime, which is the time that the underlying action is in progress.
public virtual TimeSpan InProgressTime { get; }
Property Value
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 Action.CanMultitaskResult CanMultitask(Action other)
Parameters
otherActionThe action to multi-task with
Returns
- Action.CanMultitaskResult
Whether this action can be multi-tasked
CreateDefaultInstance(Type, Action)
Creates a default instance of the type type, using the default constructor ActionBehavior(BehaviorAction).
If the type used doesn't have a default constructor, this method throws an InvalidOperationException.
public static ActionBehavior CreateDefaultInstance(Type type, Action action)
Parameters
typeTypeThe type of the behavior to construct
actionActionThe action that is constructing this behavior
Returns
- ActionBehavior
The behavior instance constructed
Exceptions
- InvalidOperationException
Thrown if the
typedoes 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
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
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
completionCompletionTypeThe 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
completionCompletionType
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)