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

67 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_TRACKING_SYSTEM_HPP
  20. #define ANTKEEPER_TRACKING_SYSTEM_HPP
  21. #include "entity-system.hpp"
  22. #include "game/components/trackable-component.hpp"
  23. #include "event/event-handler.hpp"
  24. #include "game/events/tool-events.hpp"
  25. #include <unordered_map>
  26. class material;
  27. class event_dispatcher;
  28. class resource_manager;
  29. class model;
  30. namespace scene
  31. {
  32. class collection;
  33. class model_instance;
  34. }
  35. class tracking_system: public entity_system,
  36. public event_handler<tool_pressed_event>,
  37. public event_handler<tool_released_event>
  38. {
  39. public:
  40. tracking_system(entt::registry& registry, event_dispatcher* event_dispatcher, resource_manager* resource_manager);
  41. virtual ~tracking_system();
  42. virtual void update(double t, double dt);
  43. void set_scene(scene::collection* collection);
  44. void set_viewport(const float4& viewport);
  45. private:
  46. void on_component_construct(entt::registry& registry, entt::entity entity, ecs::trackable_component& component);
  47. void on_component_destroy(entt::registry& registry, entt::entity entity);
  48. virtual void handle_event(const tool_pressed_event& event);
  49. virtual void handle_event(const tool_released_event& event);
  50. event_dispatcher* event_dispatcher;
  51. resource_manager* resource_manager;
  52. scene::collection* scene_collection;
  53. model* tracker_model;
  54. model* paint_ball_model;
  55. material** paint_ball_materials;
  56. std::unordered_map<entt::entity, scene::model_instance*> trackers;
  57. };
  58. #endif // ANTKEEPER_TRACKING_SYSTEM_HPP