#include "AdvanceExecutor.h" #include #include "AdvanceBehavior.h" #include "BehaviorKind.h" #include "EntityAdmin.h" #include "FactionComponent.h" #include "MovementIntentComponent.h" #include "PositionComponent.h" #include "SelectedBehaviorComponent.h" #include "tracing.h" void AdvanceExecutor::execute(EntityAdmin& admin) { TRACE(); admin.forEach( [](entt::entity /*e*/, const AdvanceBehavior& /*advance*/, const SelectedBehaviorComponent& selected, const PositionComponent& pos, const FactionComponent& faction, MovementIntentComponent& intent) { if (selected.winner != BehaviorKind::Advance) { return; } const QVector2D target = faction.isEnemy ? QVector2D(-10000.0f, pos.value.y()) : QVector2D(pos.value.x() + 1000.0f, pos.value.y()); intent = MovementIntentComponent{true, target}; }); }