diff --git a/Assets/Fungus/Scripts/Commands/StopBlock.cs b/Assets/Fungus/Scripts/Commands/StopBlock.cs
index c04dee4f..2f6a5e91 100644
--- a/Assets/Fungus/Scripts/Commands/StopBlock.cs
+++ b/Assets/Fungus/Scripts/Commands/StopBlock.cs
@@ -32,7 +32,7 @@ namespace Fungus.Commands
flowchart = (Flowchart)GetFlowchart();
}
- IBlock block = flowchart.FindBlock(blockName.Value);
+ var block = flowchart.FindBlock(blockName.Value);
if (block == null ||
!block.IsExecuting())
{
diff --git a/Assets/Fungus/Scripts/Components/Block.cs b/Assets/Fungus/Scripts/Components/Block.cs
index cdf79a33..a19a5ac8 100644
--- a/Assets/Fungus/Scripts/Components/Block.cs
+++ b/Assets/Fungus/Scripts/Components/Block.cs
@@ -11,13 +11,24 @@ using Fungus.Utils;
namespace Fungus
{
+ ///
+ /// Execution state of a Block.
+ ///
+ public enum ExecutionState
+ {
+ /// No command executing
+ Idle,
+ /// Executing a command
+ Executing,
+ }
+
///
/// A container for a sequence of Fungus comands.
///
[ExecuteInEditMode]
[RequireComponent(typeof(Flowchart))]
[AddComponentMenu("")]
- public class Block : Node, IBlock
+ public class Block : Node
{
[SerializeField] protected int itemId = -1; // Invalid flowchart item id
@@ -101,46 +112,91 @@ namespace Fungus
}
#endif
- #region IBlock implementation
+ #region Public methods
+ ///
+ /// 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.
+ /// Note: Using the concrete class instead of the interface here because of weird editor behaviour.
+ ///
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 IFlowchart 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)
@@ -249,6 +305,9 @@ namespace Fungus
}
}
+ ///
+ /// Stop executing commands in this Block.
+ ///
public virtual void Stop()
{
// Tell the executing command to stop immediately
@@ -262,6 +321,9 @@ namespace Fungus
jumpToCommandIndex = int.MaxValue;
}
+ ///
+ /// Returns a list of all Blocks connected to this one.
+ ///
public virtual List GetConnectedBlocks()
{
var connectedBlocks = new List();
@@ -275,6 +337,10 @@ 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 &&
@@ -286,6 +352,9 @@ 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/Scripts/Components/Flowchart.cs b/Assets/Fungus/Scripts/Components/Flowchart.cs
index ba50bae0..14ef0d31 100644
--- a/Assets/Fungus/Scripts/Components/Flowchart.cs
+++ b/Assets/Fungus/Scripts/Components/Flowchart.cs
@@ -200,7 +200,7 @@ 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();
- var blocks = GetComponents();
+ var blocks = GetComponents();
foreach (var block in blocks)
{
if (block.ItemId == -1 ||
@@ -241,7 +241,7 @@ namespace Fungus
}
}
- var blocks = GetComponents();
+ var blocks = GetComponents();
foreach (var command in GetComponents())
{
@@ -339,7 +339,7 @@ namespace Fungus
public int NextItemId()
{
int maxId = -1;
- var blocks = GetComponents();
+ var blocks = GetComponents();
foreach (var block in blocks)
{
maxId = Math.Max(maxId, block.ItemId);
@@ -363,9 +363,9 @@ namespace Fungus
return b;
}
- public virtual IBlock FindBlock(string blockName)
+ public virtual Block FindBlock(string blockName)
{
- var blocks = GetComponents();
+ var blocks = GetComponents();
foreach (var block in blocks)
{
if (block.BlockName == blockName)
@@ -393,7 +393,7 @@ namespace Fungus
}
}
- public virtual bool ExecuteBlock(IBlock block, int commandIndex = 0, Action onComplete = null)
+ public virtual bool ExecuteBlock(Block block, int commandIndex = 0, Action onComplete = null)
{
if (block == null)
{
@@ -421,8 +421,8 @@ namespace Fungus
public virtual void StopAllBlocks()
{
- var blocks = GetComponents();
- foreach (IBlock block in blocks)
+ var blocks = GetComponents();
+ foreach (Block block in blocks)
{
if (block.IsExecuting())
{
@@ -486,7 +486,7 @@ namespace Fungus
}
}
- public virtual string GetUniqueBlockKey(string originalKey, IBlock ignoreBlock = null)
+ public virtual string GetUniqueBlockKey(string originalKey, Block ignoreBlock = null)
{
int suffix = 0;
string baseKey = originalKey.Trim();
@@ -497,7 +497,7 @@ namespace Fungus
baseKey = FungusConstants.DefaultBlockName;
}
- var blocks = GetComponents();
+ var blocks = GetComponents();
string key = baseKey;
while (true)
@@ -537,7 +537,7 @@ namespace Fungus
baseKey = "New Label";
}
- IBlock block = ignoreLabel.ParentBlock;
+ var block = ignoreLabel.ParentBlock;
string key = baseKey;
while (true)
@@ -811,8 +811,8 @@ namespace Fungus
public virtual bool HasExecutingBlocks()
{
- var blocks = GetComponents();
- foreach (IBlock block in blocks)
+ var blocks = GetComponents();
+ foreach (var block in blocks)
{
if (block.IsExecuting())
{
@@ -822,10 +822,10 @@ namespace Fungus
return false;
}
- public virtual List GetExecutingBlocks()
+ public virtual List GetExecutingBlocks()
{
- var executingBlocks = new List();
- var blocks = GetComponents();
+ var executingBlocks = new List();
+ var blocks = GetComponents();
foreach (var block in blocks)
{
if (block.IsExecuting())
diff --git a/Assets/Fungus/Scripts/Components/Localization.cs b/Assets/Fungus/Scripts/Components/Localization.cs
index 5cd3216a..68a45b73 100644
--- a/Assets/Fungus/Scripts/Components/Localization.cs
+++ b/Assets/Fungus/Scripts/Components/Localization.cs
@@ -139,7 +139,7 @@ namespace Fungus
var flowcharts = GameObject.FindObjectsOfType();
foreach (var flowchart in flowcharts)
{
- var blocks = flowchart.GetComponents();
+ var blocks = flowchart.GetComponents();
foreach (var block in blocks)
{
foreach (var command in block.CommandList)
diff --git a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs
index d5b68722..1f9bed6e 100644
--- a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs
+++ b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs
@@ -551,7 +551,7 @@ namespace Fungus.EditorUtils
return newBlock;
}
- protected virtual void DeleteBlock(Flowchart flowchart, IBlock block)
+ protected virtual void DeleteBlock(Flowchart flowchart, Block block)
{
foreach (var command in block.CommandList)
{
diff --git a/Assets/Fungus/Scripts/Interfaces/IBlock.cs b/Assets/Fungus/Scripts/Interfaces/IBlock.cs
deleted file mode 100644
index b38321a1..00000000
--- a/Assets/Fungus/Scripts/Interfaces/IBlock.cs
+++ /dev/null
@@ -1,119 +0,0 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
-// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
-
-using System.Collections;
-using System.Collections.Generic;
-
-namespace Fungus
-{
- ///
- /// Execution state of a Block.
- ///
- public enum ExecutionState
- {
- /// No command executing
- Idle,
- /// Executing a command
- Executing,
- }
-
- ///
- /// A container for a sequence of Fungus comands.
- ///
- public interface IBlock
- {
- ///
- /// The execution state of the Block.
- ///
- ExecutionState State { get; }
-
- ///
- /// Unique identifier for the Block.
- ///
- int ItemId { get; set; }
-
- ///
- /// The name of the block node as displayed in the Flowchart window.
- ///
- string BlockName { get; set; }
-
- ///
- /// Description text to display under the block node
- ///
- string Description { get; }
-
- ///
- /// An optional Event Handler which can execute the block when an event occurs.
- /// Note: Using the concrete class instead of the interface here because of weird editor behaviour.
- ///
- EventHandler _EventHandler { get; set; }
-
- ///
- /// The currently executing command.
- ///
- Command ActiveCommand { get; }
-
- ///
- /// Timer for fading Block execution icon.
- ///
- float ExecutingIconTimer { get; set; }
-
- ///
- /// The list of commands in the sequence.
- ///
- List CommandList { get; }
-
- ///
- /// Controls the next command to execute in the block execution coroutine.
- ///
- int JumpToCommandIndex { set; }
-
- ///
- /// Returns the parent Flowchart for this Block.
- ///
- IFlowchart GetFlowchart();
-
- ///
- /// Returns true if the Block is executing a command.
- ///
- bool IsExecuting();
-
- ///
- /// Returns the number of times this Block has executed.
- ///
- int GetExecutionCount();
-
- ///
- /// Start a coroutine which executes all commands in the Block. Only one running instance of each Block is permitted.
- ///
- void StartExecution();
-
- ///
- /// 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
- IEnumerator Execute(int commandIndex = 0, System.Action onComplete = null);
-
- ///
- /// Stop executing commands in this Block.
- ///
- void Stop();
-
- ///
- /// Returns a list of all Blocks connected to this one.
- ///
- List GetConnectedBlocks();
-
- ///
- /// Returns the type of the previously executing command.
- ///
- /// The previous active command type.
- System.Type GetPreviousActiveCommandType();
-
- ///
- /// Recalculate the indent levels for all commands in the list.
- ///
- void UpdateIndentLevels();
- }
-}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Interfaces/IBlock.cs.meta b/Assets/Fungus/Scripts/Interfaces/IBlock.cs.meta
deleted file mode 100644
index a0965ceb..00000000
--- a/Assets/Fungus/Scripts/Interfaces/IBlock.cs.meta
+++ /dev/null
@@ -1,12 +0,0 @@
-fileFormatVersion: 2
-guid: 3a23dd66c807e4fab86a64184c3faa9a
-timeCreated: 1473856388
-licenseType: Free
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Interfaces/IFlowchart.cs b/Assets/Fungus/Scripts/Interfaces/IFlowchart.cs
index 981141cf..a802d9cc 100644
--- a/Assets/Fungus/Scripts/Interfaces/IFlowchart.cs
+++ b/Assets/Fungus/Scripts/Interfaces/IFlowchart.cs
@@ -133,7 +133,7 @@ namespace Fungus
///
/// Returns the named Block in the flowchart, or null if not found.
///
- IBlock FindBlock(string blockName);
+ Block FindBlock(string blockName);
///
/// Execute a child block in the Flowchart.
@@ -146,7 +146,7 @@ namespace Fungus
/// This version provides extra options to control how the block is executed.
/// Returns true if the Block started execution.
///
- bool ExecuteBlock(IBlock block, int commandIndex = 0, System.Action onComplete = null);
+ bool ExecuteBlock(Block block, int commandIndex = 0, System.Action onComplete = null);
///
/// Stop all executing Blocks in this Flowchart.
@@ -167,7 +167,7 @@ namespace Fungus
///
/// Returns a new Block key that is guaranteed not to clash with any existing Block in the Flowchart.
///
- string GetUniqueBlockKey(string originalKey, IBlock ignoreBlock = null);
+ string GetUniqueBlockKey(string originalKey, Block ignoreBlock = null);
///
/// Returns a new Label key that is guaranteed not to clash with any existing Label in the Block.
@@ -283,7 +283,7 @@ namespace Fungus
///
/// Returns a list of all executing blocks in this Flowchart.
///
- List GetExecutingBlocks();
+ List GetExecutingBlocks();
///
/// Substitute variables in the input text with the format {$VarName}