#pragma once
#include "../Behaviors/UnitBehavior.h"
#include "../Behaviors/Utils/TimerState.h"
#include "../Behaviors/Utils/WrapperState.h"
#include "../../../../PerceptualState/Locations/Location.h"

class FleeingAirUnitBehavior : public UnitBehaviorT<FleeingAirUnitBehavior>
{
public:
  FleeingAirUnitBehavior(const Process* parent, unsigned int initialPriority, BWAPI::Unit* unit, AutoPtr<Location> fleeingArea);
  
  class Fleeing;
  friend class Fleeing;

  class Fleeing : public TimerState<FleeingAirUnitBehavior, Fleeing>
  {
  public:
    Fleeing(FleeingAirUnitBehavior &behav) 
      : TimerState(behav, 4, 4)
      , m_events(m_timerEvent)
      , m_currentSafeSpot(BWAPI::Positions::Invalid) {}

    void onTimer();

    typedef boost::tuple<
      TimerEvent&
          > Events;
		Events m_events;
    
		typedef boost::tuple<
		  > Transitions;
		Transitions m_transitions;

  protected:
    BWAPI::Position m_currentSafeSpot;
  };

  typedef boost::tuple<
      Fleeing&
    > States;
	const States m_states;

protected:
  virtual void _output(std::ostream& out) const
  {
    out << "FleeingAirUnitBehavior(" << *m_unit << ")";
  }

  virtual void onStart()
  {
    UnitBehaviorT::onStart();
    m_fleeingState.enter();
  }

  // States
  Fleeing m_fleeingState;
  AutoPtr<Location> m_fleeingArea;
};