Class DieAction
An action that is invoked when a PersonLike should Die(DeathReason). All default DeathReason values are handled by this action. To enqueue this action effectively, use Enqueue(PersonLike, DeathReason).
public class DieAction : Action, IGenericDataHolder
- Inheritance
-
JsonTypeSafeGenericDataHolderDieAction
- Implements
-
IGenericDataHolder
- Inherited Members
-
JsonTypeSafeGenericDataHolder.GetDataKeys()
- Extension Methods
Constructors
DieAction(ActionType, ActionInfo)
Creates a new action with the given action information.
public DieAction(ActionType type, ActionInfo info)
Parameters
typeActionTypeThe type for this action.
infoActionInfoThe information for this action.
Fields
Reason
The reason of death
[DataMember]
public DeathReason Reason
Field Value
Methods
CanActionInterrupt(Action)
Determines whether the given action can interrupt this action.
If this method returns true, it is usually followed by a call to Interrupt(CompletionType). To call this method effectively, use ActionInterruptAction(Action, Action, CompletionType, bool).
This method returns false by default, and MultiAction returns true only if the main action has not yet started.
public override bool CanActionInterrupt(Action action)
Parameters
actionActionThe action trying to interrupt this action.
Returns
- bool
Whether the action can interrupt this action.
CanEnqueueConversation(PersonLike, ActionType)
Returns true if the given person can (automatically) enqueue a social action with the Person that is executing this action.
Note that enqueueing a social action manually is still possible even if this method returns false.
By default, only TinyLife.Actions.SleepAction returns false on this method.
public override bool CanEnqueueConversation(PersonLike person, ActionType type)
Parameters
personPersonLikeThe person that wants to converse with us.
typeActionTypeThe type of action that should be enqueued. Might be null, in which case a generic or unknown action is querying this function.
Returns
- bool
Whether or not enqueueing a social action is possible.
CanGenericInterrupt(bool)
Determines whether this action can be interrupted by a generic interruption source. If this method returns true, it is usually followed by a call to Interrupt(CompletionType). To call this method effectively, use GenericInterruptAction(Action, bool, CompletionType, bool). This method returns true by default.
public override bool CanGenericInterrupt(bool isPlayer)
Parameters
isPlayerboolWhether the generic interruption source is the player.
Returns
- bool
Whether a generic interruption source can interrupt this action.
Enqueue(PersonLike, DeathReason)
Enqueues a DieAction for the given PersonLike. The enqueued action receives priority, and all other current actions are canceled.
public static void Enqueue(PersonLike person, DeathReason reason)
Parameters
personPersonLikeThe person that should die
reasonDeathReasonThe reason for their death
GetDisplayName()
Returns a localized string that explains this action in short. By default, this method returns GetDisplayName(ActionInfo, bool).
public override string GetDisplayName()
Returns
- string
This action's display name
Initialize()
This method is called when the action is first started by a Person. Note that it is not called when the action gets added to the ActionQueue, but when it is moved to CurrentActions.
public override void Initialize()
IsCompleted()
This method is called every update frame by a Person if this action is currently active to check if it should be stopped. If this returns a result other than Completed, OnCompleted(CompletionType) will be called and the action is stopped. By default, only the default behavior of Interrupt(CompletionType) modifies the completion type, otherwise Active is returned.
public override CompletionType IsCompleted()
Returns
- CompletionType
The current completion type of this action
OnCompleted(CompletionType)
This method is called when this action IsCompleted(), or if it is canceled from an outside source. Note that, if this method is called as a result of IsCompleted(), the CompletionType passed will be the same. By default, only OnActionCompleted(Action, CompletionType, bool) is called.
public override void OnCompleted(CompletionType type)
Parameters
typeCompletionTypeThe type that this action completed with
Update(GameTime, TimeSpan, float)
This method is called every update frame if this action is currently active. By default, only the ElapsedTime is modified in this method and ActionUpdate(Action, GameTime, TimeSpan, float, bool) is called.
public override void Update(GameTime time, TimeSpan passedInGame, float speedMultiplier)