MultiblockStructure.h 1.8 KB

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