#pragma once

#include "FactoryQueries.h"

#include "AdvanceEvaluator.h"
#include "AdvanceExecutor.h"
#include "AttackEvaluator.h"
#include "AttackExecutor.h"
#include "DeliverScrapEvaluator.h"
#include "DeliverScrapExecutor.h"
#include "RallyEvaluator.h"
#include "RallyExecutor.h"
#include "RepairEvaluator.h"
#include "RepairExecutor.h"
#include "RetreatEvaluator.h"
#include "RetreatExecutor.h"
#include "SalvageScrapEvaluator.h"
#include "SalvageScrapExecutor.h"
#include "StandbyEvaluator.h"
#include "StandbyExecutor.h"

class EntityAdmin;
struct GameConfig;

// Orchestrates ship-behavior decision-making in three batched phases:
//   1. evaluators score each behavior and set its target data,
//   2. selectWinningBehaviors picks the highest-scoring behavior per ship,
//   3. executors run for the winning behavior, setting movement intent and
//      preferred module targets.
// All world mutation (collection, healing, damage) is left to the module
// systems (SalvagerSystem, RepairSystem, CombatSystem).
class AiSystem
{
public:
    explicit AiSystem(const GameConfig& config);

    void tick(EntityAdmin& admin, const FactoryState& state);

private:
    void selectWinningBehaviors(EntityAdmin& admin);

    AdvanceEvaluator      m_advanceEvaluator;
    StandbyEvaluator      m_standbyEvaluator;
    RallyEvaluator        m_rallyEvaluator;
    RetreatEvaluator      m_retreatEvaluator;
    AttackEvaluator       m_attackEvaluator;
    RepairEvaluator       m_repairEvaluator;
    SalvageScrapEvaluator m_salvageScrapEvaluator;
    DeliverScrapEvaluator m_deliverScrapEvaluator;

    AdvanceExecutor      m_advanceExecutor;
    StandbyExecutor      m_standbyExecutor;
    RallyExecutor        m_rallyExecutor;
    RetreatExecutor      m_retreatExecutor;
    AttackExecutor       m_attackExecutor;
    RepairExecutor       m_repairExecutor;
    SalvageScrapExecutor m_salvageScrapExecutor;
    DeliverScrapExecutor m_deliverScrapExecutor;
};
