💿🐜 Antkeeper source code https://antkeeper.com
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.

83 lines
1.7 KiB

  1. #ifndef LEVEL_HPP
  2. #define LEVEL_HPP
  3. #include "../configuration.hpp"
  4. #include "terrain.hpp"
  5. #include <string>
  6. #include <vector>
  7. /**
  8. * Contains the parameters required to load a level.
  9. */
  10. class LevelParameterSet
  11. {
  12. public:
  13. LevelParameterSet();
  14. ~LevelParameterSet();
  15. // Loads level parameters from a .lvl file
  16. bool load(const std::string& filename);
  17. std::string filename;
  18. std::string biome;
  19. std::string heightmap;
  20. };
  21. /**
  22. * A level.
  23. */
  24. class Level
  25. {
  26. public:
  27. Level();
  28. ~Level();
  29. // Loads a level from a level file
  30. bool load(const LevelParameterSet& params);
  31. Terrain terrain;
  32. ModelInstance terrainSurface;
  33. ModelInstance terrainSubsurface;
  34. };
  35. /**
  36. * A collection of level parameters which constitute a campaign.
  37. */
  38. class Campaign
  39. {
  40. public:
  41. Campaign();
  42. ~Campaign();
  43. // Loads all level parameter sets in a directory with the file name pattern `<world>-<level>.lvl`
  44. bool load(const std::string& directory);
  45. // Returns the number of worlds in the campaign
  46. std::size_t getWorldCount() const;
  47. // Returns the number of levels in a world
  48. std::size_t getLevelCount(std::size_t worldIndex) const;
  49. // Returns the file for the level with the specified indices
  50. const LevelParameterSet* getLevelParams(std::size_t worldIndex, std::size_t levelIndex) const;
  51. private:
  52. std::vector<std::vector<LevelParameterSet>> levelParameterSets;
  53. };
  54. inline std::size_t Campaign::getWorldCount() const
  55. {
  56. return levelParameterSets.size();
  57. }
  58. inline std::size_t Campaign::getLevelCount(std::size_t worldIndex) const
  59. {
  60. return levelParameterSets[worldIndex].size();
  61. }
  62. inline const LevelParameterSet* Campaign::getLevelParams(std::size_t worldIndex, std::size_t levelIndex) const
  63. {
  64. return &levelParameterSets[worldIndex][levelIndex];
  65. }
  66. #endif // LEVEL_HPP