#include "MultiblockTree.h" #include "Block.h" using namespace Framework; MultiblockTree::MultiblockTree( int dimensionId, __int64 structureId, Framework::Vec3 uniquePosition) : MultiblockStructure(dimensionId, structureId, uniquePosition, MultiblockStructureEnum::TREE) {} void MultiblockTree::onBlockRemoved( Entity* zActor, Item* zUsedItem, ItemSkill* zUsedSkill, Block* zBlock) { if (isBlockMember(zBlock)) { MultiblockStructure::onBlockRemoved( zActor, zUsedItem, zUsedSkill, zBlock); for (int d = 4; d >= 0; d--) { bool foundStablizer = 0; Array checked; Array queue; Either tmp = Game::INSTANCE->zBlockAt( zBlock->getPos() + getDirection(getDirectionFromIndex(d)), getDimensionId(), 0); Block* current = tmp.isA() ? tmp.getA() : 0; if (current && isBlockMember(current)) queue.add(current); while (queue.getEintragAnzahl() > 0) { current = queue.get(0); queue.remove(0); tmp = Game::INSTANCE->zBlockAt( zBlock->getPos() + getDirection(getDirectionFromIndex(d) | BOTTOM), getDimensionId(), 0); Block* bottom = tmp.isA() ? tmp.getA() : 0; if (bottom && isBlockMember(bottom)) { foundStablizer = 1; break; } checked.add(current); for (int i = 0; i < 4; i++) { tmp = Game::INSTANCE->zBlockAt( zBlock->getPos() + getDirection(getDirectionFromIndex(d) | getDirectionFromIndex(i)), getDimensionId(), 0); Block* neighbor = tmp.isA() ? tmp.getA() : 0; if (neighbor && isBlockMember(neighbor)) { bool found = 0; for (Block* b : checked) { if (b == neighbor) { found = 1; break; } } if (!found) { for (Block* b : queue) { if (b == neighbor) { found = 1; break; } } } if (!found) queue.add(neighbor); } } } if (!foundStablizer) { for (Block* b : checked) b->setHP(zActor, zUsedItem, zUsedSkill, 0); } } } } MultiblockTreeStructureType::MultiblockTreeStructureType() : MultiblockStructureType(MultiblockStructureEnum::TREE) {} MultiblockStructure* MultiblockTreeStructureType::createStructure( int dimensionId, __int64 structureId, Framework::Vec3 uniquePosition) const { return new MultiblockTree(dimensionId, structureId, uniquePosition); }