Show / Hide Table of Contents

Class AutomatedBotBase<TAction>

The base class for a bot that performs actions.

Inheritance
object
EventPublisher<BotActionEventArgs>
BotWithEvents<TAction>
AutomatedBotBase<TAction>
AutomatedBot<TBot, TAction>
Implements
IEventPublisher<BotActionEventArgs>
IBotWithEvents<TAction>
IBotWithEvents
IBotWithQueue<TAction>
IBotWithQueue
IAutomatedBot<TAction>
IAutomatedBot
IHasParameters
IDisposable
Inherited Members
BotWithEvents<TAction>.ActionStarted
BotWithEvents<TAction>.ActionFailed
BotWithEvents<TAction>.ActionFinished
BotWithEvents<TAction>.Name
BotWithEvents<TAction>.CurrentUrge
BotWithEvents<TAction>.Parameters
BotWithEvents<TAction>.ToString()
BotWithEvents<TAction>.OnActionStarted()
BotWithEvents<TAction>.OnActionFinished(TAction)
BotWithEvents<TAction>.OnActionFailed(TAction, Exception)
EventPublisher<BotActionEventArgs>.Publish(object, BotActionEventArgs)
EventPublisher<BotActionEventArgs>.EventReceived
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
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 Source

CurrentAction

Gets or sets the bot's current action.

Declaration
public override TAction CurrentAction { get; set; }
Property Value
Type Description
TAction
Overrides
BotWithEvents<TAction>.CurrentAction
View Source

IsRunning

Gets a value indicating whether the bot is executing an action.

Declaration
public override bool IsRunning { get; }
Property Value
Type Description
bool
Overrides
BotWithEvents<TAction>.IsRunning
View Source

QueueCount

Gets the number of actions in the queue.

Declaration
public int QueueCount { get; }
Property Value
Type Description
int
View Source

QueueIndex

Gets the index of the current action in the queue.

Declaration
public int QueueIndex { get; }
Property Value
Type Description
int
View Source

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 Source

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Declaration
public virtual void Dispose()
View Source

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.

View Source

OnQueueStarted()

Raises an event indicating that the queue's started.

Declaration
protected void OnQueueStarted()
View Source

OnQueueStopped()

Raises an event indicating that the queue's stopped or finished.

Declaration
protected void OnQueueStopped()
View Source

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
BotWithEvents<TAction>.Reset()
View Source

SetActions(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.

View Source

Start()

Starts executing the bot queue.

Declaration
public override Task Start()
Returns
Type Description
Task

A task that completes once the queue begins.

Overrides
BotWithEvents<TAction>.Start()
View Source

Start(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.

View Source

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.

View Source

Stop()

Stops executing the bot queue.

Declaration
public override Task Stop()
Returns
Type Description
Task

A task that completes once the queue stops.

Overrides
BotWithEvents<TAction>.Stop()

Events

View Source

QueueStarted

Occurs when the bot queue is started.

Declaration
public event EventHandler? QueueStarted
Event Type
Type Description
EventHandler
View Source

QueueStopped

Occurs when the bot queue is finished.

Declaration
public event EventHandler? QueueStopped
Event Type
Type Description
EventHandler

Implements

Microsoft.XboxStudios.GameStateTracker.Events.IEventPublisher<T>
IBotWithEvents<TAction>
IBotWithEvents
IBotWithQueue<T>
IBotWithQueue
IAutomatedBot<TAction>
IAutomatedBot
IHasParameters
IDisposable

Extension Methods

IBotWithEventsExtensions.WaitForActionFinished(IBotWithEvents, Func<Task>?, CancellationToken)
IBotWithEventsExtensions.RunAction<T>(IBotWithEvents<T>, T, CancellationToken)
IBotWithQueueExtensions.WaitForQueueStopped(IBotWithQueue, Func<Task>?, CancellationToken)
IEventPublisherExtensions.WaitForAsync<T>(IEventPublisher<T>, Func<T, bool>?, CancellationToken)
  • View Source
In this article
Back to top Generated by DocFX