FluidBlock.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #pragma once
  2. #include "Block.h"
  3. #include "TickQueue.h"
  4. class FluidBlockType;
  5. class FluidBlock : public Block
  6. {
  7. private:
  8. Directions flowDir;
  9. short fluidAmount;
  10. short lastBroadcastedAmount;
  11. int nextFlow;
  12. protected:
  13. virtual bool onTick(
  14. TickQueue* zQueue, int numTicks, bool& blocked) override;
  15. virtual void onPostTick() override;
  16. void broadcastAmount();
  17. public:
  18. FluidBlock(int typeId, Framework::Vec3<int> pos, int dimensionId);
  19. virtual ~FluidBlock();
  20. virtual void sendModelInfo(NetworkMessage* zMessage) override;
  21. static void sortByAmound(FluidBlock** array, int count);
  22. friend FluidBlockType;
  23. };
  24. class FluidBlockType : public BlockType
  25. {
  26. protected:
  27. virtual void loadSuperBlock(Block* zBlock,
  28. Framework::StreamReader* zReader,
  29. int dimensionId) const override;
  30. virtual void saveSuperBlock(
  31. Block* zBlock, Framework::StreamWriter* zWriter) const override;
  32. virtual Item* createItem() const override;
  33. virtual Block* createBlock(Framework::Vec3<int> position, int dimesionId) const override;
  34. public:
  35. FluidBlockType(int id, ModelInfo model, const char* name, int mapColor);
  36. };