#include "BasicBlocks.h" #include "Game.h" #include "ItemEntity.h" #include "ItemSlot.h" #include "ItemStack.h" #include "ModelInfo.h" #include "TreeSeblingBlock.h" BasicBlock::BasicBlock(int typeId, Framework::Vec3 pos, int dimensionId) : BasicBlock(typeId, pos, dimensionId, false) {} BasicBlock::BasicBlock( int typeId, Framework::Vec3 pos, int dimensionId, bool hasInventory) : Block(typeId, pos, dimensionId, hasInventory) {} bool BasicBlock::onTick(TickQueue* zQueue, int numTicks, bool& blocked) { return 0; } void BasicBlock::onPostTick() {} BasicBlockType::BasicBlockType() : BlockType(), itemTypeName(), transparent(0), passable(0), speedModifier(1.f), interactable(1) {} bool BasicBlockType::initialize(Game* zGame) { if (itemTypeName.getLength()) { itemTypeId = zGame->getItemTypeId(itemTypeName); } else { itemTypeId = 0; } return itemTypeId >= 0 && BlockType::initialize(zGame); } void BasicBlockType::createSuperBlock(Block* zBlock, Item* zItem) const { BasicBlock* block = dynamic_cast(zBlock); block->transparent = transparent; block->passable = passable; block->hp = (float)getInitialMaxHP(); block->maxHP = (float)getInitialMaxHP(); block->hardness = getHardness(); block->speedModifier = speedModifier; block->interactable = interactable; for (ItemSlot* slot : itemSlots) { block->addSlot(new ItemSlot(*slot)); } BlockType::createSuperBlock(zBlock, zItem); } Block* BasicBlockType::createBlock( Framework::Vec3 position, int dimensionId) const { return new BasicBlock(getId(), position, dimensionId); } Item* BasicBlockType::createItem() const { if (getItemTypeName().istGleich("")) { return 0; } return Game::INSTANCE->zItemType(itemTypeId)->createItem(); } Framework::Text BasicBlockType::getItemTypeName() const { return itemTypeName; } ItemType* BasicBlockType::createItemType() const { if (getItemTypeName().istGleich("")) { return 0; } return new BasicBlockItemType(getItemTypeName(), new ModelInfo(zModel()->getModelPath(), zModel()->getTexturePaths(), zModel()->isTransparent(), zModel()->getSize() / 2.f), transparent, passable, getHardness(), speedModifier, getName(), 0, 50, getGroupNames()); } void BasicBlockType::setItemTypeName(Framework::Text itemTypeName) { this->itemTypeName = itemTypeName; } int BasicBlockType::getItemTypeId() const { return itemTypeId; } void BasicBlockType::setTransparent(bool transparent) { this->transparent = transparent; } bool BasicBlockType::isTransparent() const { return transparent; } void BasicBlockType::setPassable(bool passable) { this->passable = passable; } bool BasicBlockType::isPassable() const { return passable; } void BasicBlockType::setSpeedModifier(float speedModifier) { this->speedModifier = speedModifier; } float BasicBlockType::getSpeedModifier() const { return speedModifier; } void BasicBlockType::setInteractable(bool interactable) { this->interactable = interactable; } bool BasicBlockType::isInteractable() const { return interactable; } const Framework::RCArray& BasicBlockType::getInventorySlots() const { return itemSlots; } void BasicBlockType::addInventorySlot(ItemSlot* slot) { itemSlots.add(slot); }