\hypertarget{classDetectorAction}{\section{\-Detector\-Action \-Class \-Reference}
\label{classDetectorAction}\index{\-Detector\-Action@{\-Detector\-Action}}
}


{\ttfamily \#include $<$\-Detector\-Action.\-h$>$}



\-Inheritance diagram for \-Detector\-Action\-:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=238pt]{classDetectorAction__inherit__graph}
\end{center}
\end{figure}


\-Collaboration diagram for \-Detector\-Action\-:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=238pt]{classDetectorAction__coll__graph}
\end{center}
\end{figure}
\subsection*{\-Public \-Member \-Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{classDetectorAction_ac042d708bcfd47b9525657a1194900e7}{\-Detector\-Action} (\hyperlink{Interface_8h_ab8fbb9e601c27f783b69f16c5a1fd40a}{\-Unit} unit)
\item 
bool \hyperlink{classDetectorAction_af4e2069fe6528c1205b0e4b64a56d366}{update} (const \hyperlink{classGoal}{\-Goal} \&squad\-Goal, const \hyperlink{classUnitGroup}{\-Unit\-Group} \&squad\-Unit\-Group)
\end{DoxyCompactItemize}


\subsection{\-Detailed \-Description}


\-Definition at line 6 of file \-Detector\-Action.\-h.



\subsection{\-Constructor \& \-Destructor \-Documentation}
\hypertarget{classDetectorAction_ac042d708bcfd47b9525657a1194900e7}{\index{\-Detector\-Action@{\-Detector\-Action}!\-Detector\-Action@{\-Detector\-Action}}
\index{\-Detector\-Action@{\-Detector\-Action}!DetectorAction@{\-Detector\-Action}}
\subsubsection[{\-Detector\-Action}]{\setlength{\rightskip}{0pt plus 5cm}{\bf \-Detector\-Action\-::\-Detector\-Action} (
\begin{DoxyParamCaption}
\item[{{\bf \-Unit}}]{unit}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}\label{classDetectorAction_ac042d708bcfd47b9525657a1194900e7}


\-Definition at line 9 of file \-Detector\-Action.\-h.


\begin{DoxyCode}
: SingleMicroActionBaseClass(unit) {}
\end{DoxyCode}


\subsection{\-Member \-Function \-Documentation}
\hypertarget{classDetectorAction_af4e2069fe6528c1205b0e4b64a56d366}{\index{\-Detector\-Action@{\-Detector\-Action}!update@{update}}
\index{update@{update}!DetectorAction@{\-Detector\-Action}}
\subsubsection[{update}]{\setlength{\rightskip}{0pt plus 5cm}bool {\bf \-Detector\-Action\-::update} (
\begin{DoxyParamCaption}
\item[{const {\bf \-Goal} \&}]{squad\-Goal, }
\item[{const {\bf \-Unit\-Group} \&}]{squad\-Unit\-Group}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}virtual\mbox{]}}}}\label{classDetectorAction_af4e2069fe6528c1205b0e4b64a56d366}


\-Implements \hyperlink{classSingleMicroActionBaseClass_aecc4881945144ca283aaf4dfd9397a4f}{\-Single\-Micro\-Action\-Base\-Class}.



\-Definition at line 9 of file \-Detector\-Action.\-cpp.



\-References \-Action\-Type\-Def\-::\-Fall\-Back, \-Goal\-::get\-Action\-Type(), \-B\-W\-A\-P\-I\-::\-Unit\-Type\-::has\-Permanent\-Cloak(), \-Unit\-Group\-::insert(), \-Singleton$<$ T $>$\-::\-Instance(), \-Unit\-Helper\-::is\-Army\-Unit(), \-B\-W\-A\-P\-I\-::\-Unit\-Type\-::is\-Building(), \-Single\-Micro\-Action\-Base\-Class\-::m\-Unit, \-B\-W\-A\-P\-I\-::\-Unit\-Types\-::\-Protoss\-\_\-\-Arbiter, \-B\-W\-A\-P\-I\-::\-Unit\-Types\-::\-Protoss\-\_\-\-Observer, \-Action\-Type\-Def\-::\-Retreat, and \-B\-W\-A\-P\-I\-::\-Unit\-Types\-::\-Zerg\-\_\-\-Lurker.


\begin{DoxyCode}
{
        if(squadGoal.getActionType() == ActionType::Retreat || squadGoal.
      getActionType() == ActionType::FallBack)
                return false;

        Unit needsDetecting;
        int unitDistance = std::numeric_limits<int>::max();
        for each(Unit unit in UnitTracker::Instance().selectAllEnemy())
        {
                const BWAPI::UnitType &unitType = unit->getType();
                if(unitType.hasPermanentCloak() || unitType == 
      BWAPI::UnitTypes::Zerg_Lurker || unit->isCloaked() || unit->isBurrowed())
                {
                        int thisDistance = mUnit->getDistance(unit);
                        if(thisDistance < unitDistance)
                        {
                                needsDetecting = unit;
                                unitDistance = thisDistance;
                        }
                }
        }

        if(needsDetecting)
        {
                if(unitDistance > BWAPI::UnitTypes::Protoss_Observer.sightRange
      ())
                {
                        mUnit->move(needsDetecting->getPosition());
                        return true;
                }
        }

        //TODO: give actions access to the rest of the squad
        UnitGroup protectionUnits;
        for each(Unit unit in squadUnitGroup)
        {
                if(!UnitHelper::isArmyUnit(unit->getType()))
                        continue;

                if(unit->getType() == BWAPI::UnitTypes::Protoss_Arbiter || unit
      ->getType().isBuilding())
                        continue;

                if(mUnit->getDistance(unit) > 250)
                        continue;

                protectionUnits.insert(unit);
        }

        if(!protectionUnits.empty())
        {
                protectionUnits = protectionUnits.getBestFittingToCircle(136);
                if(!protectionUnits.empty())
                {
                        Position protectedArea = protectionUnits.getCenter();
                        if(mUnit->getDistance(protectedArea) > 110)
                        {
                                mUnit->move(protectedArea);
                                return true;
                        }
                }
        }

        return false;
}\end{DoxyCode}


\-Here is the call graph for this function\-:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{classDetectorAction_af4e2069fe6528c1205b0e4b64a56d366_cgraph}
\end{center}
\end{figure}




\-The documentation for this class was generated from the following files\-:\begin{DoxyCompactItemize}
\item 
\-Skynet/\-Skynet/\hyperlink{DetectorAction_8h}{\-Detector\-Action.\-h}\item 
\-Skynet/\-Skynet/\hyperlink{DetectorAction_8cpp}{\-Detector\-Action.\-cpp}\end{DoxyCompactItemize}
