|
|
@ -37,12 +37,28 @@ namespace Fungus |
|
|
|
protected virtual void Awake() |
|
|
|
protected virtual void Awake() |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Give each child command a reference back to its parent sequence |
|
|
|
// Give each child command a reference back to its parent sequence |
|
|
|
|
|
|
|
int index = 0; |
|
|
|
foreach (Command command in commandList) |
|
|
|
foreach (Command command in commandList) |
|
|
|
{ |
|
|
|
{ |
|
|
|
command.parentSequence = this; |
|
|
|
command.parentSequence = this; |
|
|
|
|
|
|
|
command.commandIndex = index++; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if UNITY_EDITOR |
|
|
|
|
|
|
|
// The user can modify the command list order while playing in the editor, |
|
|
|
|
|
|
|
// so we keep the command indices updated every frame. There's no need to |
|
|
|
|
|
|
|
// do this in player builds so we compile this bit out for those builds. |
|
|
|
|
|
|
|
void Update() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
int index = 0; |
|
|
|
|
|
|
|
foreach (Command command in commandList) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
command.commandIndex = index++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
public virtual FungusScript GetFungusScript() |
|
|
|
public virtual FungusScript GetFungusScript() |
|
|
|
{ |
|
|
|
{ |
|
|
|
FungusScript fungusScript = GetComponent<FungusScript>(); |
|
|
|
FungusScript fungusScript = GetComponent<FungusScript>(); |
|
|
@ -97,27 +113,27 @@ namespace Fungus |
|
|
|
|
|
|
|
|
|
|
|
FungusScript fungusScript = GetFungusScript(); |
|
|
|
FungusScript fungusScript = GetFungusScript(); |
|
|
|
|
|
|
|
|
|
|
|
activeCommand = null; |
|
|
|
int commandIndex = 0; |
|
|
|
Command nextCommand = null; |
|
|
|
if (currentCommand != null) |
|
|
|
executingIconTimer = 0.5f; |
|
|
|
{ |
|
|
|
|
|
|
|
commandIndex = currentCommand.commandIndex + 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool executeNext = (currentCommand == null); |
|
|
|
while (commandIndex < commandList.Count && |
|
|
|
foreach (Command command in commandList) |
|
|
|
(!commandList[commandIndex].enabled || commandList[commandIndex].GetType() == typeof(Comment))) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (command == currentCommand) |
|
|
|
commandIndex = commandList[commandIndex].commandIndex + 1; |
|
|
|
{ |
|
|
|
} |
|
|
|
executeNext = true; |
|
|
|
|
|
|
|
} |
|
|
|
Command nextCommand = null; |
|
|
|
else if (executeNext) |
|
|
|
if (commandIndex < commandList.Count) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (command.enabled && command.GetType() != typeof(Comment)) |
|
|
|
nextCommand = commandList[commandIndex]; |
|
|
|
{ |
|
|
|
|
|
|
|
nextCommand = command; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
activeCommand = null; |
|
|
|
|
|
|
|
executingIconTimer = 0.5f; |
|
|
|
|
|
|
|
|
|
|
|
if (nextCommand == null) |
|
|
|
if (nextCommand == null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Stop(); |
|
|
|
Stop(); |
|
|
|