#pragma once
#include <set>
#include "../Scenario.h"
#include "../../DecisionMaking/Layer1Reactive/Layer1FSM/Old/FleeingAirUnitBehavior.h"

class CorsairVsScourgeScenario : public Scenario<CorsairVsScourgeScenario>
{
public:
  CorsairVsScourgeScenario();

  void onTimer();
  void onTerminated(void * raw);
  void onKilled(void *);

  typedef SCHEDULER_EVENT_HANDLER(CorsairVsScourgeScenario, onTimer) TimerEvent;

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

    SPAR* module = sparFactory.instantiate<Layer1GameState, Layer2Cueing, Layer3TacticalRecognition, Layer4StrategicRecognition,
                                           Layer1FSM, Layer2Managers, InactiveLayer3, InactiveLayer4>(this);
    
    return module;
  }

protected:
  virtual void onSparStarted(void* data);

  void _output(std::ostream &out) const
  {
    out << "CorsairVsScourge Scenario";
  }
  
  BWAPI::Unit * m_corsair;
  std::set<BWAPI::Unit *> m_scourges;
  TimerEvent m_timerEvent;
  FleeingAirUnitBehavior * m_behavior;
  FleeingAirUnitBehavior::OnTerminate::SubscriberID m_subscriberId;
  EVENT_HANDLER(CorsairVsScourgeScenario, onTerminated) m_onTerminated;

  EVENT_HANDLER(CorsairVsScourgeScenario, onKilled) m_onKilled; 

  AutoPtr<Location> m_fullMap;
};