Class StatemachineConnector
- Namespace
- Static
The StatemachineConnector connects interaction inputs with the visual scripting flow and outputs with the instruction, error and insight controller through events. It therefore functions as a funnel between the Visual Statemachine and the rest of the logic.
Either the visual statemachien decides whether actions are correct or wrong (default) or the connection can also be commented out and the decisions on wrong/correct actions can be made manually in the RequestStateChange method by using C# programming.
public class StatemachineConnector
- Inheritance
-
objectStatemachineConnector
Fields
Instance
The static instance of this StatemachineConnector.
public static StatemachineConnector Instance
Field Value
errorCounter
The amount of errors performed by the user of the training.
public int errorCounter
Field Value
- int
Properties
CurrentStateChangeRequest
Consecutive number of the latest state change request. Everything the stateflow does while a request is handled (e.g. the nodes after a "Correct" output) happens under this number, which allows to tell things set up for the next step apart from things set up earlier.
public int CurrentStateChangeRequest { get; }
Property Value
- int
LastAcceptedStateChangeRequest
Number of the latest accepted (non-grab) state change request, meaning the latest correct action.
public int LastAcceptedStateChangeRequest { get; }
Property Value
- int
LastCompletedActionRequest
Number of the latest request that completed an action node. Accepted sub-actions of an unfinished Action (Multi) node do not advance this number.
public int LastCompletedActionRequest { get; }
Property Value
- int
Methods
AcceptedStateChange(bool)
Called by the state machine. Triggers an Action that indicates if the state change was accepted.
public void AcceptedStateChange(bool stateChangeAccepted)
Parameters
stateChangeAcceptedboolIs the statechange accepted
RegisterNewStateChangeTrigger(Func<StateInformation, bool>)
Registers a new state change trigger from the visual state flow. This trigger determines which node in the visual scripting graph is handling the state change request.
public static void RegisterNewStateChangeTrigger(Func<StateInformation, bool> action)
Parameters
actionFunc<StateInformation, bool>The Func to that is registered.
RegisterNewStateChangeTrigger(Func<StateInformation, bool>, Func<bool>)
Registers an action that can accept intermediate progress before the whole node is complete.
public static void RegisterNewStateChangeTrigger(Func<StateInformation, bool> action, Func<bool> isActionComplete)
Parameters
actionFunc<StateInformation, bool>Checks whether the requested action is correct.
isActionCompleteFunc<bool>Checks completion after an accepted request. Null means every accepted request completes the node.
RequestStateChange(StateInformation)
Request a statechange from the statemachine.
public bool RequestStateChange(StateInformation stateInformation)
Parameters
stateInformationStateInformation
Returns
- bool
Reset()
Resets the instance of this static instance.
public void Reset()
ShowCompletionOverlay()
Triggers the scenario completion overlay.
public void ShowCompletionOverlay()
ShowErrorOverlay(string, string)
Called by the visual state machine. Triggers an Action that shows the error overlay.
public void ShowErrorOverlay(string headerText, string errorText)
Parameters
headerTextstringThe Header of the error overlay
errorTextstringThe text body of the error overlay
ShowExpertInsights(AudioClip, Sprite, string)
Called by the visual state machine. Triggers an Action that shows the expert insight modality and plays and audio clip.
public void ShowExpertInsights(AudioClip audio, Sprite image, string text)
Parameters
audioAudioClipThe audioclip that is played with the expert insight
imageSpriteThe image that is displayed, e.g. the expert providing the insight.
textstringThe text displayed at the expert speechbubble
StartQuestionUI(QuestionUITypes, string, List<Answer>)
Triggers a new Questionnaire to be answered by the user on the UI.
public void StartQuestionUI(QuestionnaireController.QuestionUITypes type, string question, List<QuestionnaireController.Answer> answers)
Parameters
typeQuestionnaireController.QuestionUITypesThe type of Question(MultipleChoice, List, Input).
questionstringThe question.
answersList<QuestionnaireController.Answer>A List of struct with all possible answers.
UpdateTopPanel(string, int)
Called by the visual state machine, triggers an Action that updates the instruction text and completion percentage of the top panel.
public void UpdateTopPanel(string text, int completionPercentage)
Parameters
textstringNew instruction displayed on the top panel
completionPercentageintNew compeltion percentage displayed
Events
TriggerAcceptedStateChange
public event Action<bool> TriggerAcceptedStateChange
Event Type
- Action<bool>
TriggerErrorOverlay
public event Action<string, string> TriggerErrorOverlay
Event Type
- Action<string, string>
TriggerExpertInsights
public event Action<AudioClip, Sprite, string> TriggerExpertInsights
Event Type
- Action<AudioClip, Sprite, string>
TriggerScenarioCompletionOverlay
public event Action TriggerScenarioCompletionOverlay
Event Type
- Action
TriggerTopPanelChange
public event Action<string, int> TriggerTopPanelChange
Event Type
- Action<string, int>
TriggerUIQuestion
public event Action<QuestionnaireController.QuestionUITypes, string, List<QuestionnaireController.Answer>> TriggerUIQuestion
Event Type
- Action<QuestionnaireController.QuestionUITypes, string, List<QuestionnaireController.Answer>>