\hypertarget{classSquadManagerClass}{\section{\-Squad\-Manager\-Class \-Class \-Reference}
\label{classSquadManagerClass}\index{\-Squad\-Manager\-Class@{\-Squad\-Manager\-Class}}
}


{\ttfamily \#include $<$\-Squad\-Manager.\-h$>$}



\-Collaboration diagram for \-Squad\-Manager\-Class\-:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=550pt]{classSquadManagerClass__coll__graph}
\end{center}
\end{figure}
\subsection*{\-Public \-Member \-Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{classSquadManagerClass_a253a0258949b9bdff083b10c7adc869f}{\-Squad\-Manager\-Class} ()
\item 
void \hyperlink{classSquadManagerClass_a0d4d1edd47bc2a3df7be8bb7e5fd5341}{update} ()
\item 
void \hyperlink{classSquadManagerClass_a507c4340f1d0d0624c518f72840f8061}{on\-Change\-Build} ()
\item 
\hyperlink{BaseSquad_8h_a08edd0fd5385b55578b85f5fce05ae6c}{\-Base\-Squad\-Task\-Pointer} \hyperlink{classSquadManagerClass_ac7296feb0c421611d1744740956ffa99}{create\-Squad} (\hyperlink{BuildOrder_8h_ac4ec08819f2cc9ac5ddbb68fdeccdcd1}{\-Squad\-Type} type)
\end{DoxyCompactItemize}
\subsection*{\-Private \-Attributes}
\begin{DoxyCompactItemize}
\item 
std\-::map$<$ \hyperlink{BuildOrder_8h_ac4ec08819f2cc9ac5ddbb68fdeccdcd1}{\-Squad\-Type}, std\-::set\*
$<$ \hyperlink{BaseSquad_8h_a08edd0fd5385b55578b85f5fce05ae6c}{\-Base\-Squad\-Task\-Pointer} $>$ $>$ \hyperlink{classSquadManagerClass_a9189638067aa63dadf7ddd2c1d4bb8de}{m\-Squads}
\item 
\hyperlink{BuildOrder_8h_a542f03dc7d3ea96b4a75927437d0fd4a}{\-Army\-Behaviour} \hyperlink{classSquadManagerClass_a5cbd81a3fbd84b15ddb6d6432135cd94}{m\-Current\-Behaviour}
\item 
\hyperlink{BaseSquad_8h_a08edd0fd5385b55578b85f5fce05ae6c}{\-Base\-Squad\-Task\-Pointer} \hyperlink{classSquadManagerClass_abafaf8dd0fa0c502b62ea975b490b774}{m\-Default\-Squad}
\item 
std\-::map$<$ \hyperlink{Base_8h_aeee60104d9f1947526194ec22d997f69}{\-Base}, \*
\hyperlink{DefenseSquad_8h_a9841e2c8e019a0ccd6861f30f3cc5144}{\-Defense\-Squad\-Pointer} $>$ \hyperlink{classSquadManagerClass_a9682837f110915bb51719965c7ca46d3}{m\-Defense\-Squads}
\end{DoxyCompactItemize}


\subsection{\-Detailed \-Description}


\-Definition at line 10 of file \-Squad\-Manager.\-h.



\subsection{\-Constructor \& \-Destructor \-Documentation}
\hypertarget{classSquadManagerClass_a253a0258949b9bdff083b10c7adc869f}{\index{\-Squad\-Manager\-Class@{\-Squad\-Manager\-Class}!\-Squad\-Manager\-Class@{\-Squad\-Manager\-Class}}
\index{\-Squad\-Manager\-Class@{\-Squad\-Manager\-Class}!SquadManagerClass@{\-Squad\-Manager\-Class}}
\subsubsection[{\-Squad\-Manager\-Class}]{\setlength{\rightskip}{0pt plus 5cm}{\bf \-Squad\-Manager\-Class\-::\-Squad\-Manager\-Class} (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}\label{classSquadManagerClass_a253a0258949b9bdff083b10c7adc869f}


\-Definition at line 8 of file \-Squad\-Manager.\-cpp.



\-References create\-Squad(), and m\-Default\-Squad.


\begin{DoxyCode}
{
        mDefaultSquad = createSquad(SquadType::DefaultSquad);
}
\end{DoxyCode}


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




\subsection{\-Member \-Function \-Documentation}
\hypertarget{classSquadManagerClass_ac7296feb0c421611d1744740956ffa99}{\index{\-Squad\-Manager\-Class@{\-Squad\-Manager\-Class}!create\-Squad@{create\-Squad}}
\index{create\-Squad@{create\-Squad}!SquadManagerClass@{\-Squad\-Manager\-Class}}
\subsubsection[{create\-Squad}]{\setlength{\rightskip}{0pt plus 5cm}{\bf \-Base\-Squad\-Task\-Pointer} {\bf \-Squad\-Manager\-Class\-::create\-Squad} (
\begin{DoxyParamCaption}
\item[{{\bf \-Squad\-Type}}]{type}
\end{DoxyParamCaption}
)}}\label{classSquadManagerClass_ac7296feb0c421611d1744740956ffa99}


\-Definition at line 102 of file \-Squad\-Manager.\-cpp.



\-References \-Singleton$<$ T $>$\-::\-Instance(), m\-Current\-Behaviour, m\-Squads, and \-Safe\-Enum$<$ def, inner $>$\-::underlying().



\-Referenced by on\-Change\-Build(), \-Squad\-Manager\-Class(), and update().


\begin{DoxyCode}
{
        BaseSquadTaskPointer task;

        switch(type.underlying())
        {
        case SquadType::DefaultSquad:
                task = BaseSquadTaskPointer(new DefaultSquadTask(
      mCurrentBehaviour));
                break;
        case SquadType::DefenseSquad:
                task = BaseSquadTaskPointer(new DefenseSquadTask(
      mCurrentBehaviour));
                break;
        case SquadType::ReaverDropSquad:
                //task = BaseSquadTaskPointer(new ReaverDropSquad());
                break;
        case SquadType::DarkTemplerSquad:
                //task = BaseSquadTaskPointer(new DarkTemplerSquad());
                break;
        case SquadType::CorsairSquad:
                //task = BaseSquadTaskPointer(new CorsairSquad());
                break;
        }

        if(task)
        {
                mSquads[type].insert(task);
                TaskManager::Instance().addTask(task);
        }

        return task;
}\end{DoxyCode}


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




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


\hypertarget{classSquadManagerClass_a507c4340f1d0d0624c518f72840f8061}{\index{\-Squad\-Manager\-Class@{\-Squad\-Manager\-Class}!on\-Change\-Build@{on\-Change\-Build}}
\index{on\-Change\-Build@{on\-Change\-Build}!SquadManagerClass@{\-Squad\-Manager\-Class}}
\subsubsection[{on\-Change\-Build}]{\setlength{\rightskip}{0pt plus 5cm}void {\bf \-Squad\-Manager\-Class\-::on\-Change\-Build} (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}\label{classSquadManagerClass_a507c4340f1d0d0624c518f72840f8061}


\-Definition at line 37 of file \-Squad\-Manager.\-cpp.



\-References create\-Squad(), \-Singleton$<$ T $>$\-::\-Instance(), m\-Current\-Behaviour, and m\-Squads.


\begin{DoxyCode}
{
        const std::map<SquadType, int> &squads = BuildOrderManager::Instance().
      getCurrentBuild().getSquads();
        for(std::map<SquadType, int>::const_iterator it = squads.begin(); it !=
       squads.end(); ++it)
        {
                if(it->first == SquadType::DefaultSquad || it->first == 
      SquadType::DefenseSquad)
                        continue;

                int numNeeded = it->second - mSquads[it->first].size();
                while(numNeeded != 0)
                {
                        if(numNeeded < 0)
                        {
                                ++numNeeded;

                                int smallest = std::numeric_limits<int>::max();
                                BaseSquadTaskPointer smallestSquad;
                                for each(BaseSquadTaskPointer squad in mSquads[
      it->first])
                                {
                                        int size = squad->controlSize();
                                        if(size < smallest)
                                        {
                                                smallest = size;
                                                smallestSquad = squad;
                                        }
                                }

                                if(smallestSquad)
                                {
                                        smallestSquad->cancel();
                                        mSquads[it->first].erase(smallestSquad)
      ;
                                }
                        }
                        else
                        {
                                --numNeeded;
                                createSquad(it->first);
                        }
                }
        }

        for(std::map<SquadType, std::set<BaseSquadTaskPointer>>::iterator o = 
      mSquads.begin(); o != mSquads.end();)
        {
                if(o->first != SquadType::DefaultSquad && o->first != 
      SquadType::DefenseSquad && squads.find(o->first) == squads.end())
                {
                        for each(BaseSquadTaskPointer task in o->second)
                        {
                                task->cancel();
                        }

                        mSquads.erase(o++);
                }
                else ++o;
        }

        mCurrentBehaviour = BuildOrderManager::Instance().getCurrentBuild().
      getArmyBehaiour();
        for(std::map<SquadType, std::set<BaseSquadTaskPointer>>::iterator o = 
      mSquads.begin(); o != mSquads.end(); ++o)
        {
                for each(BaseSquadTaskPointer squad in o->second)
                {
                        squad->changeBehaviour(mCurrentBehaviour);
                }
        }
}
\end{DoxyCode}


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


\hypertarget{classSquadManagerClass_a0d4d1edd47bc2a3df7be8bb7e5fd5341}{\index{\-Squad\-Manager\-Class@{\-Squad\-Manager\-Class}!update@{update}}
\index{update@{update}!SquadManagerClass@{\-Squad\-Manager\-Class}}
\subsubsection[{update}]{\setlength{\rightskip}{0pt plus 5cm}void {\bf \-Squad\-Manager\-Class\-::update} (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}\label{classSquadManagerClass_a0d4d1edd47bc2a3df7be8bb7e5fd5341}


\-Definition at line 13 of file \-Squad\-Manager.\-cpp.



\-References create\-Squad(), \-Action\-Type\-Def\-::\-Defend, \-Singleton$<$ T $>$\-::\-Instance(), m\-Defense\-Squads, and \-Defense\-Squad\-Task\-::set\-Goal().


\begin{DoxyCode}
{
        for(std::map<Base, DefenseSquadPointer>::iterator it = mDefenseSquads.
      begin(); it != mDefenseSquads.end();)
        {
                if(it->first->getEnemyThreats().empty() || (it->first->
      isMinedOut() && it->first->getNumberOfTechBuildings() == 0))
                        it->second->cancel();

                if(it->second->hasEnded())
                        mDefenseSquads.erase(it++);
                else
                        ++it;
        }

        for each(Base base in BaseTracker::Instance().getPlayerBases())
        {
                if(!base->getEnemyThreats().empty() && (base->
      getNumberOfTechBuildings() > 0 || (!base->isMinedOut() && base->getResourceDepot())) && 
      mDefenseSquads.count(base) == 0)
                {
                        DefenseSquadPointer squad = 
      std::tr1::static_pointer_cast<DefenseSquadTask>(createSquad(SquadType::DefenseSquad));
                        squad->setGoal(Goal(ActionType::Defend, base));
                        mDefenseSquads[base] = squad;
                }
        }
}
\end{DoxyCode}


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




\subsection{\-Member \-Data \-Documentation}
\hypertarget{classSquadManagerClass_a5cbd81a3fbd84b15ddb6d6432135cd94}{\index{\-Squad\-Manager\-Class@{\-Squad\-Manager\-Class}!m\-Current\-Behaviour@{m\-Current\-Behaviour}}
\index{m\-Current\-Behaviour@{m\-Current\-Behaviour}!SquadManagerClass@{\-Squad\-Manager\-Class}}
\subsubsection[{m\-Current\-Behaviour}]{\setlength{\rightskip}{0pt plus 5cm}{\bf \-Army\-Behaviour} {\bf \-Squad\-Manager\-Class\-::m\-Current\-Behaviour}\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}\label{classSquadManagerClass_a5cbd81a3fbd84b15ddb6d6432135cd94}


\-Definition at line 23 of file \-Squad\-Manager.\-h.



\-Referenced by create\-Squad(), and on\-Change\-Build().

\hypertarget{classSquadManagerClass_abafaf8dd0fa0c502b62ea975b490b774}{\index{\-Squad\-Manager\-Class@{\-Squad\-Manager\-Class}!m\-Default\-Squad@{m\-Default\-Squad}}
\index{m\-Default\-Squad@{m\-Default\-Squad}!SquadManagerClass@{\-Squad\-Manager\-Class}}
\subsubsection[{m\-Default\-Squad}]{\setlength{\rightskip}{0pt plus 5cm}{\bf \-Base\-Squad\-Task\-Pointer} {\bf \-Squad\-Manager\-Class\-::m\-Default\-Squad}\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}\label{classSquadManagerClass_abafaf8dd0fa0c502b62ea975b490b774}


\-Definition at line 25 of file \-Squad\-Manager.\-h.



\-Referenced by \-Squad\-Manager\-Class().

\hypertarget{classSquadManagerClass_a9682837f110915bb51719965c7ca46d3}{\index{\-Squad\-Manager\-Class@{\-Squad\-Manager\-Class}!m\-Defense\-Squads@{m\-Defense\-Squads}}
\index{m\-Defense\-Squads@{m\-Defense\-Squads}!SquadManagerClass@{\-Squad\-Manager\-Class}}
\subsubsection[{m\-Defense\-Squads}]{\setlength{\rightskip}{0pt plus 5cm}std\-::map$<${\bf \-Base}, {\bf \-Defense\-Squad\-Pointer}$>$ {\bf \-Squad\-Manager\-Class\-::m\-Defense\-Squads}\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}\label{classSquadManagerClass_a9682837f110915bb51719965c7ca46d3}


\-Definition at line 26 of file \-Squad\-Manager.\-h.



\-Referenced by update().

\hypertarget{classSquadManagerClass_a9189638067aa63dadf7ddd2c1d4bb8de}{\index{\-Squad\-Manager\-Class@{\-Squad\-Manager\-Class}!m\-Squads@{m\-Squads}}
\index{m\-Squads@{m\-Squads}!SquadManagerClass@{\-Squad\-Manager\-Class}}
\subsubsection[{m\-Squads}]{\setlength{\rightskip}{0pt plus 5cm}std\-::map$<${\bf \-Squad\-Type}, std\-::set$<${\bf \-Base\-Squad\-Task\-Pointer}$>$ $>$ {\bf \-Squad\-Manager\-Class\-::m\-Squads}\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}\label{classSquadManagerClass_a9189638067aa63dadf7ddd2c1d4bb8de}


\-Definition at line 21 of file \-Squad\-Manager.\-h.



\-Referenced by create\-Squad(), and on\-Change\-Build().



\-The documentation for this class was generated from the following files\-:\begin{DoxyCompactItemize}
\item 
\-Skynet/\-Skynet/\hyperlink{SquadManager_8h}{\-Squad\-Manager.\-h}\item 
\-Skynet/\-Skynet/\hyperlink{SquadManager_8cpp}{\-Squad\-Manager.\-cpp}\end{DoxyCompactItemize}
