LightSources.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #pragma once
  2. #include "BasicBlocks.h"
  3. #include "Block.h"
  4. #include "BlockType.h"
  5. class BasicLightSourceBlockType;
  6. class LightSourceItemType;
  7. class LightSourceItem : public BasicBlockItem
  8. {
  9. protected:
  10. int color;
  11. public:
  12. LightSourceItem(int itemType, int blockType, const char* name);
  13. virtual bool canBeStackedWith(const Item* zItem) const override;
  14. friend LightSourceItemType;
  15. friend BasicLightSourceBlockType;
  16. };
  17. class LightSourceItemType : public BasicBlockItemType
  18. {
  19. private:
  20. int color;
  21. protected:
  22. virtual void loadSuperItem(
  23. Item* zItem, Framework::StreamReader* zReader) const override;
  24. virtual void saveSuperItem(
  25. const Item* zItem, Framework::StreamWriter* zWriter) const override;
  26. virtual Item* createItem() const override;
  27. public:
  28. LightSourceItemType(
  29. int id, const char* name, const ModelInfo model, int blockTypeId);
  30. LightSourceItemType* setColor(int color);
  31. };
  32. class BasicLightSource : public Block
  33. {
  34. protected:
  35. void setLight(int light);
  36. public:
  37. BasicLightSource(int typeId, Framework::Vec3<int> pos, int dimensionId);
  38. virtual bool onTick(
  39. TickQueue* zQueue, int numTicks, bool& blocked) override;
  40. virtual void onPostTick() override;
  41. friend BasicLightSourceBlockType;
  42. };
  43. class BasicLightSourceBlockType : public BlockType
  44. {
  45. private:
  46. int itemType;
  47. bool transparent;
  48. bool passable;
  49. float hardness;
  50. bool interactable;
  51. int color;
  52. protected:
  53. virtual void createSuperBlock(Block* zBlock, Item* zItem) const override;
  54. virtual void loadSuperBlock(Block* zBlock,
  55. Framework::StreamReader* zReader,
  56. int dimensionId) const override;
  57. virtual void saveSuperBlock(
  58. Block* zBlock, Framework::StreamWriter* zWriter) const override;
  59. public:
  60. BasicLightSourceBlockType(
  61. int typeId, int itemTypeId, ModelInfo model, const char* name);
  62. virtual Block* createBlock(
  63. Framework::Vec3<int> position, int dimensionId) const override;
  64. virtual Item* createItem() const override;
  65. BasicLightSourceBlockType* setHardness(float hardness);
  66. BasicLightSourceBlockType* setColor(int color);
  67. };