| 18 | } |
| 19 | |
| 20 | bool Enter_Transport::execute(aithread &thread) const |
| 21 | { |
| 22 | if ( this->getOpcode() == AISCRIPT::Enum::ENTER_BUNKER || this->getOpcode() == AISCRIPT::Enum::ENTER_TRANSPORT ) |
| 23 | { |
| 24 | Unitset unitsForTrans( Broodwar->getUnitsInRectangle(thread.getLocation().topLeft, thread.getLocation().bottomRight, |
| 25 | this->getOpcode() == AISCRIPT::Enum::ENTER_BUNKER ? bunkerProc : transProc) ); |
| 26 | |
| 27 | // Iterate the units that are to enter the bunkers |
| 28 | for ( auto u : unitsForTrans ) |
| 29 | { |
| 30 | // Find a bunker closest to the current unit that has space available |
| 31 | Unit pClosest = u->getClosestUnit( (this->getOpcode() == AISCRIPT::Enum::ENTER_BUNKER ? GetType == UnitTypes::Terran_Bunker : GetType != UnitTypes::Terran_Bunker) && |
| 32 | IsTransport && |
| 33 | GetPlayer == Broodwar->self() && |
| 34 | SpaceRemaining >= u->getType().spaceRequired() ); |
| 35 | |
| 36 | if ( pClosest ) // If a bunker was found |
| 37 | u->rightClick(pClosest); |
| 38 | } |
| 39 | } |
| 40 | else if ( this->getOpcode() == AISCRIPT::Enum::EXIT_TRANSPORT ) |
| 41 | { |
| 42 | // Normally we are supposed to check the type here, but we don't need to save processing time and can let BWAPI sort it out |
| 43 | Broodwar->getUnitsInRectangle(thread.getLocation().topLeft, thread.getLocation().bottomRight).unloadAll(); |
| 44 | } |
| 45 | |
| 46 | // Debug and return |
| 47 | thread.saveDebug(Text::Green, this->getOpcode()); |
| 48 | return true; |
| 49 | } |
nothing calls this directly
no test coverage detected