#include "RallyExecutor.h"

#include "BehaviorKind.h"
#include "EntityAdmin.h"
#include "MovementIntentComponent.h"
#include "RallyBehavior.h"
#include "SelectedBehaviorComponent.h"
#include "tracing.h"

void RallyExecutor::execute(EntityAdmin& admin)
{
    TRACE();
    admin.forEach<RallyBehavior, SelectedBehaviorComponent,
                  MovementIntentComponent>(
        [](entt::entity /*e*/, const RallyBehavior& rally,
           const SelectedBehaviorComponent& selected,
           MovementIntentComponent& intent)
        {
            if (selected.winner != BehaviorKind::Rally) { return; }
            intent = MovementIntentComponent{true, rally.rallyPoint,
                                             rally.orbitRadius_tiles};
        });
}
