private bool Aim(Vector2 targetPosition, Vector2 position, bool snap = false) { Vector2 direction = position - targetPosition; float targetAngle = Helpers.ConvertToAngle(direction); if (!snap) { Helpers.RotationDirection rotDirection = Helpers.GetRotationDirection(targetAngle, Rotation, padding); switch (rotDirection) { case Helpers.RotationDirection.Left: RotateLeft(); break; case Helpers.RotationDirection.Right: RotateRight(); break; case Helpers.RotationDirection.None: Rotation = targetAngle; return(true); } } else { Rotation = targetAngle; return(true); } return(false); }
private Helpers.RotationDirection GetRotationDirection(MouseState state) { Vector2 mousePosition = state.Position.ToVector2(); Vector2 direction = Center - mousePosition; float targetAngle = Helpers.ConvertToAngle(direction); Helpers.RotationDirection rotDirection = Helpers.GetRotationDirection(targetAngle, Rotation, padding); if (rotDirection == Helpers.RotationDirection.None) { Rotation = targetAngle; } return(rotDirection); }