diff options
author | Thomas Leyh <leyh.thomas@web.de> | 2016-07-24 08:14:18 +0200 |
---|---|---|
committer | Thomas Leyh <leyh.thomas@web.de> | 2016-07-24 08:14:18 +0200 |
commit | ced3d03bdb3ce866d832e03fb212865140905a9a (patch) | |
tree | 2a16c2063a46d3c354ce1585029dda3124f6ad93 /V3/AI/Internal/AbstractAction.cs | |
parent | 0394dccaf06e1009e591a6ff4d645895574724c1 (diff) | |
download | V3-ced3d03bdb3ce866d832e03fb212865140905a9a.tar.gz V3-ced3d03bdb3ce866d832e03fb212865140905a9a.tar.bz2 |
Diffstat (limited to 'V3/AI/Internal/AbstractAction.cs')
-rw-r--r-- | V3/AI/Internal/AbstractAction.cs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/V3/AI/Internal/AbstractAction.cs b/V3/AI/Internal/AbstractAction.cs new file mode 100644 index 0000000..1b5f73e --- /dev/null +++ b/V3/AI/Internal/AbstractAction.cs @@ -0,0 +1,38 @@ +namespace V3.AI.Internal +{ + /// <summary> + /// Abstract implementation of IAction. + /// </summary> + public abstract class AbstractAction : IAction + { + /// <summary> + /// The current state of the action. + /// </summary> + public ActionState State { get; private set; } = ActionState.Waiting; + + /// <summary> + /// Start the execution of the action. + /// </summary> + public virtual void Start() + { + State = ActionState.Executing; + } + + /// <summary> + /// Update the execution state. This method should be repateatingly + /// called as long as State is Executing. + /// </summary> + public virtual void Update() + { + if (State != ActionState.Executing) + return; + State = GetNextState(); + } + + /// <summary> + /// Returns the next state of this action. It is guaranteed that the + /// current state is Executing. + /// </summary> + protected abstract ActionState GetNextState(); + } +} |