Class AUnitySensor
Use this class to create sensors that have to execute code in Unity's thread You need to call the base constructor when inheriting this class and implement the SafeReset (optional) and SafeSensorCheck (mandatory) methods
Inherited Members
Namespace: Xareus.Scenarios.Unity
Assembly: Xareus.Scenarios.Unity.dll
Syntax
public abstract class AUnitySensor : ASensor
Constructors
AUnitySensor(Event, Dictionary<string, Parameter>, ContextHolder)
Declaration
protected AUnitySensor(Event @event, Dictionary<string, Parameter> parameters, ContextHolder contexts)
Parameters
Type | Name | Description |
---|---|---|
Event | event | |
Dictionary<string, Parameter> | parameters | |
ContextHolder | contexts |
AUnitySensor(Event, Dictionary<string, Parameter>, IContext, IContext, IContext)
Declaration
[Obsolete("Use AUnitySensor(Event, Dictionary<string, Parameter>, ContextHolder) instead.")]
protected AUnitySensor(Event @event, Dictionary<string, Parameter> parameters, IContext externalContext, IContext scenarioContext, IContext sequenceContext)
Parameters
Type | Name | Description |
---|---|---|
Event | event | |
Dictionary<string, Parameter> | parameters | |
IContext | externalContext | |
IContext | scenarioContext | |
IContext | sequenceContext |
Methods
FillParameters()
Override the base method as we need to execute this in the Unity thread
Declaration
public override void FillParameters()
Overrides
Init()
Initialize a sensor. Note that this code will be executed in unity's thread and the declared parameters (using the ConfigurationParameter attribute) are already filled
Declaration
[Obsolete("Use the SafeReset method instead")]
public virtual void Init()
PostCheck()
Declaration
public override void PostCheck()
Overrides
Reset()
Declaration
public override void Reset()
Overrides
SafePostCheck()
Post check on a sensor. Note that this code will be executed in unity's thread and the declared parameters (using the ConfigurationParameter attribute) are already filled Called after a check has been performed on the event/transition that contains this sensor whether it was successful or not and whether this sensors was checked or not
Declaration
public virtual void SafePostCheck()
SafeReset()
Reset a sensor. Note that this code will be executed in unity's thread and the declared parameters (using the ConfigurationParameter attribute) are already filled
Declaration
public virtual void SafeReset()
SafeSensorCheck()
This method is called at each scenario update. Note that this code will be executed in unity's thread
Declaration
public abstract ASensor.Result SafeSensorCheck()
Returns
Type | Description |
---|---|
ASensor.Result |
SafeStopCheck()
Stops a sensor. Note that this code will be executed in unity's thread and the declared parameters (using the ConfigurationParameter attribute) are already filled This will be called when the transition contining this sensor is no longer ready to be triggered. Either it already fired or tokens moved and the transition no longer has the necessary upstream tokens
Declaration
public virtual void SafeStopCheck()
SensorCheck()
SensorCheck() This method is called at each scenario update (NextStep). If the scenario is running in a thread different from Unity's thread, SafeSensorCheck() will be called. If the Result object returns true, the transition holding the sensor is triggered
Declaration
public override sealed ASensor.Result SensorCheck()
Returns
Type | Description |
---|---|
ASensor.Result |
Overrides
StopCheck()
Declaration
public override void StopCheck()
Overrides
UnityThreadFillParameters()
Declaration
protected void UnityThreadFillParameters()
UpdateScenario()
Call this method to force the scenario to update in the same thread it was running in. This can be used to have a more responsive scenario for sensors that depend on user inputs
Declaration
protected virtual void UpdateScenario()