MCPcopy Create free account
hub / github.com/bwapi/bwapi / execute

Method execute

bwapi/BWScriptEmulator/Enter_Transport.cpp:20–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18}
19
20bool 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}

Callers

nothing calls this directly

Calls 10

getOpcodeMethod · 0.80
getLocationMethod · 0.80
spaceRequiredMethod · 0.80
saveDebugMethod · 0.80
getUnitsInRectangleMethod · 0.45
getClosestUnitMethod · 0.45
selfMethod · 0.45
getTypeMethod · 0.45
rightClickMethod · 0.45
unloadAllMethod · 0.45

Tested by

no test coverage detected