LightSources.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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);
  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(int typeId, int itemTypeId, ModelInfo model, const char *name);
  61. virtual Block* createBlock(Framework::Vec3<int> position) const override;
  62. virtual Item* createItem() const override;
  63. BasicLightSourceBlockType* setHardness(float hardness);
  64. BasicLightSourceBlockType* setColor(int color);
  65. };