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

70 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. #include "nest-system.hpp"
  20. #include "nest.hpp"
  21. #include "math/math.hpp"
  22. namespace ecs {
  23. nest_system::nest_system(ecs::registry& registry, ::resource_manager* resource_manager):
  24. entity_system(registry),
  25. resource_manager(resource_manager)
  26. {
  27. registry.on_construct<nest_component>().connect<&nest_system::on_nest_construct>(this);
  28. registry.on_destroy<nest_component>().connect<&nest_system::on_nest_destroy>(this);
  29. }
  30. nest_system::~nest_system()
  31. {}
  32. void nest_system::update(double t, double dt)
  33. {}
  34. void nest_system::on_nest_construct(ecs::registry& registry, ecs::entity entity, nest_component& component)
  35. {
  36. // Allocate a nest
  37. nest* nest = new ::nest();
  38. // Setup initial nest parameters
  39. nest->set_tunnel_radius(1.15f);
  40. nest::shaft* central_shaft = nest->get_central_shaft();
  41. central_shaft->chirality = -1.0f;
  42. central_shaft->rotation = math::radians(0.0f);
  43. central_shaft->depth = {0.0f, 100.0f};
  44. central_shaft->current_depth = 0.0f;
  45. central_shaft->radius = {0.0f, 5.0f};
  46. central_shaft->pitch = {4.0f, 8.0f};
  47. central_shaft->translation = {{{0.0f, 0.0f}, {20.0f, 11.0f}}};
  48. for (std::size_t i = 0; i < 4; ++i)
  49. {
  50. nest::chamber chamber;
  51. chamber.shaft = central_shaft;
  52. chamber.depth = (i + 1) * 23.0f;
  53. chamber.rotation = math::radians(0.0f);
  54. chamber.inner_radius = 4.0f;
  55. chamber.outer_radius = 10.0f;
  56. central_shaft->chambers.push_back(chamber);
  57. }
  58. }
  59. void nest_system::on_nest_destroy(ecs::registry& registry, ecs::entity entity)
  60. {}
  61. } // namespace ecs