From 1cf014aa18807f6836521bf731ebe9a84977d16d Mon Sep 17 00:00:00 2001 From: Christopher Date: Wed, 14 Sep 2016 15:24:59 +0100 Subject: [PATCH] Refactored Block to use IBlock --- Assets/Fungus/Flowchart/Scripts/Block.cs | 61 +-------- Assets/Fungus/Flowchart/Scripts/Command.cs | 8 +- .../Fungus/Flowchart/Scripts/EventHandler.cs | 4 +- Assets/Fungus/Flowchart/Scripts/Flowchart.cs | 64 +++++----- Assets/Fungus/Flowchart/Scripts/IBlock.cs | 2 +- Assets/Fungus/Flowchart/Scripts/ICommand.cs | 8 +- Assets/Fungus/Flowchart/Scripts/INode.cs | 15 +++ Assets/Fungus/Flowchart/Scripts/INode.cs.meta | 12 ++ Assets/Fungus/Flowchart/Scripts/Node.cs | 7 +- Assets/Fungus/Scripts/Commands/Call.cs | 4 +- .../Fungus/Scripts/Commands/ControlStage.cs | 2 +- Assets/Fungus/Scripts/Commands/Menu.cs | 2 +- Assets/Fungus/Scripts/Commands/MenuTimer.cs | 2 +- Assets/Fungus/Scripts/Commands/Portrait.cs | 2 +- .../Scripts/Commands/SetInteractable.cs | 2 +- .../Fungus/Scripts/Commands/SetSpriteOrder.cs | 2 +- Assets/Fungus/Scripts/Commands/StopBlock.cs | 2 +- Assets/Fungus/Scripts/Commands/TweenUI.cs | 2 +- .../Fungus/Scripts/Components/Localization.cs | 4 +- .../Fungus/Scripts/Components/MenuDialog.cs | 8 +- Assets/Fungus/Scripts/Editor/BlockEditor.cs | 62 ++++----- .../Fungus/Scripts/Editor/BlockInspector.cs | 10 +- .../Scripts/Editor/CommandListAdaptor.cs | 8 +- .../Scripts/Editor/FlowchartMenuItems.cs | 2 +- .../Fungus/Scripts/Editor/FlowchartWindow.cs | 120 ++++++++++-------- .../Fungus/Scripts/Interfaces/IMenuDialog.cs | 4 +- 26 files changed, 207 insertions(+), 212 deletions(-) create mode 100644 Assets/Fungus/Flowchart/Scripts/INode.cs create mode 100644 Assets/Fungus/Flowchart/Scripts/INode.cs.meta diff --git a/Assets/Fungus/Flowchart/Scripts/Block.cs b/Assets/Fungus/Flowchart/Scripts/Block.cs index ea420328..a679ec0a 100644 --- a/Assets/Fungus/Flowchart/Scripts/Block.cs +++ b/Assets/Fungus/Flowchart/Scripts/Block.cs @@ -106,88 +106,44 @@ namespace Fungus #region IBlock implementation - /// - /// The execution state of the Block. - /// public virtual ExecutionState State { get { return executionState; } } - /// - /// Unique identifier for the Block. - /// public virtual int ItemId { get { return itemId; } set { itemId = value; } } - /// - /// The name of the block node as displayed in the Flowchart window. - /// public virtual string BlockName { get { return blockName; } set { blockName = value; } } - /// - /// Description text to display under the block node - /// public virtual string Description { get { return description; } } - /// - /// An optional Event Handler which can execute the block when an event occurs. - /// public virtual EventHandler _EventHandler { get { return eventHandler; } set { eventHandler = value; } } - /// - /// The currently executing command. - /// public virtual Command ActiveCommand { get { return activeCommand; } } - /// - /// Timer for fading Block execution icon. - /// public virtual float ExecutingIconTimer { get; set; } - /// - /// The list of commands in the sequence. - /// public virtual List CommandList { get { return commandList; } } - /// - /// Controls the next command to execute in the block execution coroutine. - /// public virtual int JumpToCommandIndex { set { jumpToCommandIndex = value; } } - /// - /// Returns the parent Flowchart for this Block. - /// public virtual Flowchart GetFlowchart() { return GetComponent(); } - /// - /// Returns true if the Block is executing a command. - /// public virtual bool IsExecuting() { return (executionState == ExecutionState.Executing); } - /// - /// Returns the number of times this Block has executed. - /// public virtual int GetExecutionCount() { return executionCount; } - /// - /// Start a coroutine which executes all commands in the Block. Only one running instance of each Block is permitted. - /// public virtual void StartExecution() { StartCoroutine(Execute()); } - /// - /// A coroutine method that executes all commands in the Block. Only one running instance of each Block is permitted. - /// - /// Index of command to start execution at - /// Delegate function to call when execution completes public virtual IEnumerator Execute(int commandIndex = 0, Action onComplete = null) { if (executionState != ExecutionState.Idle) @@ -296,9 +252,6 @@ namespace Fungus } } - /// - /// Stop executing commands in this Block. - /// public virtual void Stop() { // Tell the executing command to stop immediately @@ -312,12 +265,9 @@ namespace Fungus jumpToCommandIndex = int.MaxValue; } - /// - /// Returns a list of all Blocks connected to this one. - /// - public virtual List GetConnectedBlocks() + public virtual List GetConnectedBlocks() { - List connectedBlocks = new List(); + var connectedBlocks = new List(); foreach (Command command in commandList) { if (command != null) @@ -328,10 +278,6 @@ namespace Fungus return connectedBlocks; } - /// - /// Returns the type of the previously executing command. - /// - /// The previous active command type. public virtual System.Type GetPreviousActiveCommandType() { if (previousActiveCommandIndex >= 0 && @@ -343,9 +289,6 @@ namespace Fungus return null; } - /// - /// Recalculate the indent levels for all commands in the list. - /// public virtual void UpdateIndentLevels() { int indentLevel = 0; diff --git a/Assets/Fungus/Flowchart/Scripts/Command.cs b/Assets/Fungus/Flowchart/Scripts/Command.cs index b6b83314..7d60a857 100644 --- a/Assets/Fungus/Flowchart/Scripts/Command.cs +++ b/Assets/Fungus/Flowchart/Scripts/Command.cs @@ -87,7 +87,7 @@ namespace Fungus /// This reference is only populated at runtime and in the editor when the /// block is selected. /// - public virtual Block ParentBlock { get; set; } + public virtual IBlock ParentBlock { get; set; } /// /// Returns the Flowchart that this command belongs to. @@ -160,13 +160,13 @@ namespace Fungus /// /// Called when the new command is added to a block in the editor. /// - public virtual void OnCommandAdded(Block parentBlock) + public virtual void OnCommandAdded(IBlock parentBlock) {} /// /// Called when the command is deleted from a block in the editor. /// - public virtual void OnCommandRemoved(Block parentBlock) + public virtual void OnCommandRemoved(IBlock parentBlock) {} /// @@ -190,7 +190,7 @@ namespace Fungus /// /// Populates a list with the Blocks that this command references. /// - public virtual void GetConnectedBlocks(ref List connectedBlocks) + public virtual void GetConnectedBlocks(ref List connectedBlocks) {} /// diff --git a/Assets/Fungus/Flowchart/Scripts/EventHandler.cs b/Assets/Fungus/Flowchart/Scripts/EventHandler.cs index 31b86201..332fc4be 100644 --- a/Assets/Fungus/Flowchart/Scripts/EventHandler.cs +++ b/Assets/Fungus/Flowchart/Scripts/EventHandler.cs @@ -32,7 +32,7 @@ namespace Fungus /// Add an EventHandlerInfo attibute and your new EventHandler class will automatically appear in the /// 'Execute On Event' dropdown menu when a block is selected. /// - [RequireComponent(typeof(Block))] + [RequireComponent(typeof(IBlock))] [RequireComponent(typeof(Flowchart))] [AddComponentMenu("")] public class EventHandler : MonoBehaviour @@ -44,7 +44,7 @@ namespace Fungus [HideInInspector] [FormerlySerializedAs("parentSequence")] [SerializeField] protected Block parentBlock; - public virtual Block ParentBlock { get { return parentBlock; } set { parentBlock = value; } } + public virtual IBlock ParentBlock { get { return parentBlock; } set { parentBlock = (Block)value; } } /// /// The Event Handler should call this method when the event is detected. diff --git a/Assets/Fungus/Flowchart/Scripts/Flowchart.cs b/Assets/Fungus/Flowchart/Scripts/Flowchart.cs index a2826a79..f07289bf 100644 --- a/Assets/Fungus/Flowchart/Scripts/Flowchart.cs +++ b/Assets/Fungus/Flowchart/Scripts/Flowchart.cs @@ -94,7 +94,7 @@ namespace Fungus [HideInInspector] [FormerlySerializedAs("selectedSequence")] [SerializeField] protected Block selectedBlock; - public virtual Block SelectedBlock { get { return selectedBlock; } set { selectedBlock = value; } } + public virtual IBlock SelectedBlock { get { return selectedBlock; } set { selectedBlock = (Block)value; } } /// /// Currently selected command in the Flowchart editor. @@ -203,8 +203,8 @@ namespace Fungus public int NextItemId() { int maxId = -1; - Block[] blocks = GetComponents(); - foreach (Block block in blocks) + IBlock[] blocks = GetComponents(); + foreach (IBlock block in blocks) { maxId = Math.Max(maxId, block.ItemId); } @@ -309,8 +309,8 @@ namespace Fungus // Make sure item ids are unique and monotonically increasing. // This should always be the case, but some legacy Flowcharts may have issues. List usedIds = new List(); - Block[] blocks = GetComponents(); - foreach (Block block in blocks) + IBlock[] blocks = GetComponents(); + foreach (IBlock block in blocks) { if (block.ItemId == -1 || usedIds.Contains(block.ItemId)) @@ -338,7 +338,7 @@ namespace Fungus // Unreferenced components don't have any effect on the flowchart behavior, but // they waste memory so should be cleared out periodically. - Block[] blocks = GetComponents(); + IBlock[] blocks = GetComponents(); // Remove any null entries in the variables list // It shouldn't happen but it seemed to occur for a user on the forum @@ -355,7 +355,7 @@ namespace Fungus foreach (Command command in GetComponents()) { bool found = false; - foreach (Block block in blocks) + foreach (IBlock block in blocks) { if (block.CommandList.Contains(command)) { @@ -373,7 +373,7 @@ namespace Fungus foreach (EventHandler eventHandler in GetComponents()) { bool found = false; - foreach (Block block in blocks) + foreach (IBlock block in blocks) { if (block._EventHandler == eventHandler) { @@ -411,9 +411,9 @@ namespace Fungus /// /// Returns the named Block in the flowchart, or null if not found. /// - public virtual Block FindBlock(string blockName) + public virtual IBlock FindBlock(string blockName) { - Block [] blocks = GetComponents(); + IBlock [] blocks = GetComponents(); foreach (Block block in blocks) { if (block.BlockName == blockName) @@ -430,8 +430,8 @@ namespace Fungus /// You can use this method in a UI event. e.g. to handle a button click. public virtual void ExecuteBlock(string blockName) { - Block block = null; - foreach (Block b in GetComponents()) + IBlock block = null; + foreach (IBlock b in GetComponents()) { if (b.BlockName == blockName) { @@ -458,7 +458,7 @@ namespace Fungus /// This version provides extra options to control how the block is executed. /// Returns true if the Block started execution. /// - public virtual bool ExecuteBlock(Block block, int commandIndex = 0, Action onComplete = null) + public virtual bool ExecuteBlock(IBlock block, int commandIndex = 0, Action onComplete = null) { if (block == null) { @@ -466,7 +466,7 @@ namespace Fungus return false; } - if (block.gameObject != gameObject) + if (((Block)block).gameObject != gameObject) { Debug.LogError("Block must belong to the same gameobject as this Flowchart"); return false; @@ -489,8 +489,8 @@ namespace Fungus /// public virtual void StopAllBlocks() { - Block [] blocks = GetComponents(); - foreach (Block block in blocks) + IBlock [] blocks = GetComponents(); + foreach (IBlock block in blocks) { if (block.IsExecuting()) { @@ -577,7 +577,7 @@ namespace Fungus /// /// Returns a new Block key that is guaranteed not to clash with any existing Block in the Flowchart. /// - public virtual string GetUniqueBlockKey(string originalKey, Block ignoreBlock = null) + public virtual string GetUniqueBlockKey(string originalKey, IBlock ignoreBlock = null) { int suffix = 0; string baseKey = originalKey.Trim(); @@ -588,13 +588,13 @@ namespace Fungus baseKey = "New Block"; } - Block[] blocks = GetComponents(); + IBlock[] blocks = GetComponents(); string key = baseKey; while (true) { bool collision = false; - foreach(Block block in blocks) + foreach(IBlock block in blocks) { if (block == ignoreBlock || block.BlockName == null) @@ -631,7 +631,7 @@ namespace Fungus baseKey = "New Label"; } - Block block = ignoreLabel.ParentBlock; + IBlock block = ignoreLabel.ParentBlock; string key = baseKey; while (true) @@ -871,13 +871,15 @@ namespace Fungus { if (hideComponents) { - Block[] blocks = GetComponents(); - foreach (Block block in blocks) + IBlock[] blocks = GetComponents(); + foreach (IBlock block in blocks) { - block.hideFlags = HideFlags.HideInInspector; - if (block.gameObject != gameObject) + GameObject go = ((Block)block).gameObject; + + go.hideFlags = HideFlags.HideInInspector; + if (go != gameObject) { - block.gameObject.hideFlags = HideFlags.HideInHierarchy; + go.hideFlags = HideFlags.HideInHierarchy; } } @@ -975,8 +977,8 @@ namespace Fungus /// public virtual bool HasExecutingBlocks() { - Block[] blocks = GetComponents(); - foreach (Block block in blocks) + IBlock[] blocks = GetComponents(); + foreach (IBlock block in blocks) { if (block.IsExecuting()) { @@ -989,12 +991,12 @@ namespace Fungus /// /// Returns a list of all executing blocks in this Flowchart. /// - public virtual List GetExecutingBlocks() + public virtual List GetExecutingBlocks() { - List executingBlocks = new List(); + List executingBlocks = new List(); - Block[] blocks = GetComponents(); - foreach (Block block in blocks) + IBlock[] blocks = GetComponents(); + foreach (IBlock block in blocks) { if (block.IsExecuting()) { diff --git a/Assets/Fungus/Flowchart/Scripts/IBlock.cs b/Assets/Fungus/Flowchart/Scripts/IBlock.cs index c8e02abe..7ff19109 100644 --- a/Assets/Fungus/Flowchart/Scripts/IBlock.cs +++ b/Assets/Fungus/Flowchart/Scripts/IBlock.cs @@ -98,7 +98,7 @@ namespace Fungus /// /// Returns a list of all Blocks connected to this one. /// - List GetConnectedBlocks(); + List GetConnectedBlocks(); /// /// Returns the type of the previously executing command. diff --git a/Assets/Fungus/Flowchart/Scripts/ICommand.cs b/Assets/Fungus/Flowchart/Scripts/ICommand.cs index 699ff8a5..3dd97655 100644 --- a/Assets/Fungus/Flowchart/Scripts/ICommand.cs +++ b/Assets/Fungus/Flowchart/Scripts/ICommand.cs @@ -45,7 +45,7 @@ namespace Fungus /// This reference is only populated at runtime and in the editor when the /// block is selected. /// - Block ParentBlock { get; set; } + IBlock ParentBlock { get; set; } /// /// Returns the Flowchart that this command belongs to. @@ -84,12 +84,12 @@ namespace Fungus /// /// Called when the new command is added to a block in the editor. /// - void OnCommandAdded(Block parentBlock); + void OnCommandAdded(IBlock parentBlock); /// /// Called when the command is deleted from a block in the editor. /// - void OnCommandRemoved(Block parentBlock); + void OnCommandRemoved(IBlock parentBlock); /// /// Called when this command starts execution. @@ -109,7 +109,7 @@ namespace Fungus /// /// Populates a list with the Blocks that this command references. /// - void GetConnectedBlocks(ref List connectedBlocks); + void GetConnectedBlocks(ref List connectedBlocks); /// /// Returns true if this command references the variable. diff --git a/Assets/Fungus/Flowchart/Scripts/INode.cs b/Assets/Fungus/Flowchart/Scripts/INode.cs new file mode 100644 index 00000000..0285a067 --- /dev/null +++ b/Assets/Fungus/Flowchart/Scripts/INode.cs @@ -0,0 +1,15 @@ +using UnityEngine; + +namespace Fungus +{ + /// + /// Flowchart nodes. + /// + public interface INode + { + /// + /// Returns the display rect. + /// + Rect _NodeRect { get; set; } + } +} \ No newline at end of file diff --git a/Assets/Fungus/Flowchart/Scripts/INode.cs.meta b/Assets/Fungus/Flowchart/Scripts/INode.cs.meta new file mode 100644 index 00000000..9be7487a --- /dev/null +++ b/Assets/Fungus/Flowchart/Scripts/INode.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e9eea916a931c4fed81b254bae8c0b93 +timeCreated: 1473862805 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Fungus/Flowchart/Scripts/Node.cs b/Assets/Fungus/Flowchart/Scripts/Node.cs index 27fac885..268b45a9 100644 --- a/Assets/Fungus/Flowchart/Scripts/Node.cs +++ b/Assets/Fungus/Flowchart/Scripts/Node.cs @@ -9,9 +9,14 @@ namespace Fungus /// Base class for Flowchart nodes. /// [AddComponentMenu("")] - public class Node : MonoBehaviour + public class Node : MonoBehaviour, INode { [SerializeField] protected Rect nodeRect = new Rect(0, 0, 120, 30); + + #region INode implementation + public virtual Rect _NodeRect { get { return nodeRect; } set { nodeRect = value; } } + + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/Call.cs b/Assets/Fungus/Scripts/Commands/Call.cs index e3670414..223eae26 100644 --- a/Assets/Fungus/Scripts/Commands/Call.cs +++ b/Assets/Fungus/Scripts/Commands/Call.cs @@ -45,7 +45,7 @@ namespace Fungus if (targetBlock != null) { // Check if calling your own parent block - if (targetBlock == ParentBlock) + if (ParentBlock.Equals(targetBlock)) { // Just ignore the callmode in this case, and jump to first command in list Continue(0); @@ -91,7 +91,7 @@ namespace Fungus } } - public override void GetConnectedBlocks(ref List connectedBlocks) + public override void GetConnectedBlocks(ref List connectedBlocks) { if (targetBlock != null) { diff --git a/Assets/Fungus/Scripts/Commands/ControlStage.cs b/Assets/Fungus/Scripts/Commands/ControlStage.cs index d0c43dbd..73e67ef8 100644 --- a/Assets/Fungus/Scripts/Commands/ControlStage.cs +++ b/Assets/Fungus/Scripts/Commands/ControlStage.cs @@ -197,7 +197,7 @@ namespace Fungus return new Color32(230, 200, 250, 255); } - public override void OnCommandAdded(Block parentBlock) + public override void OnCommandAdded(IBlock parentBlock) { //Default to display type: show display = StageDisplayType.Show; diff --git a/Assets/Fungus/Scripts/Commands/Menu.cs b/Assets/Fungus/Scripts/Commands/Menu.cs index 09340e28..c29167a9 100644 --- a/Assets/Fungus/Scripts/Commands/Menu.cs +++ b/Assets/Fungus/Scripts/Commands/Menu.cs @@ -62,7 +62,7 @@ namespace Fungus Continue(); } - public override void GetConnectedBlocks(ref List connectedBlocks) + public override void GetConnectedBlocks(ref List connectedBlocks) { if (targetBlock != null) { diff --git a/Assets/Fungus/Scripts/Commands/MenuTimer.cs b/Assets/Fungus/Scripts/Commands/MenuTimer.cs index 4e17ed81..24ceb68a 100644 --- a/Assets/Fungus/Scripts/Commands/MenuTimer.cs +++ b/Assets/Fungus/Scripts/Commands/MenuTimer.cs @@ -37,7 +37,7 @@ namespace Fungus Continue(); } - public override void GetConnectedBlocks(ref List connectedBlocks) + public override void GetConnectedBlocks(ref List connectedBlocks) { if (targetBlock != null) { diff --git a/Assets/Fungus/Scripts/Commands/Portrait.cs b/Assets/Fungus/Scripts/Commands/Portrait.cs index 4e119220..f1600d92 100644 --- a/Assets/Fungus/Scripts/Commands/Portrait.cs +++ b/Assets/Fungus/Scripts/Commands/Portrait.cs @@ -207,7 +207,7 @@ namespace Fungus return new Color32(230, 200, 250, 255); } - public override void OnCommandAdded(Block parentBlock) + public override void OnCommandAdded(IBlock parentBlock) { //Default to display type: show display = DisplayType.Show; diff --git a/Assets/Fungus/Scripts/Commands/SetInteractable.cs b/Assets/Fungus/Scripts/Commands/SetInteractable.cs index 5357c2ab..b967b4df 100644 --- a/Assets/Fungus/Scripts/Commands/SetInteractable.cs +++ b/Assets/Fungus/Scripts/Commands/SetInteractable.cs @@ -81,7 +81,7 @@ namespace Fungus return new Color32(180, 250, 250, 255); } - public override void OnCommandAdded(Block parentBlock) + public override void OnCommandAdded(IBlock parentBlock) { targetObjects.Add(null); } diff --git a/Assets/Fungus/Scripts/Commands/SetSpriteOrder.cs b/Assets/Fungus/Scripts/Commands/SetSpriteOrder.cs index 06f615f1..8fe4f663 100644 --- a/Assets/Fungus/Scripts/Commands/SetSpriteOrder.cs +++ b/Assets/Fungus/Scripts/Commands/SetSpriteOrder.cs @@ -72,7 +72,7 @@ namespace Fungus return false; } - public override void OnCommandAdded(Block parentBlock) + public override void OnCommandAdded(IBlock parentBlock) { // Add a default empty entry targetSprites.Add(null); diff --git a/Assets/Fungus/Scripts/Commands/StopBlock.cs b/Assets/Fungus/Scripts/Commands/StopBlock.cs index f7a3f89e..3afcefd4 100644 --- a/Assets/Fungus/Scripts/Commands/StopBlock.cs +++ b/Assets/Fungus/Scripts/Commands/StopBlock.cs @@ -31,7 +31,7 @@ namespace Fungus flowchart = GetFlowchart(); } - Block block = flowchart.FindBlock(blockName.Value); + IBlock block = flowchart.FindBlock(blockName.Value); if (block == null || !block.IsExecuting()) { diff --git a/Assets/Fungus/Scripts/Commands/TweenUI.cs b/Assets/Fungus/Scripts/Commands/TweenUI.cs index 4cba1bf7..6a56e2ed 100644 --- a/Assets/Fungus/Scripts/Commands/TweenUI.cs +++ b/Assets/Fungus/Scripts/Commands/TweenUI.cs @@ -65,7 +65,7 @@ namespace Fungus Continue(); } - public override void OnCommandAdded(Block parentBlock) + public override void OnCommandAdded(IBlock parentBlock) { // Add an empty slot by default. Saves an unnecessary user click. if (targetObjects.Count == 0) diff --git a/Assets/Fungus/Scripts/Components/Localization.cs b/Assets/Fungus/Scripts/Components/Localization.cs index 3dcf540a..375e884b 100644 --- a/Assets/Fungus/Scripts/Components/Localization.cs +++ b/Assets/Fungus/Scripts/Components/Localization.cs @@ -138,8 +138,8 @@ namespace Fungus Flowchart[] flowcharts = GameObject.FindObjectsOfType(); foreach (Flowchart flowchart in flowcharts) { - Block[] blocks = flowchart.GetComponents(); - foreach (Block block in blocks) + IBlock[] blocks = flowchart.GetComponents(); + foreach (IBlock block in blocks) { foreach (Command command in block.CommandList) { diff --git a/Assets/Fungus/Scripts/Components/MenuDialog.cs b/Assets/Fungus/Scripts/Components/MenuDialog.cs index d76ca18e..2f0a6b52 100644 --- a/Assets/Fungus/Scripts/Components/MenuDialog.cs +++ b/Assets/Fungus/Scripts/Components/MenuDialog.cs @@ -72,7 +72,7 @@ namespace Fungus Canvas.ForceUpdateCanvases(); } - protected virtual IEnumerator WaitForTimeout(float timeoutDuration, Block targetBlock) + protected virtual IEnumerator WaitForTimeout(float timeoutDuration, IBlock targetBlock) { float elapsedTime = 0; @@ -147,7 +147,7 @@ namespace Fungus } } - public virtual bool AddOption(string text, bool interactable, Block targetBlock) + public virtual bool AddOption(string text, bool interactable, IBlock targetBlock) { bool addedOption = false; foreach (Button button in cachedButtons) @@ -169,7 +169,7 @@ namespace Fungus textComponent.text = text; } - Block block = targetBlock; + IBlock block = targetBlock; button.onClick.AddListener(delegate { @@ -244,7 +244,7 @@ namespace Fungus return addedOption; } - public virtual void ShowTimer(float duration, Block targetBlock) + public virtual void ShowTimer(float duration, IBlock targetBlock) { if (cachedSlider != null) { diff --git a/Assets/Fungus/Scripts/Editor/BlockEditor.cs b/Assets/Fungus/Scripts/Editor/BlockEditor.cs index 9a84341b..7420a2a0 100644 --- a/Assets/Fungus/Scripts/Editor/BlockEditor.cs +++ b/Assets/Fungus/Scripts/Editor/BlockEditor.cs @@ -20,13 +20,13 @@ namespace Fungus { protected class SetEventHandlerOperation { - public Block block; + public IBlock block; public Type eventHandlerType; } protected class AddCommandOperation { - public Block block; + public IBlock block; public Type commandType; public int index; } @@ -59,7 +59,7 @@ namespace Fungus EditorGUI.PropertyField(blockNameRect, blockNameProperty, new GUIContent("")); // Ensure block name is unique for this Flowchart - Block block = target as Block; + IBlock block = target as IBlock; string uniqueName = flowchart.GetUniqueBlockKey(blockNameProperty.stringValue, block); if (uniqueName != block.BlockName) { @@ -89,7 +89,7 @@ namespace Fungus actionList.Clear(); } - Block block = target as Block; + IBlock block = target as IBlock; SerializedProperty commandListProperty = serializedObject.FindProperty("commandList"); @@ -114,7 +114,7 @@ namespace Fungus ReorderableListGUI.Title("Commands"); CommandListAdaptor adaptor = new CommandListAdaptor(commandListProperty, 0); - adaptor.nodeRect = block._NodeRect; + adaptor.nodeRect = (block as INode)._NodeRect; ReorderableListFlags flags = ReorderableListFlags.HideAddButton | ReorderableListFlags.HideRemoveButtons | ReorderableListFlags.DisableContextMenu; @@ -305,7 +305,7 @@ namespace Fungus // event handler selected. List eventHandlerTypes = EditorExtensions.FindDerivedTypes(typeof(EventHandler)).ToList(); - Block block = target as Block; + IBlock block = target as IBlock; System.Type currentType = null; if (block._EventHandler != null) { @@ -382,14 +382,14 @@ namespace Fungus protected void OnSelectEventHandler(object obj) { SetEventHandlerOperation operation = obj as SetEventHandlerOperation; - Block block = operation.block; + IBlock block = operation.block; System.Type selectedType = operation.eventHandlerType; if (block == null) { return; } - Undo.RecordObject(block, "Set Event Handler"); + Undo.RecordObject((Block)block, "Set Event Handler"); if (block._EventHandler != null) { @@ -398,13 +398,13 @@ namespace Fungus if (selectedType != null) { - EventHandler newHandler = Undo.AddComponent(block.gameObject, selectedType) as EventHandler; + EventHandler newHandler = Undo.AddComponent(((Block)block).gameObject, selectedType) as EventHandler; newHandler.ParentBlock = block; block._EventHandler = newHandler; } // Because this is an async call, we need to force prefab instances to record changes - PrefabUtility.RecordPrefabInstancePropertyModifications(block); + PrefabUtility.RecordPrefabInstancePropertyModifications((Block)block); } static public void BlockField(SerializedProperty property, GUIContent label, GUIContent nullLabel, Flowchart flowchart) @@ -414,14 +414,14 @@ namespace Fungus return; } - Block block = property.objectReferenceValue as Block; + IBlock block = property.objectReferenceValue as IBlock; // Build dictionary of child blocks List blockNames = new List(); int selectedIndex = 0; blockNames.Add(nullLabel); - Block[] blocks = flowchart.GetComponents(); + IBlock[] blocks = flowchart.GetComponents(); for (int i = 0; i < blocks.Length; ++i) { blockNames.Add(new GUIContent(blocks[i].BlockName)); @@ -442,7 +442,7 @@ namespace Fungus block = blocks[selectedIndex - 1]; } - property.objectReferenceValue = block; + property.objectReferenceValue = (Block)block; } static public Block BlockField(Rect position, GUIContent nullLabel, Flowchart flowchart, Block block) @@ -631,7 +631,7 @@ namespace Fungus protected virtual void ShowCommandMenu() { - Block block = target as Block; + IBlock block = target as IBlock; Flowchart flowchart = block.GetFlowchart(); @@ -722,7 +722,7 @@ namespace Fungus { AddCommandOperation commandOperation = obj as AddCommandOperation; - Block block = commandOperation.block; + IBlock block = commandOperation.block; if (block == null) { return; @@ -732,7 +732,7 @@ namespace Fungus flowchart.ClearSelectedCommands(); - Command newCommand = Undo.AddComponent(block.gameObject, commandOperation.commandType) as Command; + Command newCommand = Undo.AddComponent(((Block)block).gameObject, commandOperation.commandType) as Command; block.GetFlowchart().AddSelectedCommand(newCommand); newCommand.ParentBlock = block; newCommand.ItemId = flowchart.NextItemId(); @@ -740,7 +740,7 @@ namespace Fungus // Let command know it has just been added to the block newCommand.OnCommandAdded(block); - Undo.RecordObject(block, "Set command type"); + Undo.RecordObject((Block)block, "Set command type"); if (commandOperation.index < block.CommandList.Count - 1) { block.CommandList.Insert(commandOperation.index, newCommand); @@ -751,12 +751,12 @@ namespace Fungus } // Because this is an async call, we need to force prefab instances to record changes - PrefabUtility.RecordPrefabInstancePropertyModifications(block); + PrefabUtility.RecordPrefabInstancePropertyModifications((Block)block); } public virtual void ShowContextMenu() { - Block block = target as Block; + IBlock block = target as IBlock; Flowchart flowchart = block.GetFlowchart(); if (flowchart == null) @@ -844,7 +844,7 @@ namespace Fungus protected void SelectAll() { - Block block = target as Block; + IBlock block = target as IBlock; Flowchart flowchart = block.GetFlowchart(); if (flowchart == null || @@ -865,7 +865,7 @@ namespace Fungus protected void SelectNone() { - Block block = target as Block; + IBlock block = target as IBlock; Flowchart flowchart = block.GetFlowchart(); if (flowchart == null || @@ -888,7 +888,7 @@ namespace Fungus protected void Copy() { - Block block = target as Block; + IBlock block = target as IBlock; Flowchart flowchart = block.GetFlowchart(); if (flowchart == null || @@ -918,7 +918,7 @@ namespace Fungus protected void Paste() { - Block block = target as Block; + IBlock block = target as IBlock; Flowchart flowchart = block.GetFlowchart(); if (flowchart == null || @@ -970,14 +970,14 @@ namespace Fungus } // Because this is an async call, we need to force prefab instances to record changes - PrefabUtility.RecordPrefabInstancePropertyModifications(block); + PrefabUtility.RecordPrefabInstancePropertyModifications((Block)block); Repaint(); } protected void Delete() { - Block block = target as Block; + IBlock block = target as IBlock; Flowchart flowchart = block.GetFlowchart(); if (flowchart == null || @@ -998,7 +998,7 @@ namespace Fungus // Order of destruction is important here for undo to work Undo.DestroyObjectImmediate(command); - Undo.RecordObject(flowchart.SelectedBlock, "Delete"); + Undo.RecordObject((Block)flowchart.SelectedBlock, "Delete"); flowchart.SelectedBlock.CommandList.RemoveAt(i); lastSelectedIndex = i; @@ -1022,7 +1022,7 @@ namespace Fungus protected void PlayCommand() { - Block targetBlock = target as Block; + IBlock targetBlock = target as IBlock; Flowchart flowchart = targetBlock.GetFlowchart(); Command command = flowchart.SelectedCommands[0]; if (targetBlock.IsExecuting()) @@ -1042,7 +1042,7 @@ namespace Fungus protected void StopAllPlayCommand() { - Block targetBlock = target as Block; + IBlock targetBlock = target as IBlock; Flowchart flowchart = targetBlock.GetFlowchart(); Command command = flowchart.SelectedCommands[0]; @@ -1051,7 +1051,7 @@ namespace Fungus flowchart.StartCoroutine(RunBlock(flowchart, targetBlock, command.CommandIndex, 0.2f)); } - protected IEnumerator RunBlock(Flowchart flowchart, Block targetBlock, int commandIndex, float delay) + protected IEnumerator RunBlock(Flowchart flowchart, IBlock targetBlock, int commandIndex, float delay) { yield return new WaitForSeconds(delay); flowchart.ExecuteBlock(targetBlock, commandIndex); @@ -1059,7 +1059,7 @@ namespace Fungus protected void SelectPrevious() { - Block block = target as Block; + IBlock block = target as IBlock; Flowchart flowchart = block.GetFlowchart(); int firstSelectedIndex = flowchart.SelectedBlock.CommandList.Count; @@ -1099,7 +1099,7 @@ namespace Fungus protected void SelectNext() { - Block block = target as Block; + IBlock block = target as IBlock; Flowchart flowchart = block.GetFlowchart(); int lastSelectedIndex = -1; diff --git a/Assets/Fungus/Scripts/Editor/BlockInspector.cs b/Assets/Fungus/Scripts/Editor/BlockInspector.cs index 02962d28..833f098a 100644 --- a/Assets/Fungus/Scripts/Editor/BlockInspector.cs +++ b/Assets/Fungus/Scripts/Editor/BlockInspector.cs @@ -70,20 +70,20 @@ namespace Fungus public override void OnInspectorGUI () { BlockInspector blockInspector = target as BlockInspector; - Block block = blockInspector.block; - - if (block == null) + if (blockInspector.block == null) { return; } + IBlock block = blockInspector.block; + Flowchart flowchart = block.GetFlowchart(); if (activeBlockEditor == null || - block != activeBlockEditor.target) + !block.Equals(activeBlockEditor.target)) { DestroyImmediate(activeBlockEditor); - activeBlockEditor = Editor.CreateEditor(block) as BlockEditor; + activeBlockEditor = Editor.CreateEditor((Block)block) as BlockEditor; } activeBlockEditor.DrawBlockName(flowchart); diff --git a/Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs b/Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs index 352401a5..0dd64147 100644 --- a/Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs +++ b/Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs @@ -84,13 +84,13 @@ namespace Fungus return null; } - Block block = flowchart.SelectedBlock; + IBlock block = flowchart.SelectedBlock; if (block == null) { return null; } - Command newCommand = Undo.AddComponent(block.gameObject) as Command; + Command newCommand = Undo.AddComponent(((Block)block).gameObject) as Command; newCommand.ItemId = flowchart.NextItemId(); flowchart.ClearSelectedCommands(); flowchart.AddSelectedCommand(newCommand); @@ -103,10 +103,10 @@ namespace Fungus Command command = _arrayProperty.GetArrayElementAtIndex(index).objectReferenceValue as Command; // Add the command as a new component - Block parentBlock = command.GetComponent(); + IBlock parentBlock = command.GetComponent(); System.Type type = command.GetType(); - Command newCommand = Undo.AddComponent(parentBlock.gameObject, type) as Command; + Command newCommand = Undo.AddComponent(((Block)parentBlock).gameObject, type) as Command; newCommand.ItemId = newCommand.GetFlowchart().NextItemId(); System.Reflection.FieldInfo[] fields = type.GetFields(); foreach (System.Reflection.FieldInfo field in fields) diff --git a/Assets/Fungus/Scripts/Editor/FlowchartMenuItems.cs b/Assets/Fungus/Scripts/Editor/FlowchartMenuItems.cs index 63794ade..5ee63a14 100644 --- a/Assets/Fungus/Scripts/Editor/FlowchartMenuItems.cs +++ b/Assets/Fungus/Scripts/Editor/FlowchartMenuItems.cs @@ -24,7 +24,7 @@ namespace Fungus // Only the first created Flowchart in the scene should have a default GameStarted block if (GameObject.FindObjectsOfType().Length > 1) { - Block block = go.GetComponent(); + IBlock block = go.GetComponent(); block._EventHandler = null; GameObject.DestroyImmediate(block._EventHandler); } diff --git a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs index 26b5c3f4..c3311feb 100644 --- a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs +++ b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs @@ -12,9 +12,9 @@ namespace Fungus { public class FlowchartWindow : EditorWindow { - public static List deleteList = new List(); + public static List deleteList = new List(); - protected List windowBlockMap = new List(); + protected List windowBlockMap = new List(); // The ReorderableList control doesn't drag properly when used with GUI.DragWindow(), // so we just implement dragging ourselves. @@ -74,7 +74,7 @@ namespace Fungus { ShowBlockInspector(flowchart); } - blockInspector.block = flowchart.SelectedBlock; + blockInspector.block = (Block)flowchart.SelectedBlock; } forceRepaintCount--; @@ -117,7 +117,7 @@ namespace Fungus } // Delete any scheduled objects - foreach (Block deleteBlock in deleteList) + foreach (IBlock deleteBlock in deleteList) { bool isSelected = (flowchart.SelectedBlock == deleteBlock); @@ -126,7 +126,7 @@ namespace Fungus Undo.DestroyObjectImmediate(command); } - Undo.DestroyObjectImmediate(deleteBlock); + Undo.DestroyObjectImmediate((Block)deleteBlock); flowchart.ClearSelectedCommands(); if (isSelected) @@ -219,15 +219,21 @@ namespace Fungus protected virtual void DrawFlowchartView(Flowchart flowchart) { - Block[] blocks = flowchart.GetComponents(); + IBlock[] blocks = flowchart.GetComponents(); - foreach (Block block in blocks) + foreach (IBlock block in blocks) { + var node = block as INode; + if (node == null) + { + continue; + } + var newRect = new Rect(); - newRect.xMin = Mathf.Min(flowchart.ScrollViewRect.xMin, block._NodeRect.xMin - 400); - newRect.xMax = Mathf.Max(flowchart.ScrollViewRect.xMax, block._NodeRect.xMax + 400); - newRect.yMin = Mathf.Min(flowchart.ScrollViewRect.yMin, block._NodeRect.yMin - 400); - newRect.yMax = Mathf.Max(flowchart.ScrollViewRect.yMax, block._NodeRect.yMax + 400); + newRect.xMin = Mathf.Min(flowchart.ScrollViewRect.xMin, node._NodeRect.xMin - 400); + newRect.xMax = Mathf.Max(flowchart.ScrollViewRect.xMax, node._NodeRect.xMax + 400); + newRect.yMin = Mathf.Min(flowchart.ScrollViewRect.yMin, node._NodeRect.yMin - 400); + newRect.yMax = Mathf.Max(flowchart.ScrollViewRect.yMax, node._NodeRect.yMax + 400); flowchart.ScrollViewRect = newRect; } @@ -257,11 +263,11 @@ namespace Fungus CalcFlowchartCenter(flowchart, blocks); // Draw connections - foreach (Block block in blocks) + foreach (IBlock block in blocks) { DrawConnections(flowchart, block, false); } - foreach (Block block in blocks) + foreach (IBlock block in blocks) { DrawConnections(flowchart, block, true); } @@ -274,7 +280,7 @@ namespace Fungus windowBlockMap.Clear(); for (int i = 0; i < blocks.Length; ++i) { - Block block = blocks[i]; + IBlock block = blocks[i]; float nodeWidthA = nodeStyle.CalcSize(new GUIContent(block.BlockName)).x + 10; float nodeWidthB = 0f; @@ -282,10 +288,12 @@ namespace Fungus { nodeWidthB = nodeStyle.CalcSize(new GUIContent(block._EventHandler.GetSummary())).x + 10; } - + + var node = block as INode; + if (Event.current.button == 0) { - Rect tempRect = block._NodeRect; + Rect tempRect = node._NodeRect; tempRect.width = Mathf.Max(Mathf.Max(nodeWidthA, nodeWidthB), 120); tempRect.height = 40; @@ -304,7 +312,7 @@ namespace Fungus tempRect.x = startDragPosition.x; tempRect.y = startDragPosition.y; - Undo.RecordObject(block, "Node Position"); + Undo.RecordObject((Block)block, "Node Position"); tempRect.x = newPos.x; tempRect.y = newPos.y; @@ -313,10 +321,10 @@ namespace Fungus forceRepaintCount = 6; } - block._NodeRect = tempRect; + node._NodeRect = tempRect; } - Rect windowRect = new Rect(block._NodeRect); + Rect windowRect = new Rect(node._NodeRect); windowRect.x += flowchart.ScrollPos.x; windowRect.y += flowchart.ScrollPos.y; @@ -330,7 +338,7 @@ namespace Fungus EndWindows(); // Draw Event Handler labels - foreach (Block block in blocks) + foreach (IBlock block in blocks) { if (block._EventHandler != null) { @@ -347,8 +355,10 @@ namespace Fungus handlerStyle.margin.bottom = 0; handlerStyle.alignment = TextAnchor.MiddleCenter; - Rect rect = new Rect(block._NodeRect); - rect.height = handlerStyle.CalcHeight(new GUIContent(handlerLabel), block._NodeRect.width); + INode node = block as INode; + + Rect rect = new Rect(node._NodeRect); + rect.height = handlerStyle.CalcHeight(new GUIContent(handlerLabel), node._NodeRect.width); rect.x += flowchart.ScrollPos.x; rect.y += flowchart.ScrollPos.y - rect.height; @@ -360,7 +370,7 @@ namespace Fungus // Draw play icons beside all executing blocks if (Application.isPlaying) { - foreach (Block b in blocks) + foreach (IBlock b in blocks) { if (b.IsExecuting()) { @@ -371,7 +381,9 @@ namespace Fungus if (b.ExecutingIconTimer > Time.realtimeSinceStartup) { - Rect rect = new Rect(b._NodeRect); + INode node = b as INode; + + Rect rect = new Rect(node._NodeRect); rect.x += flowchart.ScrollPos.x - 37; rect.y += flowchart.ScrollPos.y + 3; @@ -402,7 +414,7 @@ namespace Fungus EditorZoomArea.End(); } - public virtual void CalcFlowchartCenter(Flowchart flowchart, Block[] blocks) + public virtual void CalcFlowchartCenter(Flowchart flowchart, IBlock[] blocks) { if (flowchart == null || blocks.Count() == 0) @@ -410,15 +422,17 @@ namespace Fungus return; } - Vector2 min = blocks[0]._NodeRect.min; - Vector2 max = blocks[0]._NodeRect.max; + Vector2 min = (blocks[0] as INode)._NodeRect.min; + Vector2 max = (blocks[0] as INode)._NodeRect.max; - foreach (Block block in blocks) + foreach (IBlock block in blocks) { - min.x = Mathf.Min(min.x, block._NodeRect.center.x); - min.y = Mathf.Min(min.y, block._NodeRect.center.y); - max.x = Mathf.Max(max.x, block._NodeRect.center.x); - max.y = Mathf.Max(max.y, block._NodeRect.center.y); + INode node = block as INode; + + min.x = Mathf.Min(min.x, node._NodeRect.center.x); + min.y = Mathf.Min(min.y, node._NodeRect.center.y); + max.x = Mathf.Max(max.x, node._NodeRect.center.x); + max.y = Mathf.Max(max.y, node._NodeRect.center.y); } Vector2 center = (min + max) * -0.5f; @@ -522,7 +536,7 @@ namespace Fungus } } - protected virtual void SelectBlock(Flowchart flowchart, Block block) + protected virtual void SelectBlock(Flowchart flowchart, IBlock block) { // Select the block and also select currently executing command ShowBlockInspector(flowchart); @@ -545,20 +559,20 @@ namespace Fungus return newBlock; } - protected virtual void DeleteBlock(Flowchart flowchart, Block block) + protected virtual void DeleteBlock(Flowchart flowchart, IBlock block) { foreach (Command command in block.CommandList) { Undo.DestroyObjectImmediate(command); } - Undo.DestroyObjectImmediate(block); + Undo.DestroyObjectImmediate((Block)block); flowchart.ClearSelectedCommands(); } protected virtual void DrawWindow(int windowId) { - Block block = windowBlockMap[windowId]; + IBlock block = windowBlockMap[windowId]; Flowchart flowchart = block.GetFlowchart(); if (flowchart == null) @@ -576,8 +590,11 @@ namespace Fungus Event.current.alt == false) { dragWindowId = windowId; - startDragPosition.x = block._NodeRect.x; - startDragPosition.y = block._NodeRect.y; + + var node = block as INode; + + startDragPosition.x = node._NodeRect.x; + startDragPosition.y = node._NodeRect.y; } if (windowId < windowBlockMap.Count) @@ -601,9 +618,9 @@ namespace Fungus else { // Count the number of unique connections (excluding self references) - List uniqueList = new List(); - List connectedBlocks = block.GetConnectedBlocks(); - foreach (Block connectedBlock in connectedBlocks) + List uniqueList = new List(); + List connectedBlocks = block.GetConnectedBlocks(); + foreach (IBlock connectedBlock in connectedBlocks) { if (connectedBlock == block || uniqueList.Contains(connectedBlock)) @@ -626,13 +643,14 @@ namespace Fungus nodeStyleCopy.normal.textColor = Color.black; // Make sure node is wide enough to fit the node name text + var n = block as INode; float width = nodeStyleCopy.CalcSize(new GUIContent(block.BlockName)).x; - Rect tempRect = block._NodeRect; - tempRect.width = Mathf.Max (block._NodeRect.width, width); - block._NodeRect = tempRect; + Rect tempRect = n._NodeRect; + tempRect.width = Mathf.Max (n._NodeRect.width, width); + n._NodeRect = tempRect; GUI.backgroundColor = Color.white; - GUILayout.Box(block.BlockName, nodeStyleCopy, GUILayout.Width(block._NodeRect.width), GUILayout.Height(block._NodeRect.height)); + GUILayout.Box(block.BlockName, nodeStyleCopy, GUILayout.Width(n._NodeRect.width), GUILayout.Height(n._NodeRect.height)); if (block.Description.Length > 0) { @@ -652,14 +670,14 @@ namespace Fungus } } - protected virtual void DrawConnections(Flowchart flowchart, Block block, bool highlightedOnly) + protected virtual void DrawConnections(Flowchart flowchart, IBlock block, bool highlightedOnly) { if (block == null) { return; } - List connectedBlocks = new List(); + List connectedBlocks = new List(); bool blockIsSelected = (flowchart.SelectedBlock == block); @@ -691,7 +709,7 @@ namespace Fungus connectedBlocks.Clear(); command.GetConnectedBlocks(ref connectedBlocks); - foreach (Block blockB in connectedBlocks) + foreach (IBlock blockB in connectedBlocks) { if (blockB == null || block == blockB || @@ -700,11 +718,11 @@ namespace Fungus continue; } - Rect startRect = new Rect(block._NodeRect); + Rect startRect = new Rect((block as INode)._NodeRect); startRect.x += flowchart.ScrollPos.x; startRect.y += flowchart.ScrollPos.y; - Rect endRect = new Rect(blockB._NodeRect); + Rect endRect = new Rect((blockB as INode)._NodeRect); endRect.x += flowchart.ScrollPos.x; endRect.y += flowchart.ScrollPos.y; @@ -764,7 +782,7 @@ namespace Fungus public static void DeleteBlock(object obj) { - Block block = obj as Block; + IBlock block = obj as IBlock; FlowchartWindow.deleteList.Add(block); } diff --git a/Assets/Fungus/Scripts/Interfaces/IMenuDialog.cs b/Assets/Fungus/Scripts/Interfaces/IMenuDialog.cs index ae3a445c..0037dc10 100644 --- a/Assets/Fungus/Scripts/Interfaces/IMenuDialog.cs +++ b/Assets/Fungus/Scripts/Interfaces/IMenuDialog.cs @@ -44,7 +44,7 @@ namespace Fungus /// The option text to display on the button. /// If false, the option is displayed but is not selectable. /// Block to execute when the option is selected. - bool AddOption(string text, bool interactable, Block targetBlock); + bool AddOption(string text, bool interactable, IBlock targetBlock); /// /// Adds the option to the list of displayed options, calls a Lua function when selected. @@ -58,7 +58,7 @@ namespace Fungus /// /// The duration during which the player can select an option. /// Block to execute if the player does not select an option in time. - void ShowTimer(float duration, Block targetBlock); + void ShowTimer(float duration, IBlock targetBlock); /// /// Show a timer during which the player can select an option. Calls a Lua function when the timer expires.