#pragma once
#include "../Behaviors/UnitBehavior.h"
#include "../Conditions/IsIdle.h"
#include "../Commands/MoveCommand.h"
#include "../../../../Scheduler/SchedulerTaskHelper.h"

class WanderBehavior : public UnitBehaviorT<WanderBehavior>
{
protected:
	class Going;
	friend class Going;

	class Going : public BehaviorStateT<WanderBehavior, Going>
	{
	public:
		Going(WanderBehavior& behavior);
		void onEnter();
		void onExit() {}

    void onTimer()
    {
      m_transitionToSelf.testTransition(boost::make_tuple());
    }

    typedef SCHEDULER_EVENT_HANDLER(Going, onTimer) TimerEvent;

		typedef boost::tuple<
          TimerEvent&
          > Events;
		const Events m_events;
    
		typedef boost::tuple<
          Transition<Going, IsUnitIdle, NoTransitionAction, Going>&
		  > Transitions;
		const Transitions m_transitions;

	protected:
    // Variables

    // Actions
		//StopCommand m_stopCommand;
		//MoveCommand m_moveCommand;

    // Transitions
    TimerEvent m_destinationReached;
		Transition<Going, IsUnitIdle, NoTransitionAction, Going> m_transitionToSelf;
	};

public:
  WanderBehavior(const Process* parent, unsigned int initialPriority, BWAPI::Unit* wanderUnit)
    : UnitBehaviorT(parent, initialPriority, wanderUnit)
    , UnitBehavior(parent, initialPriority, wanderUnit)
    , Behavior(parent, initialPriority)
    , FSM(parent)
    , Process(parent)
    , m_goingState(*this)
    , m_states(m_goingState)
  {
  }

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

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

  // Arguments

  // Variables
  
  // States
  Going m_goingState;
};


