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

145 lines
2.9 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. class PheromoneMatrix;
  30. /**
  31. * A colony of ants.
  32. */
  33. class Colony
  34. {
  35. public:
  36. Colony();
  37. ~Colony();
  38. Ant* spawn(Navmesh* navmesh, Navmesh::Triangle* triangle, const Vector3& position);
  39. void update(float dt);
  40. void setAntModel(Model* model);
  41. const Model* getAntModel() const;
  42. Model* getAntModel();
  43. const Animation* getTripodGaitAnimation() const;
  44. void queryAnts(const BoundingVolume& volume, std::list<Agent*>* results) const;
  45. std::size_t getAntCount() const;
  46. const Ant* getAnt(std::size_t index) const;
  47. Ant* getAnt(std::size_t index);
  48. void killAll();
  49. const Octree<Agent*>* getAntOctree() const;
  50. const PheromoneMatrix* getHomingMatrix() const;
  51. PheromoneMatrix* getHomingMatrix();
  52. const PheromoneMatrix* getRecruitmentMatrix() const;
  53. PheromoneMatrix* getRecruitmentMatrix();
  54. private:
  55. // Rendering
  56. Model* antModel;
  57. const Animation* tripodGaitAnimation;
  58. // Locomotion
  59. float walkSpeed;
  60. float turnSpeed;
  61. Gait* tripodGait;
  62. Gait* rippleGait;
  63. Gait* slowWaveGait;
  64. std::vector<Ant*> ants;
  65. Octree<Agent*>* antOctree;
  66. PheromoneMatrix* homingMatrix;
  67. PheromoneMatrix* recruitmentMatrix;
  68. };
  69. inline const Model* Colony::getAntModel() const
  70. {
  71. return antModel;
  72. }
  73. inline Model* Colony::getAntModel()
  74. {
  75. return antModel;
  76. }
  77. inline const Animation* Colony::getTripodGaitAnimation() const
  78. {
  79. return tripodGaitAnimation;
  80. }
  81. inline std::size_t Colony::getAntCount() const
  82. {
  83. return ants.size();
  84. }
  85. inline const Ant* Colony::getAnt(std::size_t index) const
  86. {
  87. return ants[index];
  88. }
  89. inline Ant* Colony::getAnt(std::size_t index)
  90. {
  91. return ants[index];
  92. }
  93. inline const Octree<Agent*>* Colony::getAntOctree() const
  94. {
  95. return antOctree;
  96. }
  97. inline const PheromoneMatrix* Colony::getHomingMatrix() const
  98. {
  99. return homingMatrix;
  100. }
  101. inline PheromoneMatrix* Colony::getHomingMatrix()
  102. {
  103. return homingMatrix;
  104. }
  105. inline const PheromoneMatrix* Colony::getRecruitmentMatrix() const
  106. {
  107. return recruitmentMatrix;
  108. }
  109. inline PheromoneMatrix* Colony::getRecruitmentMatrix()
  110. {
  111. return recruitmentMatrix;
  112. }
  113. #endif // COLONY_HPP