Class RoleBasedScenario
A role-based scenario.
Implements
Inherited Members
Namespace: Microsoft.XboxStudios.BotBrain.Overmind
Assembly: BotBrain.Overmind.dll
Syntax
public class RoleBasedScenario : ScenarioBase, IMetadataAccess, IDisposable, IRoleBasedScenario, IScenario, IEquatable<IScenario?>, IBasedOn<IScenario>, IBasedOn
Remarks
Initializes a new instance of the RoleBasedScenario class.
Constructors
View SourceRoleBasedScenario(string?, IReadOnlyCollection<IRole>?, string?, bool?, IReadOnlyCollection<IRequirement>?)
A role-based scenario.
Declaration
public RoleBasedScenario(string? name = null, IReadOnlyCollection<IRole>? roles = null, string? basedOn = null, bool? isConcurrent = null, IReadOnlyCollection<IRequirement>? stopAfter = null)
Parameters
Type | Name | Description |
---|---|---|
string | name | The scenario name. |
IReadOnlyCollection<IRole> | roles | The collection of roles. |
string | basedOn | The name of the template to base the role on. |
bool? | isConcurrent | Whether or not to run the scenario concurrently. |
IReadOnlyCollection<IRequirement> | stopAfter | A collection of stop conditions. |
Remarks
Initializes a new instance of the RoleBasedScenario class.
Properties
View SourceAssignedDevices
Gets an enumeration of devices assigned to this scenario.
Declaration
public override IEnumerable<IDevice> AssignedDevices { get; }
Property Value
Type | Description |
---|---|
IEnumerable<IDevice> |
Overrides
View SourceAssignedRoles
Gets a mapping from device to its assigned role.
Declaration
[JsonIgnore]
public IDictionary<IDevice, IRole> AssignedRoles { get; }
Property Value
Type | Description |
---|---|
IDictionary<IDevice, IRole> |
NumDevicesAssigned
Gets a value indicating how many devices this scenario has assigned.
Declaration
public override int NumDevicesAssigned { get; }
Property Value
Type | Description |
---|---|
int |
Overrides
View SourceNumDevicesRequired
Gets a value indicating how many devices this scenario requires.
Declaration
public override int NumDevicesRequired { get; }
Property Value
Type | Description |
---|---|
int |
Overrides
View SourceRoles
Gets the roles.
Declaration
[JsonProperty(ObjectCreationHandling = ObjectCreationHandling.Replace)]
public IReadOnlyCollection<IRole> Roles { get; set; }
Property Value
Type | Description |
---|---|
IReadOnlyCollection<IRole> |
Remarks
Public setter must be exposed for JSON template deserialization.
Status
Gets a value indicating whether this scenario is queued, started or finished.
Declaration
public override ScenarioStatus Status { get; }
Property Value
Type | Description |
---|---|
ScenarioStatus |
Overrides
View SourceStopAfter
Gets the collection of requirements indicating when to stop the scenario.
Declaration
[JsonProperty(ObjectCreationHandling = ObjectCreationHandling.Replace)]
public IReadOnlyCollection<IRequirement> StopAfter { get; set; }
Property Value
Type | Description |
---|---|
IReadOnlyCollection<IRequirement> |
Remarks
Public setter must be exposed for JSON template deserialization.
Methods
View SourceAddRequirement(IRequirement)
Adds a requirement to the collection indicating when to stop the scenario.
Declaration
public void AddRequirement(IRequirement requirement)
Parameters
Type | Name | Description |
---|---|---|
IRequirement | requirement | The requirement. |
AddRole(IRole)
Adds a role to the collection.
Declaration
public void AddRole(IRole role)
Parameters
Type | Name | Description |
---|---|---|
IRole | role | The role. |
ClearRequirements()
Clears the requirements.
Declaration
public void ClearRequirements()
CountActiveRoles(IRole)
Counts how many devices are actively assigned to a role.
Declaration
public int CountActiveRoles(IRole role)
Parameters
Type | Name | Description |
---|---|---|
IRole | role | The role. |
Returns
Type | Description |
---|---|
int | The number of devices. |
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()
Equals(IScenario?)
Indicates whether the current object is equal to another object of the same type.
Declaration
public override bool Equals(IScenario? other)
Parameters
Type | Name | Description |
---|---|---|
IScenario | other | An object to compare with this object. |
Returns
Type | Description |
---|---|
bool | true if the current object is equal to the |
Overrides
View SourceFlagFailedIfUnfinished(OvermindState)
Checks the scenario to see if it finished, and if not then flag it as failed.
Declaration
public override void FlagFailedIfUnfinished(OvermindState state)
Parameters
Type | Name | Description |
---|---|---|
OvermindState | state | The overmind state. |
Overrides
View SourceOnStarted(OvermindState)
Called when the scenario starts.
Declaration
protected virtual void OnStarted(OvermindState state)
Parameters
Type | Name | Description |
---|---|---|
OvermindState | state | The overmind state. |
OnStopped(OvermindState)
Called when the scenario stops.
Declaration
protected virtual void OnStopped(OvermindState state)
Parameters
Type | Name | Description |
---|---|---|
OvermindState | state | The overmind state. |
RemoveRequirement(IRequirement)
Removes a requirement from the collection indicating when to stop the scenario.
Declaration
public void RemoveRequirement(IRequirement requirement)
Parameters
Type | Name | Description |
---|---|---|
IRequirement | requirement | The requirement. |
RemoveRole(IRole)
Removes a role from the collection.
Declaration
public void RemoveRole(IRole role)
Parameters
Type | Name | Description |
---|---|---|
IRole | role | The role. |
TryAssignAsync(OvermindState, DeviceState)
Tries to assign a device to the scenario.
Declaration
public Task<bool> TryAssignAsync(OvermindState state, DeviceState subbot)
Parameters
Type | Name | Description |
---|---|---|
OvermindState | state | The overmind state. |
DeviceState | subbot | The overmind device bot. |
Returns
Type | Description |
---|---|
Task<bool> | A Task representing the asynchronous operation. |
Unassign(OvermindState, IDevice)
Removes a device from the scenario.
Declaration
public virtual void Unassign(OvermindState state, IDevice device)
Parameters
Type | Name | Description |
---|---|---|
OvermindState | state | The overmind state. |
IDevice | device | The overmind device. |
Update(OvermindState)
Called to update the scenario based on the overmind state.
Declaration
public override void Update(OvermindState state)
Parameters
Type | Name | Description |
---|---|---|
OvermindState | state | The overmind state. |