MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / initialMapPartRemoval

Method initialMapPartRemoval

game/state/battle/battle.cpp:424–460  ·  view source on GitHub ↗

Remove all solid walls and ground that ended up inside large units For now, removes only ground

Source from the content-addressed store, hash-verified

422// Remove all solid walls and ground that ended up inside large units
423// For now, removes only ground
424void Battle::initialMapPartRemoval(GameState &state)
425{
426 std::ignore = state;
427 for (auto &u : units)
428 {
429 if (!u.second->isLarge())
430 continue;
431 for (int x = 0; x < 1; x++)
432 {
433 for (int y = 0; y < 1; y++)
434 {
435 auto t = map->getTile(u.second->position + Vec3<float>{-x, -y, 1.0f});
436 if (t->solidGround)
437 {
438 std::list<sp<TileObjectBattleMapPart>> partsToKill;
439 for (auto &o : t->ownedObjects)
440 {
441 if (o->getType() == TileObject::Type::Ground)
442 {
443 partsToKill.push_back(
444 std::static_pointer_cast<TileObjectBattleMapPart>(o));
445 }
446 }
447 for (auto &p : partsToKill)
448 {
449 LogWarning("Removing MP %s at %s as it's blocking unit %s",
450 p->getOwner()->type.id, p->getPosition(), u.first);
451 auto mp = p->getOwner();
452 mp->destroyed = true;
453 mp->tileObject->removeFromMap();
454 mp->tileObject.reset();
455 }
456 }
457 }
458 }
459 }
460}
461
462void Battle::initialMapPartLinkUp()
463{

Callers

nothing calls this directly

Calls 7

isLargeMethod · 0.80
getTileMethod · 0.80
getTypeMethod · 0.45
getOwnerMethod · 0.45
getPositionMethod · 0.45
removeFromMapMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected