|
|
@ -12,18 +12,12 @@ namespace Fungus |
|
|
|
[ExecuteInEditMode] |
|
|
|
[ExecuteInEditMode] |
|
|
|
public class Sequence : MonoBehaviour |
|
|
|
public class Sequence : MonoBehaviour |
|
|
|
{ |
|
|
|
{ |
|
|
|
[HideInInspector] |
|
|
|
|
|
|
|
public Rect nodeRect = new Rect(10, 10, 100, 40); |
|
|
|
public Rect nodeRect = new Rect(10, 10, 100, 40); |
|
|
|
|
|
|
|
|
|
|
|
[HideInInspector] |
|
|
|
|
|
|
|
public string sequenceName = "Sequence"; |
|
|
|
public string sequenceName = "Sequence"; |
|
|
|
|
|
|
|
|
|
|
|
[HideInInspector] |
|
|
|
|
|
|
|
public string description = ""; |
|
|
|
public string description = ""; |
|
|
|
|
|
|
|
|
|
|
|
[System.NonSerialized] |
|
|
|
|
|
|
|
public FungusScript fungusScript; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[System.NonSerialized] |
|
|
|
[System.NonSerialized] |
|
|
|
public Command activeCommand; |
|
|
|
public Command activeCommand; |
|
|
|
|
|
|
|
|
|
|
@ -31,25 +25,9 @@ namespace Fungus |
|
|
|
|
|
|
|
|
|
|
|
int executionCount; |
|
|
|
int executionCount; |
|
|
|
|
|
|
|
|
|
|
|
public virtual void Start() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fungusScript = GetFungusScript(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public FungusScript GetFungusScript() |
|
|
|
public FungusScript GetFungusScript() |
|
|
|
{ |
|
|
|
{ |
|
|
|
FungusScript sc = null; |
|
|
|
return GetComponentInParent<FungusScript>(); |
|
|
|
Transform parent = transform.parent; |
|
|
|
|
|
|
|
while (parent != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
sc = parent.gameObject.GetComponent<FungusScript>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sc != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return sc; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public bool HasError() |
|
|
|
public bool HasError() |
|
|
@ -67,6 +45,8 @@ namespace Fungus |
|
|
|
|
|
|
|
|
|
|
|
public bool IsRunning() |
|
|
|
public bool IsRunning() |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
FungusScript fungusScript = GetFungusScript(); |
|
|
|
|
|
|
|
|
|
|
|
if (fungusScript == null || |
|
|
|
if (fungusScript == null || |
|
|
|
fungusScript.executingSequence == null) |
|
|
|
fungusScript.executingSequence == null) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -114,14 +94,16 @@ namespace Fungus |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (GetFungusScript().stepTime == 0f) |
|
|
|
FungusScript fungusScript = GetFungusScript(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (fungusScript.stepTime == 0f) |
|
|
|
{ |
|
|
|
{ |
|
|
|
activeCommand = nextCommand; |
|
|
|
activeCommand = nextCommand; |
|
|
|
nextCommand.Execute(); |
|
|
|
nextCommand.Execute(); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
StartCoroutine(ExecuteAfterDelay(nextCommand, GetFungusScript().stepTime)); |
|
|
|
StartCoroutine(ExecuteAfterDelay(nextCommand, fungusScript.stepTime)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -136,6 +118,12 @@ namespace Fungus |
|
|
|
|
|
|
|
|
|
|
|
public void Stop() |
|
|
|
public void Stop() |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
FungusScript fungusScript = GetFungusScript(); |
|
|
|
|
|
|
|
if (fungusScript == null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
activeCommand = null; |
|
|
|
activeCommand = null; |
|
|
|
fungusScript.executingSequence = null; |
|
|
|
fungusScript.executingSequence = null; |
|
|
|
fungusScript.selectedSequence = null; |
|
|
|
fungusScript.selectedSequence = null; |
|
|
|