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

Method OnStep

tests/test_feature_layer.cc:233–307  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

231 }
232
233 void OnStep() override {
234 const ObservationInterface* obs = agent_->Observation();
235 ActionFeatureLayerInterface* action = agent_->ActionsFeatureLayer();
236 if (obs->GetGameLoop() == starting_gameloop_ + 20) {
237 camera_pos_ = ConvertWorldToMinimap(obs->GetGameInfo(), unit_pos_);
238 action->CameraMove(camera_pos_);
239 }
240 if (obs->GetGameLoop() == starting_gameloop_ + 21) {
241 if (obs->GetFeatureLayerActions().camera_moves.empty()) {
242 ReportError("Camera move is not being reported.");
243 }
244 else {
245 Point2DI new_camera_pos = obs->GetFeatureLayerActions().camera_moves.front().center_minimap;
246 if (new_camera_pos != camera_pos_) {
247 ReportError("Camera Move is reporting the incorrect location");
248 }
249 }
250 }
251 if (obs->GetGameLoop() == starting_gameloop_ + 24) {
252 action->Select(Point2DI(0, 0), Point2DI(60, 60));
253 }
254 if (obs->GetGameLoop() == starting_gameloop_ + 25) {
255 unit_pos_i_ = ConvertWorldToCamera(obs->GetGameInfo(), obs->GetCameraPos(), unit_pos_);
256 action->Select(unit_pos_i_, PointSelectionType::PtToggle);
257 if (obs->GetFeatureLayerActions().select_rects.empty()) {
258 ReportError("Rectangle select is not being reported.");
259 }
260 else {
261 if (obs->GetFeatureLayerActions().select_rects.front().select_screen.front().from != Point2DI(0, 0)) {
262 ReportError("Rectangle select is reporting the wrong start location");
263 }
264 if (obs->GetFeatureLayerActions().select_rects.front().select_screen.front().to != Point2DI(60, 60)) {
265 ReportError("Rectangle select is reporting the wrong end location");
266 }
267 }
268 }
269 if (obs->GetGameLoop() == starting_gameloop_ + 26) {
270 action->UnitCommand(ABILITY_ID::MOVE, camera_pos_);
271 if (obs->GetFeatureLayerActions().select_points.empty()) {
272 ReportError("Select Point is not being reported.");
273 }
274 else {
275 Point2DI select_pos = obs->GetFeatureLayerActions().select_points.front().select_screen;
276 if (select_pos == unit_pos_i_) {
277 ReportError("Select Point is reporting the incorrect location");
278 }
279 if (obs->GetFeatureLayerActions().select_points.front().type != PointSelectionType::PtToggle) {
280 ReportError("Select Point is reporting the incorrect Selection Type");
281 }
282 }
283 }
284 if (obs->GetGameLoop() == starting_gameloop_ + 27) {
285 action->UnitCommand(ABILITY_ID::BURROWDOWN);
286 if (obs->GetFeatureLayerActions().unit_commands.empty()) {
287 ReportError("Unit Command is not being reported.");
288 }
289 else {
290 Point2DI target = obs->GetFeatureLayerActions().unit_commands.front().target;

Callers

nothing calls this directly

Calls 10

ConvertWorldToMinimapFunction · 0.85
Point2DIClass · 0.85
ConvertWorldToCameraFunction · 0.85
ObservationMethod · 0.80
ActionsFeatureLayerMethod · 0.80
GetGameLoopMethod · 0.80
CameraMoveMethod · 0.80
SelectMethod · 0.80
GetCameraPosMethod · 0.80
UnitCommandMethod · 0.80

Tested by

no test coverage detected