World.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #pragma once
  2. #include <Welt3D.h>
  3. #include <Bildschirm.h>
  4. #include <Kam3D.h>
  5. #include <Thread.h>
  6. #include "Dimension.h"
  7. #include "PlayerKam.h"
  8. #define CHUNK_VISIBILITY_RANGE 6
  9. #define MAX_VIEW_DISTANCE CHUNK_SIZE * CHUNK_VISIBILITY_RANGE
  10. class World : public Framework::Thread
  11. {
  12. private:
  13. Dimension* currentDimension;
  14. Framework::Welt3D* renderedWorld;
  15. Framework::Bildschirm3D* zScreenPtr;
  16. PlayerKam* kam;
  17. Framework::Vec3<int> target;
  18. int entityTarget;
  19. bool hasTarget;
  20. bool firstMessage;
  21. int ownEntityId;
  22. Framework::Model3D* currentTarget;
  23. Array<Punkt> subscriptions;
  24. Critical subLock;
  25. public:
  26. World(Framework::Bildschirm3D* zScreen);
  27. ~World();
  28. void update(bool background);
  29. void setChunk(Chunk* chunk);
  30. void thread() override;
  31. Block* zBlockAt(Framework::Vec3<int> location) const;
  32. Block* getBlockAt(Framework::Vec3<int> location) const;
  33. Dimension* zDimension() const;
  34. void setVisibility(Chunk* zChunk, bool visible);
  35. void setVisibility(Entity* zEntity, bool visible);
  36. Framework::Punkt getChunkCenter(int x, int y) const;
  37. Entity* zEntity(int id) const;
  38. Entity* getEntity(int id) const;
  39. void removeEntity(int id);
  40. PlayerKam* zKamera() const;
  41. int getCurrentPlayerId() const;
  42. Entity* getCurrentPlayerEntity() const;
  43. void setTarget(Framework::Model3D* zTarget);
  44. void lockWorld();
  45. void unlockWorld();
  46. void onChunkAdded(Punkt pos);
  47. };