1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- #pragma once
- #include <Model3D.h>
- #include <Either.h>
- #include "Inventory.h"
- #include "Chunk.h"
- #include "BlockType.h"
- #include "Registries.h"
- using namespace Framework;
- #define CONST_BLOCK(maybeBlock, type) (maybeBlock ? maybeBlock : STATIC_REGISTRY( BlockType ).zElement((int)type)->zDefault())
- class BasicBlockItemType;
- class Block : public Model3D, public Inventory
- {
- protected:
- bool visible;
- bool transparent;
- bool passable;
- float hp;
- float maxHP;
- float hardness;
- float speedModifier;
- const BlockType* zType;
- ItemType* zTool;
- Block* zNeighbours[ 6 ];
- int neighbourTypes[ 6 ];
- public:
- Block( const BlockType* zType, ItemType* zTool, Vec3<int> position, bool hasInventory );
- virtual ~Block();
- bool updateVisibility();
- virtual void setNeighbour( Direction dir, Framework::Either<Block*, int> neighbour );
- virtual void setNeighbourBlock( Direction dir, Block* zN );
- virtual void setNeighbourType( Direction dir, int type );
- void remove();
- bool isVisible() const;
- const BlockType* zBlockType() const;
- friend Chunk;
- friend BlockType;
- };
- class BasicBlockItem : public Item
- {
- protected:
- bool transparent;
- bool passable;
- float hp;
- float maxHP;
- float hardness;
- int toolId;
- float speedModifier;
- public:
- BasicBlockItem( const ItemType* zType, const char* name );
- friend BasicBlockItemType;
- friend BlockType;
- };
- class BasicBlockItemType : public ItemType
- {
- protected:
- BasicBlockItemType( int id );
- virtual void loadSuperItem( Item* zItem, Framework::StreamReader* zReader ) const override;
- };
|