MultiblockStructure.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #pragma once
  2. #include <ReferenceCounter.h>
  3. #include <Punkt.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, __int64 structureId, Framework::Vec3<int> uniquePosition, int structureTypeId);
  25. ~MultiblockStructure();
  26. void onBlockLoaded(Block* block);
  27. void onBlockUnloaded(Block* zBlock);
  28. void addMemberPosition(Framework::Vec3<int > blockPos);
  29. virtual void onBlockRemoved(Block* zBlock);
  30. bool isEmpty() const;
  31. bool isFullyLoaded() const;
  32. bool isFullyUnloaded() const;
  33. bool isBlockMember(Block* zBlock) const;
  34. __int64 getStructureId() const;
  35. Framework::Vec3<int> getUniquePosition() const;
  36. int getStructureTypeId() const;
  37. friend MultiblockStructureType;
  38. };
  39. class MultiblockStructureType : public Framework::ReferenceCounter
  40. {
  41. private:
  42. const int id;
  43. protected:
  44. MultiblockStructureType(int id);
  45. ~MultiblockStructureType();
  46. virtual void loadSuperStructure(MultiblockStructure* zStructure, Framework::StreamReader* zReader) const;
  47. virtual void saveSuperStructure(MultiblockStructure* zStructure, Framework::StreamWriter* zWriter) const;
  48. virtual MultiblockStructure* createStructure(int dimensionId, __int64 structureId, Framework::Vec3<int> uniquePosition) const = 0;
  49. public:
  50. MultiblockStructure* loadStructure(int dimensionId, __int64 structureId, Framework::Vec3<int> uniquePosition, Framework::StreamReader* zReader) const;
  51. void saveStructure(MultiblockStructure* zStructure, Framework::StreamWriter* zWriter) const;
  52. int getId() const;
  53. };