From 43d59a805957a0fbe403d40326b3db2aa41d49c9 Mon Sep 17 00:00:00 2001 From: Christopher Date: Fri, 16 Sep 2016 12:55:45 +0100 Subject: [PATCH] Using concrete Block class for safety with editor code --- Assets/Fungus/Flowchart/Scripts/Block.cs | 6 +++--- Assets/Fungus/Flowchart/Scripts/Flowchart.cs | 6 +++--- Assets/Fungus/Flowchart/Scripts/IBlock.cs | 2 +- Assets/Fungus/Flowchart/Scripts/IFlowchart.cs | 2 +- Assets/Fungus/Scripts/Editor/BlockEditor.cs | 4 ++-- Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Assets/Fungus/Flowchart/Scripts/Block.cs b/Assets/Fungus/Flowchart/Scripts/Block.cs index a765bb7a..6bfb3d65 100644 --- a/Assets/Fungus/Flowchart/Scripts/Block.cs +++ b/Assets/Fungus/Flowchart/Scripts/Block.cs @@ -34,7 +34,7 @@ namespace Fungus protected ExecutionState executionState; - protected ICommand activeCommand; + protected Command activeCommand; /// // Index of last command executed before the current one. @@ -116,7 +116,7 @@ namespace Fungus public virtual EventHandler _EventHandler { get { return eventHandler; } set { eventHandler = value; } } - public virtual ICommand ActiveCommand { get { return activeCommand; } } + public virtual Command ActiveCommand { get { return activeCommand; } } public virtual float ExecutingIconTimer { get; set; } @@ -207,7 +207,7 @@ namespace Fungus previousActiveCommandIndex = activeCommand.CommandIndex; } - ICommand command = commandList[i]; + var command = commandList[i]; activeCommand = command; if (flowchart.IsActive()) diff --git a/Assets/Fungus/Flowchart/Scripts/Flowchart.cs b/Assets/Fungus/Flowchart/Scripts/Flowchart.cs index 5cb07404..fcf212e3 100644 --- a/Assets/Fungus/Flowchart/Scripts/Flowchart.cs +++ b/Assets/Fungus/Flowchart/Scripts/Flowchart.cs @@ -780,11 +780,11 @@ namespace Fungus selectedCommands.Clear(); } - public virtual void AddSelectedCommand(ICommand command) + public virtual void AddSelectedCommand(Command command) { - if (!selectedCommands.Contains((Command)command)) + if (!selectedCommands.Contains(command)) { - selectedCommands.Add((Command)command); + selectedCommands.Add(command); } } diff --git a/Assets/Fungus/Flowchart/Scripts/IBlock.cs b/Assets/Fungus/Flowchart/Scripts/IBlock.cs index a313036d..417ff2fe 100644 --- a/Assets/Fungus/Flowchart/Scripts/IBlock.cs +++ b/Assets/Fungus/Flowchart/Scripts/IBlock.cs @@ -47,7 +47,7 @@ namespace Fungus /// /// The currently executing command. /// - ICommand ActiveCommand { get; } + Command ActiveCommand { get; } /// /// Timer for fading Block execution icon. diff --git a/Assets/Fungus/Flowchart/Scripts/IFlowchart.cs b/Assets/Fungus/Flowchart/Scripts/IFlowchart.cs index e13e2b5c..2ea2f0b9 100644 --- a/Assets/Fungus/Flowchart/Scripts/IFlowchart.cs +++ b/Assets/Fungus/Flowchart/Scripts/IFlowchart.cs @@ -260,7 +260,7 @@ namespace Fungus /// /// Adds a command to the list of selected commands. /// - void AddSelectedCommand(ICommand command); + void AddSelectedCommand(Command command); /// /// Reset the commands and variables in the Flowchart. diff --git a/Assets/Fungus/Scripts/Editor/BlockEditor.cs b/Assets/Fungus/Scripts/Editor/BlockEditor.cs index 2bae7892..9d197d35 100644 --- a/Assets/Fungus/Scripts/Editor/BlockEditor.cs +++ b/Assets/Fungus/Scripts/Editor/BlockEditor.cs @@ -732,7 +732,7 @@ namespace Fungus flowchart.ClearSelectedCommands(); - ICommand newCommand = Undo.AddComponent(((Block)block).gameObject, commandOperation.commandType) as Command; + var newCommand = Undo.AddComponent(((Block)block).gameObject, commandOperation.commandType) as Command; block.GetFlowchart().AddSelectedCommand(newCommand); newCommand.ParentBlock = block; newCommand.ItemId = flowchart.NextItemId(); @@ -1013,7 +1013,7 @@ namespace Fungus if (lastSelectedIndex < flowchart.SelectedBlock.CommandList.Count) { - Command nextCommand = flowchart.SelectedBlock.CommandList[lastSelectedIndex]; + var nextCommand = flowchart.SelectedBlock.CommandList[lastSelectedIndex]; block.GetFlowchart().AddSelectedCommand(nextCommand); } diff --git a/Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs b/Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs index 37ff844e..1ef9add6 100644 --- a/Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs +++ b/Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs @@ -90,7 +90,7 @@ namespace Fungus return null; } - Command newCommand = Undo.AddComponent(((Block)block).gameObject) as Command; + var newCommand = Undo.AddComponent(((Block)block).gameObject) as Command; newCommand.ItemId = flowchart.NextItemId(); flowchart.ClearSelectedCommands(); flowchart.AddSelectedCommand(newCommand); @@ -355,7 +355,7 @@ namespace Fungus for (int i = Math.Min(firstSelectedIndex, lastSelectedIndex); i < Math.Max(firstSelectedIndex, lastSelectedIndex); ++i) { - Command selectedCommand = flowchart.SelectedBlock.CommandList[i]; + var selectedCommand = flowchart.SelectedBlock.CommandList[i]; BlockEditor.actionList.Add ( delegate { flowchart.AddSelectedCommand(selectedCommand); });