MultiblockStructure.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #pragma once
  2. #include <Punkt.h>
  3. #include <ReferenceCounter.h>
  4. #include "Block.h"
  5. class MultiblockStructureType;
  6. class MultiblockStructureEnum
  7. {
  8. public:
  9. static const int TREE = 0;
  10. };
  11. class MultiblockStructure : public virtual Framework::ReferenceCounter
  12. {
  13. private:
  14. Framework::Array<Framework::Punkt> affectedChunks;
  15. Framework::Array<Framework::Vec3<int>> memberBlockPositions;
  16. Framework::Vec3<int> uniquePosition;
  17. int dimensionId;
  18. __int64 structureId;
  19. int structureTypeId;
  20. bool isLoading;
  21. protected:
  22. Framework::RCArray<Block> loadedMembers;
  23. public:
  24. MultiblockStructure(int dimensionId,
  25. __int64 structureId,
  26. Framework::Vec3<int> uniquePosition,
  27. int structureTypeId);
  28. ~MultiblockStructure();
  29. void onBlockLoaded(Block* block);
  30. void onBlockUnloaded(Block* zBlock);
  31. void addMemberPosition(Framework::Vec3<int> blockPos);
  32. virtual void onBlockRemoved(Block* zBlock);
  33. bool isEmpty() const;
  34. bool isFullyLoaded() const;
  35. bool isFullyUnloaded() const;
  36. bool isBlockMember(Block* zBlock) const;
  37. __int64 getStructureId() const;
  38. Framework::Vec3<int> getUniquePosition() const;
  39. int getStructureTypeId() const;
  40. friend MultiblockStructureType;
  41. };
  42. class MultiblockStructureType : public Framework::ReferenceCounter
  43. {
  44. private:
  45. const int id;
  46. protected:
  47. MultiblockStructureType(int id);
  48. ~MultiblockStructureType();
  49. virtual void loadSuperStructure(MultiblockStructure* zStructure,
  50. Framework::StreamReader* zReader) const;
  51. virtual void saveSuperStructure(MultiblockStructure* zStructure,
  52. Framework::StreamWriter* zWriter) const;
  53. virtual MultiblockStructure* createStructure(int dimensionId,
  54. __int64 structureId,
  55. Framework::Vec3<int> uniquePosition) const = 0;
  56. public:
  57. MultiblockStructure* loadStructure(int dimensionId,
  58. __int64 structureId,
  59. Framework::Vec3<int> uniquePosition,
  60. Framework::StreamReader* zReader) const;
  61. void saveStructure(MultiblockStructure* zStructure,
  62. Framework::StreamWriter* zWriter) const;
  63. int getId() const;
  64. };