MCPcopy Create free account
hub / github.com/Blizzard/s2client-api / OnStep

Method OnStep

tests/test_unit_command.cc:409–449  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

407 }
408
409 void OnStep() override {
410 const ObservationInterface* obs = agent_->Observation();
411 ActionInterface* act = agent_->Actions();
412
413 if (obs->GetGameLoop() < order_on_game_loop_) {
414 return;
415 }
416
417 const Units& units = obs->GetUnits(Unit::Alliance::Self);
418 for (const Unit& unit : units) {
419 if (unit.unit_type == test_unit_type_) {
420 test_unit_ = unit;
421 }
422 }
423
424 if (!factory_built_) {
425 act->UnitCommand(test_unit_, ABILITY_ID::BUILD_FACTORY, origin_pt_);
426 factory_built_ = true;
427 }
428
429 for (const Unit& unit : units) {
430 if (unit.unit_type == UNIT_TYPEID::TERRAN_FACTORY) {
431 test_factory_ = unit;
432 }
433 }
434
435 if (obs->GetGameLoop() < order_on_game_loop_ + 10) {
436 return;
437 }
438
439 if (!orders_verified_ && factory_built_) {
440 VerifyUnitOrders(test_unit_, ABILITY_ID::BUILD_FACTORY);
441 }
442
443 if (!ability_command_sent_) {
444 VerifyUnitExistsAndComplete(UNIT_TYPEID::TERRAN_FACTORY, false);
445 act->UnitCommand(test_factory_, test_ability_);
446 ability_command_sent_ = true;
447 }
448
449 }
450
451 void OnTestFinish() override {
452 VerifyUnitIdleAfterOrder(test_unit_type_);

Callers

nothing calls this directly

Calls 5

ObservationMethod · 0.80
ActionsMethod · 0.80
GetGameLoopMethod · 0.80
GetUnitsMethod · 0.80
UnitCommandMethod · 0.80

Tested by

no test coverage detected