Table of Contents

Class PlayModeTool

Namespace
TinyLife.Tools
Assembly
Tiny Life.dll

A tool is a type of game mode that is currently active. Tools are split up into the PlayModeTool and BuildTools, the latter of which holds all tools that can be found in the build menu.

public class PlayModeTool : Tool
Inheritance
PlayModeTool
Inherited Members
Extension Methods

Constructors

PlayModeTool()

public PlayModeTool()

Fields

AvailableStats

A dictionary that contains information about the PlayModeTool.StatType values that should be selectable for a given PersonLike type and AgeGroup combination.

public static readonly Dictionary<(Type, AgeGroup), PlayModeTool.StatType[]> AvailableStats

Field Value

Dictionary<(Type, AgeGroup), PlayModeTool.StatType[]>

SelectablePersonTypes

A list that contains the PersonLike types that can be selected in the play mode tool. If a person type is not in this list, people of that type will still display as part of the household, but not be actively playable.

public static readonly List<Type> SelectablePersonTypes

Field Value

List<Type>

Properties

SelectedPerson

Stores the PersonLike that is currently selected

public PersonLike SelectedPerson { get; }

Property Value

PersonLike

SelectedStat

The PlayModeTool.StatType that is currently se

public PlayModeTool.StatType SelectedStat { get; }

Property Value

PlayModeTool.StatType

Methods

CanUndoRedo(bool)

Returns whether or not the UndoRedoStack can currently operate and thus, whether the Undo() or Redo() actions can be called.

public override bool CanUndoRedo(bool cursorOnUi)

Parameters

cursorOnUi bool

Returns

bool

Whether the undo or redo commands can be used right now.

CloseInteraction(bool, bool)

Closes the interaction menu that was opened with OpenInteraction(IReadOnlyCollection<ActionType>, ActionInfo, Vector2, string[], int[]). If no interaction menu is open, this method does nothing.

public void CloseInteraction(bool animate, bool defer)

Parameters

animate bool

Whether to animate the closing process.

defer bool

Whether to defer the closing process to the next frame, which only has an effect if animate is false.

Closed()

Called when this build tool is closed. By default, this method removes its elements from the ui.

public override void Closed()

OpenInteraction(IReadOnlyCollection<ActionType>, ActionInfo, Vector2, string[], int[])

Opens an interaction menu for the given actions at the given location.

public bool OpenInteraction(IReadOnlyCollection<ActionType> actions, ActionInfo info, Vector2 center, string[] categories, int[] pages)

Parameters

actions IReadOnlyCollection<ActionType>

The actions to make available in the interaction menu.

info ActionInfo

The action info to invoke the actions for.

center Vector2

The position, in screen space, to open the interaction menu around.

categories string[]

The categories in the interaction menu that have already been navigated to. When freshly opening an interaction menu, this should be an empty array.

pages int[]

The pages in the interaction menu that are currently open, for each category in the categories array, as well as the "root category". When freshly opening an interaction menu, this should be an array that contains a single 0.

Returns

bool

Whether the interaction menu could be opened, which is false if the actions collection is empty or none of the actions have visible CanExecuteResults.

Opened()

Called when this build tool is opened. By default, this method initializes several settings and calls InitBuildModeUi(Panel, Panel).

public override void Opened()

PlayEventSting(SoundEffect)

Plays an event sting sound effect with the EventStingVolume, additionally ducking the music for the duration of the sting.

public static bool PlayEventSting(SoundEffect sting)

Parameters

sting SoundEffect

The sting to play.

Returns

bool

Whether the sting was successfully played. If this is false, the EventStingVolume was not high enough to play a sting.

PlayEventSting(DefaultEventSting)

Plays an event sting sound effect with the EventStingVolume, additionally ducking the music for the duration of the sting.

public static bool PlayEventSting(DefaultEventSting sting)

Parameters

sting DefaultEventSting

The default sting to play.

Returns

bool

Whether the sting was successfully played. If this is false, the EventStingVolume was not high enough to play a sting.

Reload()

Reloads the play mode tool's ui

public static void Reload()

SetSelectedPerson(PersonLike)

Sets the currently selected person to the given person and updates the UI accordingly.

public bool SetSelectedPerson(PersonLike person)

Parameters

person PersonLike

The person.

Returns

bool

Whether the person could be set. This is false if the selected person is already the given person, or if SelectablePersonTypes does not contain the person's type.

Update(GameTime, bool)

This method is called every update frame for the CurrentTool. By default, this method updates the MousePos and invokes OnUpdate, and also manages the UndoRedoStack.

public override void Update(GameTime time, bool cursorOnUi)

Parameters

time GameTime

The game's time

cursorOnUi bool

Whether the cursor is currently covering the ui.

UpdateStatsView(PersonLike)

Updates the play mode tool's stats view for the given PersonLike. If the passed person is not the SelectedPerson, this method may behave unexpectedly. To select a different person and automatically update the stats view, use SetSelectedPerson(PersonLike).

public void UpdateStatsView(PersonLike person)

Parameters

person PersonLike

The person to update the stats view for. Should generally be the same as SelectedPerson.

Events

OnSelectedPersonChanged

An event that is invoked when the currently selected person changes.

public static event Action<(PersonLike Previous, PersonLike Selected)> OnSelectedPersonChanged

Event Type

Action<(PersonLike Previous, PersonLike Selected)>

OnUpdateStatsView

An event that is invoked when the play mode tool's stats MLEM.Ui.Elements.Panel is updated. This occurs when a PlayModeTool.StatType tab is opened, or when a corresponding stat's information changes in a way that forces the panel to be refreshed. During this even't Pre phase, the previous content has not been removed from the MLEM.Ui.Elements.Panel yet.

public static event Action<(PersonLike Person, PlayModeTool.StatType Stat, Panel Panel, EventPhase Phase)> OnUpdateStatsView

Event Type

Action<(PersonLike Person, PlayModeTool.StatType Stat, Panel Panel, EventPhase Phase)>