MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / checkSellTrapTilesEditor

Method checkSellTrapTilesEditor

source/traps/TrapManager.cpp:629–666  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

627}
628
629void TrapManager::checkSellTrapTilesEditor(GameMap* gameMap, const InputManager& inputManager, InputCommand& inputCommand)
630{
631 if(inputManager.mCommandState == InputCommandState::infoOnly)
632 {
633 inputCommand.displayText(Ogre::ColourValue::White, "Remove tiles");
634 inputCommand.selectSquaredTiles(inputManager.mXPos, inputManager.mYPos, inputManager.mXPos, inputManager.mYPos);
635 return;
636 }
637
638 std::vector<Tile*> sellTiles;
639 std::vector<Tile*> tiles = gameMap->rectangularRegion(inputManager.mXPos,
640 inputManager.mYPos, inputManager.mLStartDragX, inputManager.mLStartDragY);
641 for(Tile* tile : tiles)
642 {
643 if(!tile->getIsTrap())
644 continue;
645
646 sellTiles.push_back(tile);
647 }
648
649 if(inputManager.mCommandState == InputCommandState::building)
650 {
651 inputCommand.selectTiles(sellTiles);
652 inputCommand.displayText(Ogre::ColourValue::White, "Remove tiles");
653 return;
654 }
655
656 inputCommand.unselectAllTiles();
657
658 ClientNotification *clientNotification = new ClientNotification(
659 ClientNotificationType::editorAskDestroyTrapTiles);
660 uint32_t nbTiles = sellTiles.size();
661 clientNotification->mPacket << nbTiles;
662 for(Tile* tile : sellTiles)
663 gameMap->tileToPacket(clientNotification->mPacket, tile);
664
665 ODClient::getSingleton().queueClientNotification(clientNotification);
666}
667
668void TrapManager::sellTrapTilesEditor(GameMap* gameMap, ODPacket& packet)
669{

Callers

nothing calls this directly

Calls 8

rectangularRegionMethod · 0.80
getIsTrapMethod · 0.80
tileToPacketMethod · 0.80
displayTextMethod · 0.45
selectSquaredTilesMethod · 0.45
selectTilesMethod · 0.45
unselectAllTilesMethod · 0.45

Tested by

no test coverage detected