Dimension.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #pragma once
  2. #include <Punkt.h>
  3. #include <Reader.h>
  4. #include "Chunk.h"
  5. #include "NetworkResponse.h"
  6. class Dimension : public virtual Framework::ReferenceCounter
  7. {
  8. private:
  9. int dimensionId;
  10. float gravity;
  11. Framework::Trie<Chunk>* chunks;
  12. Framework::Array<Chunk*> chunkList;
  13. Framework::RCArray<Entity>* entities;
  14. void getAddrOf(Framework::Punkt cPos, char* addr) const;
  15. void getAddrOfWorld(Framework::Punkt wPos, char* addr) const;
  16. public:
  17. Dimension(int id);
  18. ~Dimension();
  19. void api(Framework::StreamReader* zRequest, NetworkResponse* zResponse);
  20. void tickEntities();
  21. Framework::Either<Block*, int> zBlock(Framework::Vec3<int> location);
  22. Block* zRealBlockInstance(Framework::Vec3<int> location);
  23. void placeBlock(Framework::Vec3<int> location, Framework::Either<Block*, int> block);
  24. void addEntity(Entity* entity);
  25. void setChunk(Chunk* chunk, Framework::Punkt center);
  26. void save(Framework::Text worldDir) const;
  27. int getDimensionId() const;
  28. bool hasChunck(int x, int y) const;
  29. Chunk* zChunk(Framework::Punkt wPos) const;
  30. float getGravity() const;
  31. void removeOldChunks();
  32. Entity* zEntity(int id);
  33. Entity* zNearestEntity(Framework::Vec3<float> pos, std::function<bool(Entity*)> filter);
  34. void removeEntity(int id);
  35. };