Block.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #pragma once
  2. #include "EventListener.h"
  3. #include "BlockType.h"
  4. #include "ReferenceCounter.h"
  5. #include "EventThrower.h"
  6. #include <Trie.h>
  7. class ItemType;
  8. class Chunk;
  9. enum DIRECTION
  10. {
  11. NORTH,
  12. EAST,
  13. SOUTH,
  14. WEST,
  15. TOP,
  16. BOTTOM,
  17. DIRECTION_COUNT
  18. };
  19. class Block : public virtual Framework::ReferenceCounter
  20. {
  21. private:
  22. BlockType *type;
  23. protected:
  24. bool transparent;
  25. bool passable;
  26. float hp;
  27. float maxHP;
  28. float hardness;
  29. BlockType *zType;
  30. ItemType *zTool;
  31. float speedModifier;
  32. int fluidCapacity;
  33. int fluidAmount;
  34. int fluidTypeId;
  35. int fluidSpeed;
  36. Block *neighbours[ DIRECTION_COUNT ];
  37. public:
  38. Block( BlockType *zType, ItemType *zTool );
  39. virtual void tick();
  40. virtual void postTick();
  41. /// <summary>
  42. /// adds fluid to the internal storage of this block
  43. /// </summary>
  44. /// <param name="fluidTypeId">the id of the fluid to add</param>
  45. /// <param name="amount">the amount of fluids to add</param>
  46. /// <param name="dir">the direction from witch the fluid is added</param>
  47. /// <returns>the amount of fluids that were added</returns>
  48. int addFluid( int fluidTypeId, int amount, DIRECTION dir );
  49. BlockType *zBlockType() const;
  50. bool isTransparent() const;
  51. bool isPassable() const;
  52. float getHP() const;
  53. float getMaxHP() const;
  54. float getHardness() const;
  55. ItemType *zEffectiveTool() const;
  56. float getSpeedModifier() const;
  57. int getFluidCapacity() const;
  58. int getFluidAmount() const;
  59. int getFluidTypeId() const;
  60. int getFluidSpeed() const;
  61. friend Chunk;
  62. };