12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- #pragma once
- #include "EventListener.h"
- #include "BlockType.h"
- #include "ReferenceCounter.h"
- #include "EventThrower.h"
- #include <Trie.h>
- 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();
- /// <summary>
- /// adds fluid to the internal storage of this block
- /// </summary>
- /// <param name="fluidTypeId">the id of the fluid to add</param>
- /// <param name="amount">the amount of fluids to add</param>
- /// <param name="dir">the direction from witch the fluid is added</param>
- /// <returns>the amount of fluids that were added</returns>
- 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;
- };
|