Class ScenarioRunner
ScenarioRunner is a Unity component that runs a scenario. It is responsible for loading the scenario file, creating the external context and updating the scenario if set
Inheritance
ScenarioRunner
Assembly: Xareus.Scenarios.Unity.dll
Syntax
public class ScenarioRunner : MonoBehaviour, IContext
Fields
CreateExternalContext
Assign a method to customize the external context of the scenario
Declaration
public Func<IContext> CreateExternalContext
Field Value
CreateLoadingParameters
Assign a method to customize the loading parameters of the scenario
Declaration
public Func<ScenarioLoadingParameters> CreateLoadingParameters
Field Value
GAME_OBJECT_ENTRY
Declaration
public const string GAME_OBJECT_ENTRY = "gameObject"
Field Value
LoadFromFile
Load the scenario from the file specified in scenarioFileToLoad instead of the internal TextAsset from scenarioXml
@see scenarioFileToLoad
Declaration
[FormerlySerializedAs("LoadFromFile")]
public bool LoadFromFile
Field Value
RUNNER_ENTRY
Declaration
public const string RUNNER_ENTRY = "runner"
Field Value
RunInSeparateThread
Disable to run the scenario engine in Unity's main thread (i.e. Update). Reactivity will be better but the scenario engine might impact the framerate of your application
Declaration
public bool RunInSeparateThread
Field Value
RunScenarioAfterLoad
Should the scenario run the scenario after loading it ?
Declaration
public bool RunScenarioAfterLoad
Field Value
SHARED_CONTEXT_ENTRY
Declaration
public const string SHARED_CONTEXT_ENTRY = "shared"
Field Value
ScenarioFileToLoad
The scenario file to load if loadFromFile is true
@see loadFromFile
Declaration
[FormerlySerializedAs("scenarioFileToLoad")]
public string ScenarioFileToLoad
Field Value
ScenarioToScenarioRunner
Maps the opened scenarios with their corresponding scenario runner
Declaration
public static Dictionary<Scenario, ScenarioRunner> ScenarioToScenarioRunner
Field Value
ScenarioUpdateTime
The max update time of the scenario.
Declaration
public double ScenarioUpdateTime
Field Value
ScenarioXml
The XML description of the scenario
Declaration
[FormerlySerializedAs("scenarioXml")]
[FormerlySerializedAs("decisionTreeXML")]
public TextAsset ScenarioXml
Field Value
UnityExecutionSteps
Choose in which unity steps the scenario engine elements are allowed to run Unity related code
Declaration
public UnityThreadExecute.UnityExecutionStep UnityExecutionSteps
Field Value
Type |
Description |
UnityThreadExecute.UnityExecutionStep |
|
context
Declaration
protected IContext context
Field Value
externalContextEntries
Declaration
protected static Dictionary<string, MemberInfo> externalContextEntries
Field Value
scenario
Declaration
[NonSerialized]
protected Scenario scenario
Field Value
sharedExternalContext
The external context shared by all scenarios
Declaration
protected static IContext sharedExternalContext
Field Value
Properties
Container
Declaration
public IContainer Container { get; }
Property Value
ExternalContextEntries
Declaration
protected static Dictionary<string, MemberInfo> ExternalContextEntries { get; }
Property Value
GameObject
Declaration
[ExternalContextEntry("gameObject")]
public GameObject GameObject { get; }
Property Value
Type |
Description |
GameObject |
|
Instance
Declaration
public object Instance { get; }
Property Value
PropertyDescriptor
Declaration
public PropertyDescriptor PropertyDescriptor { get; }
Property Value
Ready
Checks if the scenario is ready
Declaration
public bool Ready { get; }
Property Value
Type |
Description |
bool |
True if the scenario is ready (i.e. it loaded the scenario file and created the external context)
|
Runner
Declaration
[ExternalContextEntry("runner")]
public ScenarioRunner Runner { get; }
Property Value
Scenario
Declaration
public Scenario Scenario { get; protected set; }
Property Value
ScenarioRunning
Should the component run (Update) the scenario
Declaration
public bool ScenarioRunning { get; set; }
Property Value
SharedExternalContext
The external context shared by all scenarios
Declaration
[ExternalContextEntry("shared")]
public static IContext SharedExternalContext { get; }
Property Value
Methods
Awake()
Declaration
protected virtual void Awake()
Clear()
Declaration
CreateScenarioExternalContext()
Declaration
protected virtual IContext CreateScenarioExternalContext()
Returns
CreateScenarioLoadingParameters()
Create the scenario loading parameters
Declaration
protected virtual ScenarioLoadingParameters CreateScenarioLoadingParameters()
Returns
GetPaths()
Declaration
public IEnumerable<string> GetPaths()
Returns
GetService(Type)
Declaration
public object GetService(Type serviceType)
Parameters
Type |
Name |
Description |
Type |
serviceType |
|
Returns
GetValue(string)
Declaration
public object GetValue(string path)
Parameters
Type |
Name |
Description |
string |
path |
|
Returns
GetValueOrDefault(string, object)
Declaration
public object GetValueOrDefault(string path, object defaultValue = null)
Parameters
Returns
HasPath(string)
Declaration
public bool HasPath(string path)
Parameters
Type |
Name |
Description |
string |
path |
|
Returns
InitCoroutine()
Declaration
protected virtual IEnumerator InitCoroutine()
Returns
LoadScenario()
Declaration
protected virtual void LoadScenario()
NextStep(Action<bool>)
Call this method to update the scenario. This method is called on a regular basis if useScenarioUpdateTime is true
Declaration
public void NextStep(Action<bool> resultCallback = null)
Parameters
Type |
Name |
Description |
Action<bool> |
resultCallback |
The callback action to call when the scenario is done updating. The boolean parameter indicates if the scenario has reached a final state
|
OnComponentChanged()
Declaration
public void OnComponentChanged()
OnComponentChanging()
Declaration
public bool OnComponentChanging()
Returns
OnDisable()
Declaration
public virtual void OnDisable()
OnEnable()
Declaration
public virtual void OnEnable()
SetValue(string, object)
Declaration
public void SetValue(string path, object value)
Parameters
Union(string, IContext)
Declaration
public void Union(string path, IContext other)
Parameters
Union(IContext, bool)
Declaration
public void Union(IContext other, bool overrideDuplicates = true)
Parameters
Type |
Name |
Description |
IContext |
other |
|
bool |
overrideDuplicates |
|
UpdateScenario()
Declaration
protected virtual IEnumerator UpdateScenario()
Returns
Implements