Class ScenarioWrapper
Manage scenario objets as well as their graphical counterpart.
Delegates events and display to the contained graphical elements.
Inheritance
ScenarioWrapper
Assembly: Xareus.Scenarios.Unity.Edition.dll
Syntax
[Serializable]
public class ScenarioWrapper : ScriptableObject
Constructors
ScenarioWrapper()
Declaration
protected ScenarioWrapper()
Fields
SerializableScenario
Declaration
[SerializeField]
public SerializableScenario SerializableScenario
Field Value
VariableManager
Declaration
[SerializeField]
public ContextVariableManager VariableManager
Field Value
absoluteScenarioPath
Declaration
[SerializeField]
protected string absoluteScenarioPath
Field Value
m_DeserializedGraph
Declaration
protected SerializableScenario m_DeserializedGraph
Field Value
scenarioDataConsumers
Collection of data consumers for the current scenario. When empty, the scenario file change dialog popup is disabled
Declaration
[SerializeField]
protected ScenarioWrapper.ScenarioDataConsumers scenarioDataConsumers
Field Value
scenarioWrappers
Declaration
protected static readonly Dictionary<string, ScenarioWrapper> scenarioWrappers
Field Value
Properties
AbsoluteScenarioPath
The path of the scenario file in the unity hierarchy
Declaration
public virtual string AbsoluteScenarioPath { get; protected set; }
Property Value
BusinessControl
Declaration
public BusinessControl BusinessControl { get; }
Property Value
IsDirty
Is the scenario dirty (i.e. the content of the scenario is not the same of the file)
Declaration
public bool IsDirty { get; set; }
Property Value
LastSaveDateFile
The last time the file was saved
Declaration
public DateTime? LastSaveDateFile { get; }
Property Value
LastSaveDateLocal
The last time this instance was saved to its file
Declaration
public DateTime? LastSaveDateLocal { get; set; }
Property Value
Scenario
Declaration
public Scenario Scenario { get; }
Property Value
ScenarioDirectory
The directory containing the scenario file
Declaration
public string ScenarioDirectory { get; }
Property Value
Methods
AddScenarioDataConsumer(ScriptableObject)
Call this method before using the scenario data.
If the scenario file changes, this will enable a dialog popup to warn the user
Declaration
public virtual void AddScenarioDataConsumer(ScriptableObject consumer)
Parameters
AskConfirmationToSave()
Ask the user to confirm the save.
Declaration
protected virtual int AskConfirmationToSave()
Returns
Type |
Description |
int |
0 to save, 1 to cancel the opeartion, 2 to ignore/not save
|
CheckOnceIfThisFilePathIsBeingSaved(string)
Check if the provied file path is the same path as the scenario currently being saved.
Declaration
protected static bool CheckOnceIfThisFilePathIsBeingSaved(string filePath)
Parameters
Type |
Name |
Description |
string |
filePath |
|
Returns
Exceptions
CreateEmptyScenario(SequenceType)
Create an empty scenario of the given type
Declaration
public static Scenario CreateEmptyScenario(SequenceType sequenceType = SequenceType.PetriNet)
Parameters
Returns
CreateScenarioWrapper(Scenario)
Create a new scenario wrapper
Scenario is specified. Wrapper is not cached
Declaration
public static ScenarioWrapper CreateScenarioWrapper(Scenario scenario)
Parameters
Returns
CreateScenarioWrapper(SequenceType)
Create a new scenario wrapper
Scenario is empty. Wrapper is not cached
Declaration
public static ScenarioWrapper CreateScenarioWrapper(SequenceType sequenceType = SequenceType.PetriNet)
Parameters
Returns
DestroyAllScenarioWrappers()
Destroy all active scenario wrappers
Declaration
public static void DestroyAllScenarioWrappers()
GetScenarioWrapper(string)
Gets a scenario wrapper from the cache using the path
Declaration
public static ScenarioWrapper GetScenarioWrapper(string scenarioFilePath = "")
Parameters
Type |
Name |
Description |
string |
scenarioFilePath |
|
Returns
GetSequence(string)
Declaration
public ASequence GetSequence(string nodeId)
Parameters
Type |
Name |
Description |
string |
nodeId |
|
Returns
GetShowPriority()
Declaration
public bool GetShowPriority()
Returns
GetTransition(string)
Declaration
public Transition GetTransition(string nodeId)
Parameters
Type |
Name |
Description |
string |
nodeId |
|
Returns
OnAfterDeserialize()
Implement this method to receive a callback after Unity deserializes your object.
Declaration
public void OnAfterDeserialize()
OnBeforeSerialize()
Implement this method to receive a callback before Unity serializes your object.
Declaration
public void OnBeforeSerialize()
OnEnable()
Declaration
protected virtual void OnEnable()
OnScenarioDataChanged(bool)
Declaration
public void OnScenarioDataChanged(bool setDirty = true)
Parameters
Type |
Name |
Description |
bool |
setDirty |
|
OnScenarioDataChanged(ScenarioDataChangedEventArgs)
Declaration
public void OnScenarioDataChanged(ScenarioDataChangedEventArgs args)
Parameters
OnScenarioDataChanged<T>(ChangeEvent<T>, Identifiable)
Declaration
public void OnScenarioDataChanged<T>(ChangeEvent<T> changeEvent, Identifiable source)
Parameters
Type Parameters
OverrideScenarioWrapper(Type)
Declaration
public static void OverrideScenarioWrapper(Type scenarioWrapperType)
Parameters
Type |
Name |
Description |
Type |
scenarioWrapperType |
|
ProcessEvent(Event)
Deals with events received by the canvas
Declaration
public bool ProcessEvent(Event e)
Parameters
Type |
Name |
Description |
Event |
e |
|
Returns
ReceiveScenarioDataChanged(object, ScenarioDataChangedEventArgs)
Deals with a signal containing a command
Declaration
public void ReceiveScenarioDataChanged(object sender, ScenarioDataChangedEventArgs args)
Parameters
RegisterCallback<EventType>(EventCallback<EventType>)
Declaration
public void RegisterCallback<EventType>(EventCallback<EventType> callback) where EventType : EventBase<EventType>, new()
Parameters
Type Parameters
Name |
Description |
EventType |
|
RegisterCompleteObjectUndo(string)
Declaration
public virtual void RegisterCompleteObjectUndo(string name)
Parameters
Type |
Name |
Description |
string |
name |
|
RemoveScenarioDataConsumer(ScriptableObject)
Call this method after using the scenario data.
If no data consumer remains, the dialog popup in case of file content change will be disabled
Declaration
public virtual void RemoveScenarioDataConsumer(ScriptableObject consumer)
Parameters
ResetFilePathBeingSaved()
Declaration
protected static void ResetFilePathBeingSaved()
Save(bool)
Declaration
public virtual bool Save(bool askForConfirmation = false)
Parameters
Type |
Name |
Description |
bool |
askForConfirmation |
Should we ask the user to confirm the save
|
Returns
Type |
Description |
bool |
False if the user canceled (if askForConfirmation is True)
|
ScenarioDataChangedEvent(EventBase)
Declaration
public void ScenarioDataChangedEvent(EventBase eventBase)
Parameters
SetFilePathBeingSaved(string)
Declaration
protected static void SetFilePathBeingSaved(string absoluteDestinationPath)
Parameters
Type |
Name |
Description |
string |
absoluteDestinationPath |
|
SetPath(string)
Sets a wrapper path.
If the path is null or empty, it removes the wrapper from the cache.
Declaration
public void SetPath(string absoluteDestinationPath)
Parameters
Type |
Name |
Description |
string |
absoluteDestinationPath |
|
SetScenario(Scenario)
Associates a scenario to a wrapper
Declaration
public void SetScenario(Scenario scenario)
Parameters
Events
ScenarioDataChanged
Signal emitted when the scenario data changed
TODO This might be removable once everything is using UIToolkit ?
Declaration
public event EventHandler<ScenarioDataChangedEventArgs> ScenarioDataChanged
Event Type
ScenarioDirty
Signal emitted when the scenario is dirty
Declaration
public event EventHandler<ScenarioDataChangedEventArgs> ScenarioDirty
Event Type