Class OvermindSerializer<T>
The overmind serializer.
Inheritance
Implements
Inherited Members
Namespace: Microsoft.XboxStudios.BotBrain.Overmind
Assembly: BotBrain.Overmind.dll
Syntax
public class OvermindSerializer<T> : BrainSerializer<OvermindState, OvermindBot, OvermindAction, T>, IOvermindSerializer, IBrainSerializer, IMetadataAccess, ITitleResourceHelper, IResourceHelper where T : OvermindBrain
Type Parameters
Name | Description |
---|---|
T | The overmind brain type. |
Constructors
View SourceOvermindSerializer(IBrainHelper, IServiceProvider, ILogger<OvermindSerializer<T>>?, string?, Assembly?)
Initializes a new instance of the OvermindSerializer<T> class.
Declaration
public OvermindSerializer(IBrainHelper brainHelper, IServiceProvider services, ILogger<OvermindSerializer<T>>? logger = null, string? outputFolder = null, Assembly? brainAssembly = null)
Parameters
Type | Name | Description |
---|---|---|
IBrainHelper | brainHelper | Gets the brain helper to use to run title-specific bots within overmind. |
IServiceProvider | services | The service provider used for construction. |
ILogger<OvermindSerializer<T>> | logger | The logger to use. |
string | outputFolder | The folder path containing brain resources. |
Assembly | brainAssembly | The assembly containing brain types to register and resources to extract. |
Properties
View SourceJsonConverters
Gets the JSON converters for serializing and deserializing bot brains.
Declaration
protected override IEnumerable<JsonConverter> JsonConverters { get; }
Property Value
Type | Description |
---|---|
IEnumerable<JsonConverter> |
Overrides
OvermindConverters
Gets the overmind converters.
Declaration
protected IEnumerable<JsonConverter> OvermindConverters { get; }
Property Value
Type | Description |
---|---|
IEnumerable<JsonConverter> |
RoleFileExtension
Gets the file extension for role files.
Declaration
public virtual string RoleFileExtension { get; }
Property Value
Type | Description |
---|---|
string |
RolesOutputFolder
Gets the path to the folder containing role files.
Declaration
public virtual string RolesOutputFolder { get; }
Property Value
Type | Description |
---|---|
string |
ScenarioFileExtension
Gets the file extension for scenario files.
Declaration
public virtual string ScenarioFileExtension { get; }
Property Value
Type | Description |
---|---|
string |
ScenariosOutputFolder
Gets the path to the folder containing scenario files.
Declaration
public virtual string ScenariosOutputFolder { get; }
Property Value
Type | Description |
---|---|
string |
SubBrainHelper
Gets the brain helper used to run title-specific bots within overmind.
Declaration
public IBrainHelper SubBrainHelper { get; }
Property Value
Type | Description |
---|---|
IBrainHelper |
TitleOutputFolder
Gets the output folder for title resources.
Declaration
public override string TitleOutputFolder { get; }
Property Value
Type | Description |
---|---|
string |
Overrides
Methods
View SourceDeserializeRequirement(string)
Deserializes a requirement from a string.
Declaration
public IRequirement DeserializeRequirement(string contents)
Parameters
Type | Name | Description |
---|---|---|
string | contents | A string representation of a requirement. |
Returns
Type | Description |
---|---|
IRequirement | The requirement. |
DeserializeRole(string)
Deserializes a role from a string.
Declaration
public virtual IRole DeserializeRole(string contents)
Parameters
Type | Name | Description |
---|---|---|
string | contents | A string representation of a role. |
Returns
Type | Description |
---|---|
IRole | The role. |
DeserializeRoleFile(string)
Creates a role from a file.
Declaration
public virtual IRole DeserializeRoleFile(string file)
Parameters
Type | Name | Description |
---|---|---|
string | file | The file path. |
Returns
Type | Description |
---|---|
IRole | The role. |
DeserializeScenario(string)
Deserializes a scenario from a string.
Declaration
public virtual IScenario DeserializeScenario(string contents)
Parameters
Type | Name | Description |
---|---|---|
string | contents | A string representation of a scenario. |
Returns
Type | Description |
---|---|
IScenario | The scenario. |
DeserializeScenarioFile(string)
Creates a scenario from a file.
Declaration
public virtual IScenario DeserializeScenarioFile(string file)
Parameters
Type | Name | Description |
---|---|---|
string | file | The file path. |
Returns
Type | Description |
---|---|
IScenario | The scenario. |
GetDefaultSerializerSettings(bool)
Gets the default serializer settings for the given options.
Declaration
protected override JsonSerializerSettings GetDefaultSerializerSettings(bool indented = true)
Parameters
Type | Name | Description |
---|---|---|
bool | indented | If true, the JSON output is indented. |
Returns
Type | Description |
---|---|
JsonSerializerSettings | A settings object. |
Overrides
View SourceGetRoleFilePath(string)
Gets the output file path for a role.
Declaration
protected virtual string GetRoleFilePath(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The role name. |
Returns
Type | Description |
---|---|
string | The file path. |
GetScenarioFilePath(string)
Gets the output file path for a scenario.
Declaration
protected virtual string GetScenarioFilePath(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The scenario name. |
Returns
Type | Description |
---|---|
string | The file path. |
Initialize()
Initializes the brain helper.
Declaration
public override void Initialize()
Overrides
LoadBrainTemplates()
Loads built-in brain templates.
Declaration
protected virtual void LoadBrainTemplates()
LoadRole(string)
Loads the role instance.
Declaration
public virtual IRole? LoadRole(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The role name. |
Returns
Type | Description |
---|---|
IRole | The role. |
LoadScenario(string)
Loads a scenario instance.
Declaration
public virtual IScenario? LoadScenario(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The scenario name. |
Returns
Type | Description |
---|---|
IScenario | The scenario. |
LoadScenarioAndRoleTemplates()
Loads built-in scenario and role templates.
Declaration
protected virtual void LoadScenarioAndRoleTemplates()
LoadSettings(IParameterManager)
Loads the overmind settings.
Declaration
public virtual OvermindSettings LoadSettings(IParameterManager parameters)
Parameters
Type | Name | Description |
---|---|---|
IParameterManager | parameters | The parameters to load. |
Returns
Type | Description |
---|---|
OvermindSettings | The overmind settings. |
LoadSettings(string)
Loads the overmind settings.
Declaration
public virtual OvermindSettings LoadSettings(string parameters)
Parameters
Type | Name | Description |
---|---|---|
string | parameters | The parameters to load. |
Returns
Type | Description |
---|---|
OvermindSettings | The overmind settings. |
RegisterOvermindAssemblyTypes(Assembly)
Registers overmind-related types for deserialization.
Declaration
protected static void RegisterOvermindAssemblyTypes(Assembly a)
Parameters
Type | Name | Description |
---|---|---|
Assembly | a | The assembly to index. |
SaveSettings(OvermindSettings)
Saves the overmind settings to a string.
Declaration
public virtual string SaveSettings(OvermindSettings settings)
Parameters
Type | Name | Description |
---|---|---|
OvermindSettings | settings | The overmind settings. |
Returns
Type | Description |
---|---|
string | The serialized settings. |
SerializeRequirement(IRequirement, bool)
Serializes a requirement to a string.
Declaration
public virtual string SerializeRequirement(IRequirement requirement, bool indented = true)
Parameters
Type | Name | Description |
---|---|---|
IRequirement | requirement | The requirement. |
bool | indented | If true, the output is indented. |
Returns
Type | Description |
---|---|
string | A string representation of a requirement. |
SerializeRole(IRole, bool)
Serializes a role to a string.
Declaration
public virtual string SerializeRole(IRole role, bool indented = true)
Parameters
Type | Name | Description |
---|---|---|
IRole | role | The role. |
bool | indented | If true, the output is indented. |
Returns
Type | Description |
---|---|
string | A string representation of a role. |
SerializeScenario(IScenario, bool)
Serializes a scenario to a string.
Declaration
public virtual string SerializeScenario(IScenario scenario, bool indented = true)
Parameters
Type | Name | Description |
---|---|---|
IScenario | scenario | The scenario. |
bool | indented | If true, the output is indented. |
Returns
Type | Description |
---|---|
string | A string representation of a scenario. |
WriteTitleResources()
Writes the embedded bot brain title-specific resources to disk.
Declaration
protected override void WriteTitleResources()