MultiblockStructure.h 2.1 KB

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