diff --git a/Assets/Fungus/Editor/AddOptionCommandEditor.cs b/Assets/Fungus/Editor/AddOptionCommandEditor.cs index 87519c76..e7fd86db 100644 --- a/Assets/Fungus/Editor/AddOptionCommandEditor.cs +++ b/Assets/Fungus/Editor/AddOptionCommandEditor.cs @@ -18,7 +18,7 @@ namespace Fungus string newText = EditorGUILayout.TextField(new GUIContent("Text", "Text to display on option button"), t.text); Sequence newSequence = SequenceEditor.SequenceField(new GUIContent("Sequence", "Sequence to execute when this option is selected"), - t.GetParentFungusScript(), + t.GetFungusScript(), t.sequence); AddOptionCommand.Condition newCondition = (AddOptionCommand.Condition)EditorGUILayout.EnumPopup(new GUIContent("Condition", "Conditions for when this option is displayed"), t.condition); diff --git a/Assets/Fungus/Editor/CompareCommandEditor.cs b/Assets/Fungus/Editor/CompareCommandEditor.cs index 835467bf..648feda1 100644 --- a/Assets/Fungus/Editor/CompareCommandEditor.cs +++ b/Assets/Fungus/Editor/CompareCommandEditor.cs @@ -13,7 +13,7 @@ namespace Fungus { CompareCommand t = target as CompareCommand; - FungusScript sc = t.GetParentFungusScript(); + FungusScript sc = t.GetFungusScript(); if (sc == null) { return; @@ -115,11 +115,11 @@ namespace Fungus } Sequence onTrue = SequenceEditor.SequenceField(new GUIContent("On True Sequence", "Sequence to execute if comparision is true"), - t.GetParentFungusScript(), + t.GetFungusScript(), t.onTrueSequence); Sequence onFalse = SequenceEditor.SequenceField(new GUIContent("On False Sequence", "Sequence to execute if comparision is false"), - t.GetParentFungusScript(), + t.GetFungusScript(), t.onFalseSequence); if (onTrue != t.onTrueSequence) diff --git a/Assets/Fungus/Editor/SetVariableCommandEditor.cs b/Assets/Fungus/Editor/SetVariableCommandEditor.cs index c6daab3f..a49fb054 100644 --- a/Assets/Fungus/Editor/SetVariableCommandEditor.cs +++ b/Assets/Fungus/Editor/SetVariableCommandEditor.cs @@ -13,7 +13,7 @@ namespace Fungus { SetVariableCommand t = target as SetVariableCommand; - FungusScript fungusScript = t.GetParentFungusScript(); + FungusScript fungusScript = t.GetFungusScript(); if (fungusScript == null) { return; diff --git a/Assets/Fungus/VisualScripting/AddOptionCommand.cs b/Assets/Fungus/VisualScripting/AddOptionCommand.cs index ebcb5e61..5d67721f 100644 --- a/Assets/Fungus/VisualScripting/AddOptionCommand.cs +++ b/Assets/Fungus/VisualScripting/AddOptionCommand.cs @@ -24,7 +24,8 @@ namespace Fungus { Dialog dialog = Game.GetInstance().dialog; if (dialog != null && - sequence != null) + sequence != null && + !(condition == Condition.HideOnVisited && sequence.GetExecutionCount() > 0)) { dialog.AddOption(text, () => { Stop(); diff --git a/Assets/Fungus/VisualScripting/FungusCommand.cs b/Assets/Fungus/VisualScripting/FungusCommand.cs index b061473b..445cc7f4 100644 --- a/Assets/Fungus/VisualScripting/FungusCommand.cs +++ b/Assets/Fungus/VisualScripting/FungusCommand.cs @@ -22,10 +22,10 @@ namespace Fungus public virtual void Start() { parentSequence = GetComponent(); - parentFungusScript = GetParentFungusScript(); + parentFungusScript = GetFungusScript(); } - public FungusScript GetParentFungusScript() + public FungusScript GetFungusScript() { FungusScript sc = null; diff --git a/Assets/Fungus/VisualScripting/Sequence.cs b/Assets/Fungus/VisualScripting/Sequence.cs index df2727b0..69466d5c 100644 --- a/Assets/Fungus/VisualScripting/Sequence.cs +++ b/Assets/Fungus/VisualScripting/Sequence.cs @@ -22,6 +22,8 @@ namespace Fungus [System.NonSerialized] public FungusCommand activeCommand; + int executionCount; + public virtual void Start() { fungusScript = GetFungusScript(); @@ -67,8 +69,18 @@ namespace Fungus return (fungusScript.activeSequence == this); } + public int GetExecutionCount() + { + return executionCount; + } + public void ExecuteNextCommand(FungusCommand currentCommand = null) { + if (currentCommand == null) + { + executionCount++; + } + activeCommand = null; FungusCommand nextCommand = null;