|
|
@ -31,31 +31,32 @@ namespace Fungus |
|
|
|
[HideInInspector] |
|
|
|
[HideInInspector] |
|
|
|
public bool selected; |
|
|
|
public bool selected; |
|
|
|
|
|
|
|
|
|
|
|
public virtual Sequence GetSequence() |
|
|
|
/** |
|
|
|
{ |
|
|
|
* Reference to the Sequence object that this command belongs to. |
|
|
|
return gameObject.GetComponent<Sequence>(); |
|
|
|
* This reference is only set at runtime (null in editor). |
|
|
|
} |
|
|
|
*/ |
|
|
|
|
|
|
|
[NonSerialized] |
|
|
|
|
|
|
|
public Sequence parentSequence; |
|
|
|
|
|
|
|
|
|
|
|
public virtual FungusScript GetFungusScript() |
|
|
|
public virtual FungusScript GetFungusScript() |
|
|
|
{ |
|
|
|
{ |
|
|
|
Sequence s = GetSequence(); |
|
|
|
FungusScript fungusScript = GetComponent<FungusScript>(); |
|
|
|
if (s == null) |
|
|
|
if (fungusScript == null && |
|
|
|
|
|
|
|
transform.parent != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return null; |
|
|
|
fungusScript = transform.parent.GetComponent<FungusScript>(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return fungusScript; |
|
|
|
return s.GetFungusScript(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public virtual bool IsExecuting() |
|
|
|
public virtual bool IsExecuting() |
|
|
|
{ |
|
|
|
{ |
|
|
|
Sequence sequence = GetSequence(); |
|
|
|
if (parentSequence == null) |
|
|
|
if (sequence == null) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return (sequence.activeCommand == this); |
|
|
|
return (parentSequence.activeCommand == this); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public virtual void Execute() |
|
|
|
public virtual void Execute() |
|
|
@ -71,31 +72,28 @@ namespace Fungus |
|
|
|
public virtual void Continue(Command currentCommand) |
|
|
|
public virtual void Continue(Command currentCommand) |
|
|
|
{ |
|
|
|
{ |
|
|
|
OnExit(); |
|
|
|
OnExit(); |
|
|
|
Sequence sequence = GetSequence(); |
|
|
|
if (parentSequence != null) |
|
|
|
if (sequence != null) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
sequence.ExecuteNextCommand(currentCommand); |
|
|
|
parentSequence.ExecuteNextCommand(currentCommand); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public virtual void Stop() |
|
|
|
public virtual void Stop() |
|
|
|
{ |
|
|
|
{ |
|
|
|
OnExit(); |
|
|
|
OnExit(); |
|
|
|
Sequence sequence = GetSequence(); |
|
|
|
if (parentSequence != null) |
|
|
|
if (sequence != null) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
sequence.Stop(); |
|
|
|
parentSequence.Stop(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public virtual void ExecuteSequence(Sequence s) |
|
|
|
public virtual void ExecuteSequence(Sequence s) |
|
|
|
{ |
|
|
|
{ |
|
|
|
OnExit(); |
|
|
|
OnExit(); |
|
|
|
Sequence sequence = GetSequence(); |
|
|
|
if (parentSequence != null) |
|
|
|
if (sequence != null) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
sequence.Stop(); |
|
|
|
parentSequence.Stop(); |
|
|
|
FungusScript fungusScript = sequence.GetFungusScript(); |
|
|
|
FungusScript fungusScript = parentSequence.GetFungusScript(); |
|
|
|
if (fungusScript != null) |
|
|
|
if (fungusScript != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
fungusScript.ExecuteSequence(s); |
|
|
|
fungusScript.ExecuteSequence(s); |
|
|
|