BWAPI
Public Member Functions
GoalAction Class Reference

#include <GoalAction.h>

Inheritance diagram for GoalAction:
Inheritance graph
[legend]
Collaboration diagram for GoalAction:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 GoalAction (Unit unit)
bool update (const Goal &squadGoal, const UnitGroup &squadUnitGroup)

Detailed Description

Definition at line 6 of file GoalAction.h.


Constructor & Destructor Documentation

GoalAction::GoalAction ( Unit  unit) [inline]

Definition at line 9 of file GoalAction.h.


Member Function Documentation

bool GoalAction::update ( const Goal squadGoal,
const UnitGroup squadUnitGroup 
) [virtual]

Implements SingleMicroActionBaseClass.

Definition at line 5 of file GoalAction.cpp.

References GoalTypeDef::Base, Goal::getBase(), UnitGroup::getClosestUnit(), Goal::getEngageUnits(), Goal::getGoalType(), Goal::getPosition(), Goal::getUnit(), SingleMicroActionBaseClass::mUnit, GoalTypeDef::Position, SafeEnum< def, inner >::underlying(), GoalTypeDef::Unit, and GoalTypeDef::UnitGroup.

{
        switch(squadGoal.getGoalType().underlying())
        {
        case GoalType::Base:
                {
                        Unit enemy = squadGoal.getBase()->getClosestEnemyBuilding(mUnit->getPosition());
                        if(enemy)
                        {
                                mUnit->move(enemy->getPosition(), 128);
                                return true;
                        }
                        else
                        {
                                mUnit->move(squadGoal.getBase()->getCenterLocation(), 128);
                                return true;
                        }
                }
        case GoalType::Position:
                mUnit->move(squadGoal.getPosition(), 128);
                return true;
        case GoalType::Unit:
                mUnit->move(squadGoal.getUnit()->getPosition(), 128);
                return true;
        case GoalType::UnitGroup:
                mUnit->move(squadGoal.getEngageUnits().getClosestUnit(mUnit)->getPosition(), 128);
                return true;
        }
        return false;
}

Here is the call graph for this function:


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines