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

124 lines
2.6 KiB

  1. /*
  2. * Copyright (C) 2017 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 COLONY_HPP
  20. #define COLONY_HPP
  21. #include <vector>
  22. #include "navmesh.hpp"
  23. #include <emergent/emergent.hpp>
  24. using namespace Emergent;
  25. class Ant;
  26. class Agent;
  27. class Pheromone;
  28. class Gait;
  29. /**
  30. * A colony of ants.
  31. */
  32. class Colony
  33. {
  34. public:
  35. Colony();
  36. ~Colony();
  37. Ant* spawn(Navmesh* navmesh, Navmesh::Triangle* triangle, const Vector3& position);
  38. void update(float dt);
  39. void setAntModel(Model* model);
  40. const Model* getAntModel() const;
  41. Model* getAntModel();
  42. const Animation* getTripodGaitAnimation() const;
  43. void queryAnts(const BoundingVolume& volume, std::list<Agent*>* results) const;
  44. std::size_t getAntCount() const;
  45. const Ant* getAnt(std::size_t index) const;
  46. Ant* getAnt(std::size_t index);
  47. void killAll();
  48. const Octree<Agent*>* getAntOctree() const;
  49. const Octree<Pheromone*>* getPheromoneOctree() const;
  50. private:
  51. // Rendering
  52. Model* antModel;
  53. const Animation* tripodGaitAnimation;
  54. // Locomotion
  55. float walkSpeed;
  56. float turnSpeed;
  57. Gait* tripodGait;
  58. Gait* rippleGait;
  59. Gait* slowWaveGait;
  60. std::vector<Ant*> ants;
  61. Octree<Agent*>* antOctree;
  62. std::vector<Pheromone*> pheromones;
  63. Octree<Pheromone*>* pheromoneOctree;
  64. };
  65. inline const Model* Colony::getAntModel() const
  66. {
  67. return antModel;
  68. }
  69. inline Model* Colony::getAntModel()
  70. {
  71. return antModel;
  72. }
  73. inline const Animation* Colony::getTripodGaitAnimation() const
  74. {
  75. return tripodGaitAnimation;
  76. }
  77. inline std::size_t Colony::getAntCount() const
  78. {
  79. return ants.size();
  80. }
  81. inline const Ant* Colony::getAnt(std::size_t index) const
  82. {
  83. return ants[index];
  84. }
  85. inline Ant* Colony::getAnt(std::size_t index)
  86. {
  87. return ants[index];
  88. }
  89. inline const Octree<Agent*>* Colony::getAntOctree() const
  90. {
  91. return antOctree;
  92. }
  93. inline const Octree<Pheromone*>* Colony::getPheromoneOctree() const
  94. {
  95. return pheromoneOctree;
  96. }
  97. #endif // COLONY_HPP