123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 |
- #include "BasicBlocks.h"
- BasicBlock::BasicBlock(const BlockType* zType, ItemType* zTool, Framework::Vec3<int> 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<BasicBlock*>(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<int> position) const
- {
- return new BasicBlock(this, 0, position);
- }
- Item* BasicBlockType::createItem() const
- {
- return StaticRegistry<ItemType>::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;
- }
|