Browse Source

Added properties for fine control of Reset command

master
chrisgregan 10 years ago
parent
commit
427759830b
  1. 8
      Assets/Fungus/FungusScript/Commands/Reset.cs
  2. 14
      Assets/Fungus/FungusScript/Scripts/FungusScript.cs

8
Assets/Fungus/FungusScript/Commands/Reset.cs

@ -6,12 +6,16 @@ namespace Fungus
{
[CommandInfo("Scripting",
"Reset",
"Resets state of all commands and variables in this Fungus Script.")]
"Resets the state of all commands and local and global variables in the Fungus Script.")]
public class Reset : Command
{
public bool resetCommands = true;
public bool resetLocalVariables = true;
public bool resetGlobalVariables = true;
public override void OnEnter()
{
GetFungusScript().Reset();
GetFungusScript().Reset(resetCommands, resetLocalVariables, resetGlobalVariables);
Continue();
}

14
Assets/Fungus/FungusScript/Scripts/FungusScript.cs

@ -409,18 +409,30 @@ namespace Fungus
}
}
public virtual void Reset()
public virtual void Reset(bool resetCommands, bool resetLocalVariables, bool resetGlobalVariables)
{
if (resetCommands)
{
Command[] commands = GetComponentsInChildren<Command>();
foreach (Command command in commands)
{
command.OnReset();
}
}
foreach (Variable variable in variables)
{
if (resetLocalVariables &&
variable.scope == VariableScope.Local)
{
variable.OnReset();
}
else if (resetGlobalVariables &&
variable.scope == VariableScope.Global)
{
variable.OnReset();
}
}
}
}

Loading…
Cancel
Save