#include "BasicBlocks.h" BasicBlock::BasicBlock(const BlockType* zType, ItemType* zTool, Framework::Vec3 pos) : Block(zType, zTool, pos, false) {} bool BasicBlock::onTick(TickQueue* zQueue, int numTicks, bool& blocked) { return 0; } void BasicBlock::onPostTick() {} BasicBlockType::BasicBlockType(int typeId, int itemTypeId) : BlockType(typeId, 0), itemType(itemTypeId), transparent(0), passable(0), maxHp(100.f), hardness(1.f), zTool(0), speedModifier(1.f), interactable(1) {} void BasicBlockType::createSuperBlock(Block* zBlock, Item* zItem) const { if (zItem) BlockType::createSuperBlock(zBlock, zItem); else { BasicBlock* block = dynamic_cast(zBlock); if (!block) throw "DirtBlockType::createSuperBlock was called with a block witch is not an instance of BasicBlock"; block->transparent = transparent; block->passable = passable; block->hp = maxHp; block->maxHP = maxHp; block->hardness = hardness; block->zTool = zTool; block->speedModifier = speedModifier; block->interactable = interactable; } } Block* BasicBlockType::createBlock(Framework::Vec3 position) const { return new BasicBlock(this, 0, position); } Item* BasicBlockType::createItem() const { return StaticRegistry::INSTANCE.zElement(itemType)->createItem(); } // Dirt DirtBlockType::DirtBlockType() : BasicBlockType(ID, DirtBlockItemType::ID) { defaultBlock = createBlockAt({ 0, 0, 0 }, 0); } DirtBlockItemType::DirtBlockItemType() : BasicBlockItemType(ID, "Dirt", 0, 0) {} Item* DirtBlockItemType::createItem() const { BasicBlockItem* item = new BasicBlockItem(this, DirtBlockType::INSTANCE, "Dirt"); initializeItem(item, 0, 0, 100, 100, 1, 0, 1); return item; } // Stone StoneBlockType::StoneBlockType() : BasicBlockType(ID, StoneBlockItemType::ID) { hardness = 2.f; defaultBlock = createBlockAt({ 0, 0, 0 }, 0); } StoneBlockItemType::StoneBlockItemType() : BasicBlockItemType(ID, "Stone", 0, 0) {} Item* StoneBlockItemType::createItem() const { BasicBlockItem* item = new BasicBlockItem(this, StoneBlockType::INSTANCE, "Stone"); initializeItem(item, 0, 0, 100, 100, 2, 0, 1); return item; } // Sand SandBlockType::SandBlockType() : BasicBlockType(ID, SandBlockItemType::ID) { hardness = 0.5f; defaultBlock = createBlockAt({ 0, 0, 0 }, 0); } SandBlockItemType::SandBlockItemType() : BasicBlockItemType(ID, "Sand", 0, 0) {} Item* SandBlockItemType::createItem() const { BasicBlockItem* item = new BasicBlockItem(this, SandBlockType::INSTANCE, "Sand"); initializeItem(item, 0, 0, 100, 100, 0.5f, 0, 1); return item; } // Oak Wood OakBlockType::OakBlockType() : BasicBlockType(ID, OakBlockItemType::ID) { hardness = 1.5f; defaultBlock = createBlockAt({ 0, 0, 0 }, 0); } OakBlockItemType::OakBlockItemType() : BasicBlockItemType(ID, "Oak", 0, 0) {} Item* OakBlockItemType::createItem() const { BasicBlockItem* item = new BasicBlockItem(this, OakBlockType::INSTANCE, "Oak"); initializeItem(item, 0, 0, 100, 100, 1.5f, 0, 1); return item; } // Leaves Wood LeavesBlockType::LeavesBlockType() : BasicBlockType(ID, LeavesBlockItemType::ID) { hardness = 0.1f; defaultBlock = createBlockAt({ 0, 0, 0 }, 0); } LeavesBlockItemType::LeavesBlockItemType() : BasicBlockItemType(ID, "Leaves", 0, 0) {} Item* LeavesBlockItemType::createItem() const { BasicBlockItem* item = new BasicBlockItem(this, LeavesBlockType::INSTANCE, "Leaves"); initializeItem(item, 0, 0, 100, 100, 0.1f, 0, 1); return item; } // Gravel GravelBlockType::GravelBlockType() : BasicBlockType(ID, GravelBlockItemType::ID) { hardness = 0.75f; defaultBlock = createBlockAt({ 0, 0, 0 }, 0); } GravelBlockItemType::GravelBlockItemType() : BasicBlockItemType(ID, "Gravel", 0, 0) {} Item* GravelBlockItemType::createItem() const { BasicBlockItem* item = new BasicBlockItem(this, GravelBlockType::INSTANCE, "Gravel"); initializeItem(item, 0, 0, 100, 100, 0.75f, 0, 1); return item; } // Granite GraniteBlockType::GraniteBlockType() : BasicBlockType(ID, GraniteBlockItemType::ID) { hardness = 3.f; defaultBlock = createBlockAt({ 0, 0, 0 }, 0); } GraniteBlockItemType::GraniteBlockItemType() : BasicBlockItemType(ID, "Granite", 0, 0) {} Item* GraniteBlockItemType::createItem() const { BasicBlockItem* item = new BasicBlockItem(this, GraniteBlockType::INSTANCE, "Granite"); initializeItem(item, 0, 0, 100, 100, 3.f, 0, 1); return item; } // Cobble CobbleBlockType::CobbleBlockType() : BasicBlockType(ID, CobbleBlockItemType::ID) { hardness = 1.f; defaultBlock = createBlockAt({ 0, 0, 0 }, 0); } CobbleBlockItemType::CobbleBlockItemType() : BasicBlockItemType(ID, "Cobble", 0, 0) {} Item* CobbleBlockItemType::createItem() const { BasicBlockItem* item = new BasicBlockItem(this, CobbleBlockType::INSTANCE, "Cobble"); initializeItem(item, 0, 0, 100, 100, 1.f, 0, 1); return item; } // Birch Wood BirchBlockType::BirchBlockType() : BasicBlockType(ID, BirchBlockItemType::ID) { hardness = 1.5f; defaultBlock = createBlockAt({ 0, 0, 0 }, 0); } BirchBlockItemType::BirchBlockItemType() : BasicBlockItemType(ID, "Birch", 0, 0) {} Item* BirchBlockItemType::createItem() const { BasicBlockItem* item = new BasicBlockItem(this, BirchBlockType::INSTANCE, "Birch"); initializeItem(item, 0, 0, 100, 100, 1.5f, 0, 1); return item; } // Beech Wood BeechBlockType::BeechBlockType() : BasicBlockType(ID, BeechBlockItemType::ID) { hardness = 1.5f; defaultBlock = createBlockAt({ 0, 0, 0 }, 0); } BeechBlockItemType::BeechBlockItemType() : BasicBlockItemType(ID, "Beech", 0, 0) {} Item* BeechBlockItemType::createItem() const { BasicBlockItem* item = new BasicBlockItem(this, BeechBlockType::INSTANCE, "Beech"); initializeItem(item, 0, 0, 100, 100, 1.5f, 0, 1); return item; } // Basalt BasaltBlockType::BasaltBlockType() : BasicBlockType(ID, BasaltBlockItemType::ID) { hardness = 2.f; defaultBlock = createBlockAt({ 0, 0, 0 }, 0); } BasaltBlockItemType::BasaltBlockItemType() : BasicBlockItemType(ID, "Basalt", 0, 0) {} Item* BasaltBlockItemType::createItem() const { BasicBlockItem* item = new BasicBlockItem(this, BasaltBlockType::INSTANCE, "Basalt"); initializeItem(item, 0, 0, 100, 100, 2.f, 0, 1); return item; }