#pragma once
#include "../../../Layer1Reactive/Layer1FSM/Behaviors/General/Scout/ScoutBehavior.h"
#include "../../Interface/Actions/Scout.h"
#include "L2GroupTacticalAction.h"

class L2Scout : public virtual Scout, public L2GroupTacticalAction
{
public:
  L2Scout(const Process* parent, unsigned int priority, const PersistentUnitGroup* initialGroup, StaticLocation* location)
    : Scout(parent, priority, location)
    , L2GroupTacticalAction(parent, priority, initialGroup)
    , GroupTacticalAction(parent, priority, initialGroup)
    , TacticalAction(parent, priority)
    , Process(parent)
    , m_scoutBehavior(*this)
    , m_scoutArrivedEventHandler(*this)
    , m_scoutTerminatedEventHandler(*this)
  {
  }

  L2Scout(const Process* parent, unsigned int priority, StaticLocation* location)
    : Scout(parent, priority, location)
    , L2GroupTacticalAction(parent, priority)
    , GroupTacticalAction(parent, priority)
    , TacticalAction(parent, priority)
    , Process(parent)
    , m_scoutBehavior(*this)
    , m_scoutArrivedEventHandler(*this)
    , m_scoutTerminatedEventHandler(*this)
  {
  }

protected:
  virtual void onStartImplementation();
  virtual void onCancelImplementation();
  virtual void onEndImplementation();

  virtual void onUnitAddedToGroup(void*, BWAPI::Unit* unit);
  virtual void onUnitRemovedFromGroup(void*, BWAPI::Unit* unit);

  void onScoutArrived(void*);
  void onScoutTerminated(void*);

  Event<boost::tuples::tuple<>>::SubscriberID m_scoutTerminatedSubscriberId;
  EVENT_HANDLER(L2Scout, onScoutTerminated) m_scoutTerminatedEventHandler;
  Event<boost::tuples::tuple<>>::SubscriberID m_scoutArrivedSubscriberId;
  EVENT_HANDLER(L2Scout, onScoutArrived) m_scoutArrivedEventHandler;

private:
  ProcessContainer<ScoutBehavior> m_scoutBehavior;
};
