DieAction - Ellpeck/TinyLifeExampleMod Wiki

Tiny Life


DieAction Class

An action that is invoked when a Person should Die(DeathReason, bool).
All default DeathReason values are handled by this action.
To enqueue this action efficiently, use Enqueue(Person, DeathReason).

public class DieAction : TinyLife.Actions.Action

Inheritance System.Object 🡒 MLEM.Misc.GenericDataHolder 🡒 Action 🡒 DieAction


DieAction.DieAction(ActionType, ActionInfo) Constructor

Creates a new action from the given ActionType

public DieAction(TinyLife.Actions.ActionType type, TinyLife.Actions.ActionInfo info);


type ActionType
The type to create this action from

info ActionInfo
The information for this action


DieAction.Reason Field

The reason of death

public DeathReason Reason;

Field Value



DieAction.CanCancel(Action) Method

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(TinyLife.Actions.Action cancelSource);


cancelSource Action
The source of the cancelation, or null if the player canceled it


true if the action can be canceled

DieAction.CanEnqueueConversation(Person, ActionType) Method

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.

protected override bool CanEnqueueConversation(TinyLife.Objects.Person person, TinyLife.Actions.ActionType type);


person Person
The person that wants to converse with us

type ActionType
The type of action that should be enqueued


Whether or not enqueueing a social action is possible

DieAction.Enqueue(Person, DeathReason) Method

Enqueues a DieAction for the given Person.
The enqueued action receives priority, and all other current actions are canceled.

public static void Enqueue(TinyLife.Objects.Person person, TinyLife.Objects.Person.DeathReason reason);


person Person
The person that should die

reason DeathReason
The reason for their death

DieAction.GetDisplayName() Method

Returns a localized string that explains this action in short.
By default, this method returns GetDisplayName(ActionInfo, bool).

public override string GetDisplayName();


This action's display name

DieAction.Initialize() Method

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();

DieAction.IsCompleted() Method

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 ForceFail modifies the completion type, otherwise Active is returned.

public override TinyLife.Actions.Action.CompletionType IsCompleted();


The current completion type of this action

DieAction.OnCompleted(CompletionType) Method

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.

public override void OnCompleted(TinyLife.Actions.Action.CompletionType type);


type CompletionType
The type that this action completed with

DieAction.Update(GameTime, TimeSpan, GameSpeed) Method

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, GameSpeed, bool) is called.

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


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