A 2D tile-based sandbox game.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #pragma once
  2. #include <vector>
  3. #include <utility>
  4. #include <memory>
  5. #include "common.h"
  6. #include "Chunk.h"
  7. #include "Tile.h"
  8. #include "TileMap.h"
  9. #include "WorldGen.h"
  10. #include "Entity.h"
  11. namespace Swan {
  12. class World;
  13. class WorldPlane {
  14. public:
  15. using ID = uint16_t;
  16. WorldPlane(ID id, World *world, std::shared_ptr<WorldGen> gen):
  17. id_(id), world_(world), gen_(gen) {}
  18. Entity &spawnEntity(const std::string &name, const Vec2 &pos);
  19. Chunk &getChunk(int x, int y);
  20. void setTileID(int x, int y, Tile::ID id);
  21. Tile &getTile(int x, int y);
  22. Entity &spawnPlayer();
  23. void draw(Win &win);
  24. void update(float dt);
  25. void tick();
  26. ID id_;
  27. World *world_;
  28. std::shared_ptr<WorldGen> gen_;
  29. private:
  30. std::map<std::pair<int, int>, std::unique_ptr<Chunk>> chunks_;
  31. std::vector<std::unique_ptr<Entity>> entities_;
  32. };
  33. }