using Microsoft.Xna.Framework;
using V3.Objects;
namespace V3.AI.Internal
{
///
/// Moves a creature to a destination point.
///
// ReSharper disable once ClassNeverInstantiated.Global
public class MoveAction : AbstractAction
{
private ICreature mCreature;
private Vector2 mDestination;
///
/// Creates a new MoveAction to move the given creature to the given
/// destination.
///
/// the creature to mvoe
/// the destination of the creature
public MoveAction(ICreature creature, Vector2 destination)
{
mCreature = creature;
mDestination = destination;
}
///
/// Start the execution of the action.
///
public override void Start()
{
mCreature.Move(mDestination);
base.Start();
}
protected override ActionState GetNextState()
{
switch (mCreature.MovementState)
{
case MovementState.Idle:
return ActionState.Done;
case MovementState.Attacking:
case MovementState.Dying:
return ActionState.Failed;
case MovementState.Moving:
return ActionState.Executing;
default:
return ActionState.Failed;
}
}
}
}