Class DebugAction
An abstract class that can be used to easily create debug-only actions that are available when TinyLife.Debug.ShowDebugActions is enabled. They complete immediately when started and invoke their Run() method once on completion. A debug action type should be created using Create(string, ObjectCategory, Type, CanExecuteDelegate) or one of its overloads.
public abstract class DebugAction : Action, IGenericDataHolder
- Inheritance
-
JsonTypeSafeGenericDataHolderDebugAction
- Implements
-
IGenericDataHolder
- Inherited Members
-
JsonTypeSafeGenericDataHolder.GetDataKeys()
- Extension Methods
Constructors
DebugAction(ActionType, ActionInfo)
Creates a new action with the given action information.
public DebugAction(ActionType type, ActionInfo info)
Parameters
typeActionTypeThe type for this action.
infoActionInfoThe information for this action.
Methods
CanMultitask(Action)
Return true on this method if this action can be multi-tasked along with the passed Action. To actually check this property, CanMultitask(Action, Action) should be used as it compares both objects. A multi-tasking is an action that is currently active along with another action. By default, multi-tasking is disallowed for any action.
public override Action.CanMultitaskResult CanMultitask(Action other)
Parameters
otherActionThe action to multi-task with
Returns
- Action.CanMultitaskResult
Whether this action can be multi-tasked
Create(string, ObjectCategory, Action<Action>, CanExecuteDelegate)
Creates type settings for a debug action that executes a simple Action with the given settings.
public static ActionType.TypeSettings Create(string name, ObjectCategory context, Action<Action> run, ActionType.CanExecuteDelegate canExecute = null)
Parameters
namestringThe name.
contextObjectCategoryThe context.
runAction<Action>The action to execute when this debug action is run.
canExecuteActionType.CanExecuteDelegateA ActionType.CanExecuteDelegate that determines whether the action can be started.
Returns
- ActionType.TypeSettings
The created type settings.
Create(string, ObjectCategory, string, Func<ActionInfo, IEnumerable<object>>, CanExecuteDelegate)
Creates type settings for a debug action that executes a Cheats entry with the given settings.
public static ActionType.TypeSettings Create(string name, ObjectCategory context, string cheat, Func<ActionInfo, IEnumerable<object>> args = null, ActionType.CanExecuteDelegate canExecute = null)
Parameters
namestringThe name.
contextObjectCategoryThe context.
cheatstringThe cheat to execute when this debug action is run.
argsFunc<ActionInfo, IEnumerable<object>>The arguments to pass to the executed
cheatwhen this debug action is run.canExecuteActionType.CanExecuteDelegateA ActionType.CanExecuteDelegate that determines whether the action can be started.
Returns
- ActionType.TypeSettings
The created type settings.
Create(string, ObjectCategory, string, (Func<string> DisplayName, Func<ActionInfo, IEnumerable<object>> Args)[], CanExecuteDelegate)
Creates type settings for a debug action that executes a set of Cheats entry with the given potential arguments. Each argument is displayed as an ActionArgument when executing.
public static ActionType.TypeSettings Create(string name, ObjectCategory context, string cheat, (Func<string> DisplayName, Func<ActionInfo, IEnumerable<object>> Args)[] runsArgs, ActionType.CanExecuteDelegate canExecute = null)
Parameters
namestringThe name.
contextObjectCategoryThe context.
cheatstringThe cheat to execute when this debug action is run.
runsArgs(Func<string> DisplayName, Func<ActionInfo, IEnumerable<object>> Args)[]The choices of arguments to pass to the executed
cheatwhen this debug action is run.canExecuteActionType.CanExecuteDelegateA ActionType.CanExecuteDelegate that determines whether the action can be started.
Returns
- ActionType.TypeSettings
The created type settings.
Create(string, ObjectCategory, Type, CanExecuteDelegate)
Creates type settings for a debug action with the given settings.
public static ActionType.TypeSettings Create(string name, ObjectCategory context, Type constructedType, ActionType.CanExecuteDelegate canExecute = null)
Parameters
namestringThe name.
contextObjectCategoryThe context.
constructedTypeTypeThe type of action to construct.
canExecuteActionType.CanExecuteDelegateA ActionType.CanExecuteDelegate that determines whether the action can be started.
Returns
- ActionType.TypeSettings
The created type settings.
Create(string, ObjectCategory, (Func<string> DisplayName, Action<Action> Action)[], CanExecuteDelegate)
Creates type settings for a debug action that executes a set of simple Action functions with the given settings. Each action function is displayed as an ActionArgument when executing.
public static ActionType.TypeSettings Create(string name, ObjectCategory context, (Func<string> DisplayName, Action<Action> Action)[] runs, ActionType.CanExecuteDelegate canExecute = null)
Parameters
namestringThe name.
contextObjectCategoryThe context.
runs(Func<string> DisplayName, Action<Action> Action)[]The actions to execute when this debug action is run.
canExecuteActionType.CanExecuteDelegateA ActionType.CanExecuteDelegate that determines whether the action can be started.
Returns
- ActionType.TypeSettings
The created type settings.
Create(string, ObjectCategory, (Func<string> DisplayName, Func<ActionInfo, bool> Valid, Action<Action> Action)[], CanExecuteDelegate)
Creates type settings for a debug action that executes a set of simple Action functions with the given settings. Each action function is displayed as an ActionArgument when executing.
public static ActionType.TypeSettings Create(string name, ObjectCategory context, (Func<string> DisplayName, Func<ActionInfo, bool> Valid, Action<Action> Action)[] runs, ActionType.CanExecuteDelegate canExecute = null)
Parameters
namestringThe name.
contextObjectCategoryThe context.
runs(Func<string> DisplayName, Func<ActionInfo, bool> Valid, Action<Action> Action)[]The actions to execute when this debug action is run.
canExecuteActionType.CanExecuteDelegateA ActionType.CanExecuteDelegate that determines whether the action can be started.
Returns
- ActionType.TypeSettings
The created type settings.
IsCompleted()
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 the default behavior of Interrupt(CompletionType) modifies the completion type, otherwise Active is returned.
public override CompletionType IsCompleted()
Returns
- CompletionType
The current completion type of this action
OnCompleted(CompletionType)
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. By default, only OnActionCompleted(Action, CompletionType, bool) is called.
public override void OnCompleted(CompletionType type)
Parameters
typeCompletionTypeThe type that this action completed with
Run()
Runs this debug action's behavior.
protected abstract void Run()