💿🐜 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.

78 lines
2.2 KiB

  1. /*
  2. * Copyright (C) 2021 Christopher J. Howard
  3. *
  4. * This file is part of Antkeeper source code.
  5. *
  6. * Antkeeper source code is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Antkeeper source code is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef ANTKEEPER_ECS_VEGETATION_SYSTEM_HPP
  20. #define ANTKEEPER_ECS_VEGETATION_SYSTEM_HPP
  21. #include "entity-system.hpp"
  22. #include "ecs/components/terrain-component.hpp"
  23. #include "ecs/entity.hpp"
  24. #include "scene/collection.hpp"
  25. class model;
  26. namespace ecs {
  27. /**
  28. * Places vegetation patches on terrain.
  29. */
  30. class vegetation_system: public entity_system
  31. {
  32. public:
  33. vegetation_system(ecs::registry& registry);
  34. ~vegetation_system();
  35. virtual void update(double t, double dt);
  36. /**
  37. * Sets the terrain patch size.
  38. *
  39. * @param size Size of the terrain patch.
  40. */
  41. void set_terrain_patch_size(float size);
  42. /**
  43. * Sets the vegetation patch size.
  44. *
  45. * @param subdivisions Number of times a terrain patch should be subdivided into vegetation patches.
  46. */
  47. void set_vegetation_patch_resolution(int subdivisions);
  48. void set_vegetation_density(float density);
  49. void set_vegetation_model(::model* model);
  50. void set_scene(scene::collection* collection);
  51. private:
  52. void on_terrain_construct(ecs::registry& registry, ecs::entity entity, ecs::terrain_component& component);
  53. void on_terrain_destroy(ecs::registry& registry, ecs::entity entity);
  54. float terrain_patch_size;
  55. float vegetation_patch_size;
  56. int vegetation_patch_columns;
  57. int vegetation_patch_rows;
  58. float vegetation_density;
  59. model* vegetation_model;
  60. scene::collection* scene_collection;
  61. };
  62. } // namespace ecs
  63. #endif // ANTKEEPER_ECS_VEGETATION_SYSTEM_HPP