public static boolean hasArrived(Entity entity) { EnemyMovement enemyMovement = EntityUtil.getComponent(entity, EnemyMovement.class); Vector2 intent = enemyMovement.getIntent().cpy(); Vector2 position = PhysicsUtil.getPosition(entity); intent.y = position.y; return position.epsilonEquals(intent, Constants.GAME.EPSILON); }
public static void drag(Entity enemy, Vector2 target, float force, int duration) { EnemyMovement movement = EntityUtil.getComponent(enemy, EnemyMovement.class); if (movement != null) { movement.setDraggedTo(target); movement.setDragForce(force); movement.setDragDuration(duration); movement.setStartDrag(TimeUtil.getGameTime()); movement.setDraggedFrom(PhysicsUtil.getPosition(enemy)); } }
public static void setTarget(Entity enemy, Vector2 target) { EnemyMovement movement = EntityUtil.getComponent(enemy, EnemyMovement.class); if (movement != null) { movement.setIntent(target); } }