#include "RetreatExecutor.h"

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

void RetreatExecutor::execute(EntityAdmin& admin)
{
    TRACE();
    admin.forEach<RetreatBehavior, SelectedBehaviorComponent, MovementIntentComponent>(
        [](entt::entity /*e*/, const RetreatBehavior& retreat,
           const SelectedBehaviorComponent& selected, MovementIntentComponent& intent)
        {
            if (selected.winner != BehaviorKind::Retreat) { return; }
            intent = MovementIntentComponent{true, retreat.retreatPoint};
        });
}
