FluidBlock.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. Framework::Vec3<float> lightWeights;
  13. protected:
  14. virtual bool onTick(
  15. TickQueue* zQueue, int numTicks, bool& blocked) override;
  16. virtual void onPostTick() override;
  17. void broadcastAmount();
  18. public:
  19. FluidBlock(int typeId,
  20. Framework::Vec3<int> pos,
  21. int dimensionId,
  22. Framework::Vec3<float> lightWeights);
  23. virtual ~FluidBlock();
  24. virtual void sendModelInfo(NetworkMessage* zMessage) override;
  25. static void sortByAmound(FluidBlock** array, int count);
  26. virtual void filterPassingLight(unsigned char rgb[3]) const override;
  27. short getFluidAmount() const;
  28. friend FluidBlockType;
  29. };
  30. class FluidBlockType : public BlockType
  31. {
  32. private:
  33. Framework::Vec3<float> lightWeights;
  34. protected:
  35. virtual void loadSuperBlock(Block* zBlock,
  36. Framework::StreamReader* zReader,
  37. int dimensionId) const override;
  38. virtual void saveSuperBlock(
  39. Block* zBlock, Framework::StreamWriter* zWriter) const override;
  40. virtual Item* createItem() const override;
  41. virtual Block* createBlock(
  42. Framework::Vec3<int> position, int dimesionId) const override;
  43. public:
  44. FluidBlockType(int id,
  45. ModelInfo model,
  46. const char* name,
  47. int mapColor,
  48. Framework::Vec3<float> lightWeights);
  49. bool isFluid() const override;
  50. };