| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- #include "MultiblockTree.h"
- #include "Block.h"
- using namespace Framework;
- MultiblockTree::MultiblockTree(
- int dimensionId, __int64 structureId, Framework::Vec3<int> 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<Block*> checked;
- Array<Block*> queue;
- Either<Block*, int> 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<int> uniquePosition) const
- {
- return new MultiblockTree(dimensionId, structureId, uniquePosition);
- }
|