BWAPI
|
00001 #include <StructureAgent.h> 00002 #include <BWTA.h> 00003 00004 void StructureAgent::update() 00005 { 00006 // Send Units to nearest chokepoint 00007 BWTA::Chokepoint* chokepoint = BWTA::getNearestChokepoint(unit.getPosition()); 00008 if( chokepoint != NULL ) 00009 unit.setRallyPoint(chokepoint->getCenter()); 00010 00011 switch (state) 00012 { 00013 case IdleState: 00014 // fall through 00015 00016 case TrainState: 00017 if (!unit.isTraining() && !unit.isBeingConstructed()) 00018 { 00019 unit.train(unitTypeTarget); 00020 } 00021 else 00022 { 00023 //state = IdleState; 00024 } 00025 break; 00026 00027 case BuildState: 00028 if (unitTypeTarget.isAddon()) 00029 { 00030 if (unit.getAddon()->getType().getID() != unitTypeTarget.getID()) 00031 unit.buildAddon(unitTypeTarget); 00032 else 00033 state = IdleState; 00034 } 00035 } 00036 }