CommandPattern 1.0.0
This package contains a collection of classes and interfaces to allow for quick and consistent implementation of the command pattern across projects.
Public Member Functions | Public Attributes | Properties | List of all members
SadSapphicGames.CommandPattern.SingletonCommandManager Class Reference

A singleton manager for a single-stream, out of the box implementation of the Command pattern. Once you understand how the package works it is highly recommended create your own CommandStream wrapper tailored to the needs of your project. Executes the next command in the CommandStream every frame. More...

Inheritance diagram for SadSapphicGames.CommandPattern.SingletonCommandManager:

Public Member Functions

void ToggleCommandExecution ()
 Turns command execution off if its on and on if its off
 
void ToggleCommandExecution (bool onoff)
 Turns command execution on or off More...
 
ReadOnlyCollection< ICommandGetCommandHistory ()
 Get the underlying CommandStream's history More...
 
ReadOnlyCollection< Task > GetRunningCommandTasks ()
 Get the currently uncompleted tasks from executed AsyncCommands More...
 
void CancelRunningCommandTask (Task taskToCancel)
 Cancels an AsyncCommand's running task through a reference to the task More...
 
void CancelRunningCommandTask (IAsyncCommand asyncCommand)
 Cancels an AsyncCommand's running task through a reference to the command More...
 
ReadOnlyCollection< ICommandDropCommandHistory ()
 Empties the history of the internal CommandStream and replaces it with an empty one. More...
 
void QueueCommand (ICommand command)
 Queue's a Command into the CommandManager's CommandStream More...
 
void QueueCommands (IEnumerable< ICommand > commands)
 Queue's multiple commands into the CommandManager's CommandStream More...
 
bool TryQueueUndoCommand (IUndoable commandToUndo)
 Queue the undo-command of a Command implementing IUndoable into the CommandStream More...
 
void ForceQueueUndoCommand (IUndoable commandToUndo)
 Forces the internal CommandStream to queue and IUndoable commands undo command More...
 

Public Attributes

int maximumHistoryDepth = -1
 The value that will be used in the internal CommandStream's constructor, set to negative to record all history
 

Properties

static SingletonCommandManager Instance [get]
 The singleton instance of the CommandManger.
 
int HistoryCount [get]
 The number of Commands recorded by the CommandManager's CommandStream
 
float HistoryDepth [get]
 The depth to which the CommandManager's CommandStream records its history
 
int QueueCount [get]
 The Number of commands queued in the CommandManager's CommandStream
 
bool QueueEmpty [get]
 Wether or not the CommandManger's CommandStream has an empty queue
 

Detailed Description

A singleton manager for a single-stream, out of the box implementation of the Command pattern. Once you understand how the package works it is highly recommended create your own CommandStream wrapper tailored to the needs of your project. Executes the next command in the CommandStream every frame.

Member Function Documentation

◆ CancelRunningCommandTask() [1/2]

void SadSapphicGames.CommandPattern.SingletonCommandManager.CancelRunningCommandTask ( IAsyncCommand  asyncCommand)

Cancels an AsyncCommand's running task through a reference to the command

Parameters
taskToCancelthe AsyncCommand who's task should be canceled

◆ CancelRunningCommandTask() [2/2]

void SadSapphicGames.CommandPattern.SingletonCommandManager.CancelRunningCommandTask ( Task  taskToCancel)

Cancels an AsyncCommand's running task through a reference to the task

Parameters
taskToCancelthe task of an AsyncCommand to cancel

◆ DropCommandHistory()

ReadOnlyCollection< ICommand > SadSapphicGames.CommandPattern.SingletonCommandManager.DropCommandHistory ( )

Empties the history of the internal CommandStream and replaces it with an empty one.

Returns
The old history of the internal CommandStream

◆ ForceQueueUndoCommand()

void SadSapphicGames.CommandPattern.SingletonCommandManager.ForceQueueUndoCommand ( IUndoable  commandToUndo)

Forces the internal CommandStream to queue and IUndoable commands undo command

Parameters
commandToUndoThe IUndoable command to undo

◆ GetCommandHistory()

ReadOnlyCollection< ICommand > SadSapphicGames.CommandPattern.SingletonCommandManager.GetCommandHistory ( )

Get the underlying CommandStream's history

Returns
A ReadOnlyCollection of all the commands executed by the CommandManager's CommandStream

◆ GetRunningCommandTasks()

ReadOnlyCollection< Task > SadSapphicGames.CommandPattern.SingletonCommandManager.GetRunningCommandTasks ( )

Get the currently uncompleted tasks from executed AsyncCommands

Returns
A ReadOnlyCollection of uncompleted tasks from executed AsyncCommands

◆ QueueCommand()

void SadSapphicGames.CommandPattern.SingletonCommandManager.QueueCommand ( ICommand  command)

Queue's a Command into the CommandManager's CommandStream

Parameters
commandThe Command to be Queued

◆ QueueCommands()

void SadSapphicGames.CommandPattern.SingletonCommandManager.QueueCommands ( IEnumerable< ICommand commands)

Queue's multiple commands into the CommandManager's CommandStream

Parameters
commandsThe collection of commands to be Queued

◆ ToggleCommandExecution()

void SadSapphicGames.CommandPattern.SingletonCommandManager.ToggleCommandExecution ( bool  onoff)

Turns command execution on or off

Parameters
onoffif false stops the execution of commands, if true enables it

◆ TryQueueUndoCommand()

bool SadSapphicGames.CommandPattern.SingletonCommandManager.TryQueueUndoCommand ( IUndoable  commandToUndo)

Queue the undo-command of a Command implementing IUndoable into the CommandStream

Parameters
commandToUndoThe IUndoable Command to queue an undo-command for
Returns
Wether the undo command was allowed to be queued

The documentation for this class was generated from the following file: