Table of Contents

Class DebugAction

Namespace
TinyLife.Actions
Assembly
Tiny Life.dll

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
JsonTypeSafeGenericDataHolder
DebugAction
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

type ActionType

The type for this action.

info ActionInfo

The information for this action.

Methods

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

name string

The name.

context ObjectCategory

The context.

run Action<Action>

The action to execute when this debug action is run.

canExecute ActionType.CanExecuteDelegate

A 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

name string

The name.

context ObjectCategory

The context.

cheat string

The cheat to execute when this debug action is run.

args Func<ActionInfo, IEnumerable<object>>

The arguments to pass to the executed cheat when this debug action is run.

canExecute ActionType.CanExecuteDelegate

A ActionType.CanExecuteDelegate that determines whether the action can be started.

Returns

ActionType.TypeSettings

The created type settings.

Create(string, ObjectCategory, string, (string Name, 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, (string Name, Func<ActionInfo, IEnumerable<object>> Args)[] runsArgs, ActionType.CanExecuteDelegate canExecute = null)

Parameters

name string

The name.

context ObjectCategory

The context.

cheat string

The cheat to execute when this debug action is run.

runsArgs (string Name, Func<ActionInfo, IEnumerable<object>> Args)[]

The choices of arguments to pass to the executed cheat when this debug action is run.

canExecute ActionType.CanExecuteDelegate

A 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

name string

The name.

context ObjectCategory

The context.

constructedType Type

The type of action to construct.

canExecute ActionType.CanExecuteDelegate

A ActionType.CanExecuteDelegate that determines whether the action can be started.

Returns

ActionType.TypeSettings

The created type settings.

Create(string, ObjectCategory, (string Name, 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, (string Name, Action<Action> Action)[] runs, ActionType.CanExecuteDelegate canExecute = null)

Parameters

name string

The name.

context ObjectCategory

The context.

runs (string Name, Action<Action> Action)[]

The actions to execute when this debug action is run.

canExecute ActionType.CanExecuteDelegate

A ActionType.CanExecuteDelegate that determines whether the action can be started.

Returns

ActionType.TypeSettings

The created type settings.

Create(string, ObjectCategory, (string Name, 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, (string Name, Func<ActionInfo, bool> Valid, Action<Action> Action)[] runs, ActionType.CanExecuteDelegate canExecute = null)

Parameters

name string

The name.

context ObjectCategory

The context.

runs (string Name, Func<ActionInfo, bool> Valid, Action<Action> Action)[]

The actions to execute when this debug action is run.

canExecute ActionType.CanExecuteDelegate

A 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 ForceResult 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

type CompletionType

The type that this action completed with

Run()

Runs this debug action's behavior.

protected abstract void Run()