#pragma once
#include "../../DecisionMaking/Layer1Reactive/Layer1FSM/Behaviors/General/Move/GroupMoveBehavior.h"
#include "../Scenario.h"

class ProbeMoveScenario : public Scenario<ProbeMoveScenario>
{
public:
  ProbeMoveScenario()
    : m_probes("Probes")
  {
  }

  template <class SparAIFactory>
  SparAIContainer* instantiateSparAIImpl(SparAIFactory& sparFactory)
  {
    typedef SparAIModule<Layer1GameState, Layer2Cueing, Layer3TacticalRecognition, Layer4StrategicRecognition,
                         Layer1FSM, InactiveLayer2, InactiveLayer3, InactiveLayer4> SPAR;

    return sparFactory.instantiate<Layer1GameState, Layer2Cueing, Layer3TacticalRecognition, Layer4StrategicRecognition,
                                   Layer1FSM, InactiveLayer2, InactiveLayer3, InactiveLayer4>(this);
  }

protected:
  virtual void onSparStarted(void* data)
  {
    const std::set<BWAPI::Unit*>& units = BWAPI::Broodwar->self()->getUnits();
    for (std::set<BWAPI::Unit*>::const_iterator it = units.begin();
         it != units.end();
         ++it)
    {
      BWAPI::Unit* unit = (*it);
      if (unit->getType() == BWAPI::UnitTypes::Protoss_Probe)
      {
        m_probes.insert(*it);
      }
    }

    Behavior* behavior = new GroupMoveBehavior(this, 100, &m_probes, BWAPI::Position(0,0), GroupMoveBehavior::getDefaultMoveOptions()); /* TODO: real threat aware */
    behavior->zombifyOnTerminate();
    behavior->start();
  }

  void _output(std::ostream &out) const
  {
    out << "ProbeMove Scenario";
  }

  PersistentUnitGroup m_probes;
};