123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291 |
- #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, ModelInfo model)
- : BlockType(typeId, 0, model, 1, 100, 0),
- itemType(itemTypeId),
- transparent(0),
- passable(0),
- hardness(1.f),
- zTool(0),
- speedModifier(1.f),
- interactable(1)
- {}
- void BasicBlockType::createSuperBlock(Block* zBlock, Item* zItem) const
- {
- 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 = (float)getInitialMaxHP();
- block->maxHP = (float)getInitialMaxHP();
- block->hardness = hardness;
- block->zTool = zTool;
- block->speedModifier = speedModifier;
- block->interactable = interactable;
- BlockType::createSuperBlock(zBlock, zItem);
- }
- 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, ModelInfo("cube", { "blocks.ltdb/dirt.png", "blocks.ltdb/dirt.png", "blocks.ltdb/dirt.png", "blocks.ltdb/dirt.png", "blocks.ltdb/lawn.png", "blocks.ltdb/dirt.png" }))
- {
- defaultBlock = createBlockAt({ 0, 0, 0 }, 0);
- }
- DirtBlockItemType::DirtBlockItemType()
- : BasicBlockItemType(ID, "Dirt", 0, 0, ModelInfo("itemCube", "blocks.ltdb/dirt.png", 6))
- {}
- Item* DirtBlockItemType::createItem() const
- {
- BasicBlockItem* item = new BasicBlockItem(this, DirtBlockType::INSTANCE, "Dirt");
- initializeItem(item, 0, 0, 1, 0, 1);
- return item;
- }
- // Stone
- StoneBlockType::StoneBlockType()
- : BasicBlockType(ID, StoneBlockItemType::ID, ModelInfo("cube", "blocks.ltdb/stone.png", 6))
- {
- hardness = 2.f;
- defaultBlock = createBlockAt({ 0, 0, 0 }, 0);
- }
- StoneBlockItemType::StoneBlockItemType()
- : BasicBlockItemType(ID, "Stone", 0, 0, ModelInfo("itemCube", "blocks.ltdb/stone.png", 6))
- {}
- Item* StoneBlockItemType::createItem() const
- {
- BasicBlockItem* item = new BasicBlockItem(this, StoneBlockType::INSTANCE, "Stone");
- initializeItem(item, 0, 0, 2, 0, 1);
- return item;
- }
- // Sand
- SandBlockType::SandBlockType()
- : BasicBlockType(ID, SandBlockItemType::ID, ModelInfo("cube", "blocks.ltdb/sand.png", 6))
- {
- hardness = 0.5f;
- defaultBlock = createBlockAt({ 0, 0, 0 }, 0);
- }
- SandBlockItemType::SandBlockItemType()
- : BasicBlockItemType(ID, "Sand", 0, 0, ModelInfo("itemCube", "blocks.ltdb/sand.png", 6))
- {}
- Item* SandBlockItemType::createItem() const
- {
- BasicBlockItem* item = new BasicBlockItem(this, SandBlockType::INSTANCE, "Sand");
- initializeItem(item, 0, 0, 0.5f, 0, 1);
- return item;
- }
- // Oak Wood
- OakBlockType::OakBlockType()
- : BasicBlockType(ID, OakBlockItemType::ID, ModelInfo("cube", "blocks.ltdb/oak.png", 6))
- {
- hardness = 1.5f;
- defaultBlock = createBlockAt({ 0, 0, 0 }, 0);
- }
- OakBlockItemType::OakBlockItemType()
- : BasicBlockItemType(ID, "Oak", 0, 0, ModelInfo("itemCube", "blocks.ltdb/oak.png", 6))
- {}
- Item* OakBlockItemType::createItem() const
- {
- BasicBlockItem* item = new BasicBlockItem(this, OakBlockType::INSTANCE, "Oak");
- initializeItem(item, 0, 0, 1.5f, 0, 1);
- return item;
- }
- // Leaves Wood
- LeavesBlockType::LeavesBlockType()
- : BasicBlockType(ID, LeavesBlockItemType::ID, ModelInfo("cube", "blocks.ltdb/leaves.png", 6))
- {
- hardness = 0.1f;
- defaultBlock = createBlockAt({ 0, 0, 0 }, 0);
- }
- LeavesBlockItemType::LeavesBlockItemType()
- : BasicBlockItemType(ID, "Leaves", 0, 0, ModelInfo("itemCube", "blocks.ltdb/leaves.png", 6))
- {}
- Item* LeavesBlockItemType::createItem() const
- {
- BasicBlockItem* item = new BasicBlockItem(this, LeavesBlockType::INSTANCE, "Leaves");
- initializeItem(item, 0, 0, 0.1f, 0, 1);
- return item;
- }
- // Gravel
- GravelBlockType::GravelBlockType()
- : BasicBlockType(ID, GravelBlockItemType::ID, ModelInfo("cube", "blocks.ltdb/gravel.png", 6))
- {
- hardness = 0.75f;
- defaultBlock = createBlockAt({ 0, 0, 0 }, 0);
- }
- GravelBlockItemType::GravelBlockItemType()
- : BasicBlockItemType(ID, "Gravel", 0, 0, ModelInfo("itemCube", "blocks.ltdb/gravel.png", 6))
- {}
- Item* GravelBlockItemType::createItem() const
- {
- BasicBlockItem* item = new BasicBlockItem(this, GravelBlockType::INSTANCE, "Gravel");
- initializeItem(item, 0, 0, 0.75f, 0, 1);
- return item;
- }
- // Granite
- GraniteBlockType::GraniteBlockType()
- : BasicBlockType(ID, GraniteBlockItemType::ID, ModelInfo("cube", "blocks.ltdb/granite.png", 6))
- {
- hardness = 3.f;
- defaultBlock = createBlockAt({ 0, 0, 0 }, 0);
- }
- GraniteBlockItemType::GraniteBlockItemType()
- : BasicBlockItemType(ID, "Granite", 0, 0, ModelInfo("itemCube", "blocks.ltdb/granite.png", 6))
- {}
- Item* GraniteBlockItemType::createItem() const
- {
- BasicBlockItem* item = new BasicBlockItem(this, GraniteBlockType::INSTANCE, "Granite");
- initializeItem(item, 0, 0, 3.f, 0, 1);
- return item;
- }
- // Cobble
- CobbleBlockType::CobbleBlockType()
- : BasicBlockType(ID, CobbleBlockItemType::ID, ModelInfo("cube", "blocks.ltdb/cobble.png", 6))
- {
- hardness = 1.f;
- defaultBlock = createBlockAt({ 0, 0, 0 }, 0);
- }
- CobbleBlockItemType::CobbleBlockItemType()
- : BasicBlockItemType(ID, "Cobble", 0, 0, ModelInfo("itemCube", "blocks.ltdb/cobble.png", 6))
- {}
- Item* CobbleBlockItemType::createItem() const
- {
- BasicBlockItem* item = new BasicBlockItem(this, CobbleBlockType::INSTANCE, "Cobble");
- initializeItem(item, 0, 0, 1.f, 0, 1);
- return item;
- }
- // Birch Wood
- BirchBlockType::BirchBlockType()
- : BasicBlockType(ID, BirchBlockItemType::ID, ModelInfo("cube", "blocks.ltdb/birch.png", 6))
- {
- hardness = 1.5f;
- defaultBlock = createBlockAt({ 0, 0, 0 }, 0);
- }
- BirchBlockItemType::BirchBlockItemType()
- : BasicBlockItemType(ID, "Birch", 0, 0, ModelInfo("itemCube", "blocks.ltdb/birch.png", 6))
- {}
- Item* BirchBlockItemType::createItem() const
- {
- BasicBlockItem* item = new BasicBlockItem(this, BirchBlockType::INSTANCE, "Birch");
- initializeItem(item, 0, 0, 1.5f, 0, 1);
- return item;
- }
- // Beech Wood
- BeechBlockType::BeechBlockType()
- : BasicBlockType(ID, BeechBlockItemType::ID, ModelInfo("cube", "blocks.ltdb/beech.png", 6))
- {
- hardness = 1.5f;
- defaultBlock = createBlockAt({ 0, 0, 0 }, 0);
- }
- BeechBlockItemType::BeechBlockItemType()
- : BasicBlockItemType(ID, "Beech", 0, 0, ModelInfo("itemCube", "blocks.ltdb/beech.png", 6))
- {}
- Item* BeechBlockItemType::createItem() const
- {
- BasicBlockItem* item = new BasicBlockItem(this, BeechBlockType::INSTANCE, "Beech");
- initializeItem(item, 0, 0, 1.5f, 0, 1);
- return item;
- }
- // Basalt
- BasaltBlockType::BasaltBlockType()
- : BasicBlockType(ID, BasaltBlockItemType::ID, ModelInfo("cube", "blocks.ltdb/basalt.png", 6))
- {
- hardness = 2.f;
- defaultBlock = createBlockAt({ 0, 0, 0 }, 0);
- }
- BasaltBlockItemType::BasaltBlockItemType()
- : BasicBlockItemType(ID, "Basalt", 0, 0, ModelInfo("itemCube", "blocks.ltdb/basalt.png", 6))
- {}
- Item* BasaltBlockItemType::createItem() const
- {
- BasicBlockItem* item = new BasicBlockItem(this, BasaltBlockType::INSTANCE, "Basalt");
- initializeItem(item, 0, 0, 2.f, 0, 1);
- return item;
- }
- // Pine Wood
- PineBlockType::PineBlockType()
- : BasicBlockType(ID, PineBlockItemType::ID, ModelInfo("cube", "blocks.ltdb/pine.png", 6))
- {
- hardness = 1.4f;
- defaultBlock = createBlockAt({ 0, 0, 0 }, 0);
- }
- PineBlockItemType::PineBlockItemType()
- : BasicBlockItemType(ID, "Pine", 0, 0, ModelInfo("itemCube", "blocks.ltdb/pine.png", 6))
- {}
- Item* PineBlockItemType::createItem() const
- {
- BasicBlockItem* item = new BasicBlockItem(this, PineBlockType::INSTANCE, "Pine");
- initializeItem(item, 0, 0, 1.4f, 0, 1);
- return item;
- }
|