You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.5 KiB
56 lines
1.5 KiB
9 years ago
|
// 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)
|
||
9 years ago
|
|
||
9 years ago
|
using UnityEngine;
|
||
|
|
||
|
namespace Fungus
|
||
|
{
|
||
9 years ago
|
/// <summary>
|
||
|
/// Stops executing the named Block.
|
||
|
/// </summary>
|
||
9 years ago
|
[CommandInfo("Flow",
|
||
|
"Stop Block",
|
||
|
"Stops executing the named Block")]
|
||
|
public class StopBlock : Command
|
||
|
{
|
||
|
[Tooltip("Flowchart containing the Block. If none is specified, the parent Flowchart is used.")]
|
||
9 years ago
|
[SerializeField] protected Flowchart flowchart;
|
||
9 years ago
|
|
||
|
[Tooltip("Name of the Block to stop")]
|
||
9 years ago
|
[SerializeField] protected StringData blockName = new StringData("");
|
||
9 years ago
|
|
||
|
public override void OnEnter()
|
||
|
{
|
||
|
if (blockName.Value == "")
|
||
|
{
|
||
|
Continue();
|
||
|
}
|
||
|
|
||
|
if (flowchart == null)
|
||
|
{
|
||
|
flowchart = GetFlowchart();
|
||
|
}
|
||
|
|
||
|
Block block = flowchart.FindBlock(blockName.Value);
|
||
|
if (block == null ||
|
||
|
!block.IsExecuting())
|
||
|
{
|
||
|
Continue();
|
||
|
}
|
||
|
|
||
|
block.Stop();
|
||
|
|
||
|
Continue();
|
||
|
}
|
||
|
|
||
|
public override string GetSummary()
|
||
|
{
|
||
|
return blockName;
|
||
|
}
|
||
|
|
||
|
public override Color GetButtonColor()
|
||
|
{
|
||
|
return new Color32(253, 253, 150, 255);
|
||
|
}
|
||
|
}
|
||
|
}
|