#pragma once
#include "GroupTacticalAction.h"
#include "../../../../PerceptualState/World/BuildingTypeObject.h"

class AutoPopulatedLocation;

// Could restrict the choice of builder probes among some probes

class Build : public virtual GroupTacticalAction
{
public:
  Build(const Process* parent, unsigned int priority, AutoPopulatedLocation* location, BWAPI::UnitType buildingType);

  static const TerminationMode TerminatedNoSpace;
  static const TerminationMode TerminatedNoWorker;
  static const TerminationMode TerminatedBuildingDestroyed;
  static const TerminationMode TerminatedTechUnavailable;

  DECLARE_EVENT2(OnBuildingStarted, const Build*, BWAPI::Unit*);
  OnBuildingStarted& getBuildingStartedEvent() const { return m_buildingStartedEvent; }
  DECLARE_EVENT2(OnBuildingCompleted, const Build*, BWAPI::Unit*);
  OnBuildingCompleted& getBuildingCompletedEvent() const { return m_buildingCompletedEvent; }

protected:
  virtual void _output(std::ostream& out) const;

  const AutoPtr<AutoPopulatedLocation> m_location;
  const BWAPI::UnitType m_buildingType;
  const BuildingTypeObject* const m_buildingTypeObject;

  EVENT(OnBuildingStarted) m_buildingStartedEvent;
  EVENT(OnBuildingCompleted) m_buildingCompletedEvent;
};