Class PlayModeTool
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
Tabs
public static readonly List<PlayModeTool.Tab> Tabs
Field Value
Properties
SelectedPerson
Stores the PersonLike that is currently selected
public PersonLike SelectedPerson { get; }
Property Value
SelectedTab
The PlayModeTool.Tab that is currently selected
public PlayModeTool.Tab SelectedTab { get; }
Property Value
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
cursorOnUibool
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
animateboolWhether to animate the closing process.
deferboolWhether to defer the closing process to the next frame, which only has an effect if
animateis false.
Closed()
Called when this build tool is closed. By default, this method removes its elements from the ui.
public override void Closed()
IsTabValidForPerson(PersonLike, Tab)
public static bool IsTabValidForPerson(PersonLike person, PlayModeTool.Tab tab)
Parameters
personPersonLiketabPlayModeTool.Tab
Returns
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
actionsIReadOnlyCollection<ActionType>The actions to make available in the interaction menu.
infoActionInfoThe action info to invoke the actions for.
centerVector2The position, in screen space, to open the interaction menu around.
categoriesstring[]The categories in the interaction menu that have already been navigated to. When freshly opening an interaction menu, this should be an empty array.
pagesint[]The pages in the interaction menu that are currently open, for each category in the
categoriesarray, 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
actionscollection 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
stingSoundEffectThe 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
stingDefaultEventStingThe 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
personPersonLikeThe person.
Returns
- bool
Whether the person could be set. This is false if the selected person is already the given person, or if PlayModeSelectable does not contain the
person's type.
ShouldHighlightSelectedObject(object)
Whether or not the selected object should currently have a white highlight around it. This method defaults to return true if IsCursorOnUi() is false.
public override bool ShouldHighlightSelectedObject(object obj)
Parameters
Returns
- bool
Whether or not the selected object should be highlighted
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
timeGameTimeThe game's time
cursorOnUiboolWhether 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
personPersonLikeThe 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
OnUpdateStatsView
An event that is invoked when the play mode tool's stats MLEM.Ui.Elements.Panel is updated. This occurs when a PlayModeTool.Tab is opened, or when a corresponding stat's information changes in a way that forces the panel to be refreshed. During this event's Pre phase, the previous content has not been removed from the MLEM.Ui.Elements.Panel yet.
public static event Action<(PersonLike Person, PlayModeTool.Tab Tab, Panel Panel, EventPhase Phase)> OnUpdateStatsView
Event Type
- Action<(PersonLike Person, PlayModeTool.Tab Tab, Panel Panel, EventPhase Phase)>