An easy to use Unity 3D library for creating illustrated Interactive Fiction games and more.
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.

76 lines
1.3 KiB

#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace Fungus
{
public class FungusCommand : MonoBehaviour
{
[HideInInspector]
public string errorMessage = "";
[HideInInspector]
public SequenceController parentSequenceController;
[HideInInspector]
public Sequence parentSequence;
public virtual void Start()
{
parentSequence = GetComponent<Sequence>();
// Populate sequenceController reference
Transform parent = transform.parent;
while (parent != null)
{
parentSequenceController = parent.gameObject.GetComponent<SequenceController>();
if (parentSequenceController != null)
{
break;
}
}
}
public bool IsExecuting()
{
if (parentSequence == null)
{
return false;
}
return (parentSequence.activeCommand == this);
}
public virtual void Execute()
{
OnEnter();
}
public virtual void Finish()
{
OnExit();
parentSequence.ExecuteNextCommand(this);
}
public virtual void ExecuteSequence(Sequence s)
{
OnExit();
parentSequence.Finish();
parentSequenceController.ExecuteSequence(s);
}
public virtual void OnEnter()
{}
public virtual void OnExit()
{}
public virtual void GetConnectedSequences(ref List<Sequence> connectedSequences)
{}
}
}