OutOfTownAction - Ellpeck/TinyLifeExampleMod Wiki

Tiny Life

TinyLife.Actions

OutOfTownAction Class

An out-of-town action is an action where the Person finds the closest exit road and then exits the city using that road.
Out-of-town actions are things like going to work, where the destination location isn't visible to the player.

public abstract class OutOfTownAction : TinyLife.Actions.MultiAction

Inheritance System.Object 🡒 MLEM.Misc.GenericDataHolder 🡒 Action 🡒 MultiAction 🡒 OutOfTownAction

Constructors

OutOfTownAction.OutOfTownAction(ActionType, ActionInfo, bool, NeedType[]) Constructor

Creates a new out-of-town action with the given settings.
Note that, since some data is not saved to disk, all of the information should be provided by a subclass constructor.

public OutOfTownAction(TinyLife.Actions.ActionType type, TinyLife.Actions.ActionInfo info, bool restoreNeedsEqually, params TinyLife.NeedType[] needsToTakeCareOf);

Parameters

type ActionType
The action type

info ActionInfo
The action info

restoreNeedsEqually System.Boolean
Whether all needs should be restored equally. If this is true, all specified needs will be restored perpetually instead of just low ones.

needsToTakeCareOf NeedType[]
The needs that should automatically be taken care of

Fields

OutOfTownAction.NeedsToTakeCareOf Field

The needs that should automatically be taken care of while the person is out of town.
A need gets taken care of in AndThenUpdate(GameTime, TimeSpan, GameSpeed) if it is below 35%.
Note that this value is not saved to disk, and should be provided by a subclass constructor.

protected readonly NeedType[] NeedsToTakeCareOf;

Field Value

NeedType[]

Methods

OutOfTownAction.AndThenInitialize() Method

Initializes the main action.
This method is called after FirstActions have all completed.

protected override void AndThenInitialize();

OutOfTownAction.AndThenUpdate(GameTime, TimeSpan, GameSpeed) Method

MultiAction version of Update(GameTime, TimeSpan, GameSpeed).
This method is called every update frame while the main action is active.
By default, only MainElapsedTime is increased.

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

Parameters

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 speed

OutOfTownAction.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);

Parameters

person Person
The person that wants to converse with us

type ActionType
The type of action that should be enqueued

Returns

System.Boolean
Whether or not enqueueing a social action is possible

OutOfTownAction.CausesExtremelyFastSpeed() Method

Returns true if this action, while it is currently active, should cause the ExtremelyFast speed to be available.
By default, this method returns false.

public override bool CausesExtremelyFastSpeed();

Returns

System.Boolean
Whether the extremely fast speed should be available

OutOfTownAction.CreateFirstActions() Method

Return a set of actions that should be executed before this action.
Even if the yield statement is used, all actions will be collected into a list at the start of this action's invocation.
If no action gets returned in this function, this action fails.
If a null action is returned as the first item, no first actions will be executed.

protected override System.Collections.Generic.IEnumerable<TinyLife.Actions.Action> CreateFirstActions();

Returns

System.Collections.Generic.IEnumerable<Action>
A set of actions that sohuld run before this action

OutOfTownAction.GetClosestExitRoad() Method

Returns the point of the road that is at the edge of the map and the MLEM.Misc.Direction2 that the map border is in, and is also closest to the Person.
Since every map is expected to have at least one exit road, no checking is done to ensure that one exists.

protected (Microsoft.Xna.Framework.Point,MLEM.Misc.Direction2) GetClosestExitRoad();

Returns

<Microsoft.Xna.Framework.Point,MLEM.Misc.Direction2>
The closest exit road

OutOfTownAction.GetNextAction(CompletionType) Method

Returns an action that should be queued up immediately after this action completes.
The queued up action is immediately started in the slot that this action occupied.
Can be null, and is null by default.

public override TinyLife.Actions.Action GetNextAction(TinyLife.Actions.Action.CompletionType completion);

Parameters

completion CompletionType
The type that this action completed with

Returns

Action
The follow-up action