Class AutomatedBotBase<TAction>
The base class for a bot that performs actions.
Implements
Inherited Members
Namespace: Microsoft.XboxStudios.BotBrain.Operations
Assembly: BotBrain.Operations.dll
Syntax
public abstract class AutomatedBotBase<TAction> : BotWithEvents<TAction>, IEventPublisher<BotActionEventArgs>, IBotWithEvents<TAction>, IBotWithEvents, IBotWithQueue<TAction>, IBotWithQueue, IAutomatedBot<TAction>, IAutomatedBot, IHasParameters, IDisposable
Type Parameters
Name | Description |
---|---|
TAction | The action type. |
Properties
View SourceCurrentAction
Gets or sets the bot's current action.
Declaration
public override TAction CurrentAction { get; set; }
Property Value
Type | Description |
---|---|
TAction |
Overrides
View SourceIsRunning
Gets a value indicating whether the bot is executing an action.
Declaration
public override bool IsRunning { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
View SourceQueueCount
Gets the number of actions in the queue.
Declaration
public int QueueCount { get; }
Property Value
Type | Description |
---|---|
int |
QueueIndex
Gets the index of the current action in the queue.
Declaration
public int QueueIndex { get; }
Property Value
Type | Description |
---|---|
int |
StopAfterError
Gets or sets a value indicating whether or not to stop the bot if an operation fails.
Declaration
public bool StopAfterError { get; set; }
Property Value
Type | Description |
---|---|
bool |
Methods
View SourceDispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public virtual void Dispose()
HandleActionFailed(TAction, Exception)
Called when an operation fails.
Declaration
protected virtual Task HandleActionFailed(TAction operation, Exception e)
Parameters
Type | Name | Description |
---|---|---|
TAction | operation | The operation. |
Exception | e | The exception, if there was one. |
Returns
Type | Description |
---|---|
Task | A task. |
OnQueueStarted()
Raises an event indicating that the queue's started.
Declaration
protected void OnQueueStarted()
OnQueueStopped()
Raises an event indicating that the queue's stopped or finished.
Declaration
protected void OnQueueStopped()
Reset()
Resets the bot's current action and stops the bot.
Declaration
public override Task Reset()
Returns
Type | Description |
---|---|
Task | A task that completes once the bot is reset. |
Overrides
View SourceSetActions(IEnumerable<TAction>)
Sets the action queue.
Declaration
public virtual Task SetActions(IEnumerable<TAction> actions)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TAction> | actions | The actions. |
Returns
Type | Description |
---|---|
Task | A task. |
Start()
Starts executing the bot queue.
Declaration
public override Task Start()
Returns
Type | Description |
---|---|
Task | A task that completes once the queue begins. |
Overrides
View SourceStart(int)
Starts executing the bot's queue from the given index.
Declaration
public virtual Task Start(int queueIndex)
Parameters
Type | Name | Description |
---|---|---|
int | queueIndex | The queue index. |
Returns
Type | Description |
---|---|
Task | A task that completes once the queue begins. |
StartOrResumeExecution(TAction, CancellationToken)
Starts executing the operation on this bot, or waits for it to finish if it's already running.
Declaration
protected abstract Task<bool> StartOrResumeExecution(TAction operation, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
TAction | operation | The operation. |
CancellationToken | token | A token to monitor for cancellation. |
Returns
Type | Description |
---|---|
Task<bool> | True if the operation was successful. |
Stop()
Stops executing the bot queue.
Declaration
public override Task Stop()
Returns
Type | Description |
---|---|
Task | A task that completes once the queue stops. |
Overrides
Events
View SourceQueueStarted
Occurs when the bot queue is started.
Declaration
public event EventHandler? QueueStarted
Event Type
Type | Description |
---|---|
EventHandler |
QueueStopped
Occurs when the bot queue is finished.
Declaration
public event EventHandler? QueueStopped
Event Type
Type | Description |
---|---|
EventHandler |