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
type
ActionTypeThe type for this action.
info
ActionInfoThe information for this action.
Fields
Reason
The reason of death
[DataMember]
public DeathReason Reason
Field Value
Methods
CanCancel(Action)
Returns whether or not this action can be canceled by the given outside source.
Note that the outside source can be null, and if it is, it means that the player canceled the action manually.
By default, actions can only be canceled if the cancelSource
is null.
public override bool CanCancel(Action cancelSource)
Parameters
cancelSource
ActionThe source of the cancelation, or null if the player canceled it
Returns
- bool
true if the action can be canceled
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
person
PersonLikeThe person that wants to converse with us.
type
ActionTypeThe 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.
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
person
PersonLikeThe person that should die
reason
DeathReasonThe 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 ForceResult 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
type
CompletionTypeThe 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)