From ced3d03bdb3ce866d832e03fb212865140905a9a Mon Sep 17 00:00:00 2001 From: Thomas Leyh Date: Sun, 24 Jul 2016 08:14:18 +0200 Subject: Add project files. --- V3/AI/Internal/AbstractAction.cs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 V3/AI/Internal/AbstractAction.cs (limited to 'V3/AI/Internal/AbstractAction.cs') 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 +{ + /// + /// Abstract implementation of IAction. + /// + public abstract class AbstractAction : IAction + { + /// + /// The current state of the action. + /// + public ActionState State { get; private set; } = ActionState.Waiting; + + /// + /// Start the execution of the action. + /// + public virtual void Start() + { + State = ActionState.Executing; + } + + /// + /// Update the execution state. This method should be repateatingly + /// called as long as State is Executing. + /// + public virtual void Update() + { + if (State != ActionState.Executing) + return; + State = GetNextState(); + } + + /// + /// Returns the next state of this action. It is guaranteed that the + /// current state is Executing. + /// + protected abstract ActionState GetNextState(); + } +} -- cgit v1.2.1