#pragma once #include "EventListener.h" #include "BlockType.h" #include "ReferenceCounter.h" #include "EventThrower.h" #include class ItemType; class Chunk; enum DIRECTION { NORTH, EAST, SOUTH, WEST, TOP, BOTTOM, DIRECTION_COUNT }; class Block : public virtual Framework::ReferenceCounter { private: BlockType *type; protected: bool transparent; bool passable; float hp; float maxHP; float hardness; BlockType *zType; ItemType *zTool; float speedModifier; int fluidCapacity; int fluidAmount; int fluidTypeId; int fluidSpeed; Block *neighbours[ DIRECTION_COUNT ]; public: Block( BlockType *zType, ItemType *zTool ); virtual void tick(); virtual void postTick(); /// /// adds fluid to the internal storage of this block /// /// the id of the fluid to add /// the amount of fluids to add /// the direction from witch the fluid is added /// the amount of fluids that were added int addFluid( int fluidTypeId, int amount, DIRECTION dir ); BlockType *zBlockType() const; bool isTransparent() const; bool isPassable() const; float getHP() const; float getMaxHP() const; float getHardness() const; ItemType *zEffectiveTool() const; float getSpeedModifier() const; int getFluidCapacity() const; int getFluidAmount() const; int getFluidTypeId() const; int getFluidSpeed() const; friend Chunk; };