💿🐜 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.3 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_ENTITY_SYSTEM_TRACKING_HPP
  20. #define ANTKEEPER_ENTITY_SYSTEM_TRACKING_HPP
  21. #include "entity/systems/updatable.hpp"
  22. #include "entity/components/trackable.hpp"
  23. #include "entity/id.hpp"
  24. #include "event/event-handler.hpp"
  25. #include "game/events/tool-events.hpp"
  26. #include <unordered_map>
  27. #include "scene/collection.hpp"
  28. #include "scene/model-instance.hpp"
  29. class material;
  30. class event_dispatcher;
  31. class resource_manager;
  32. class model;
  33. namespace entity {
  34. namespace system {
  35. class tracking: public updatable,
  36. public event_handler<tool_pressed_event>,
  37. public event_handler<tool_released_event>
  38. {
  39. public:
  40. tracking(entity::registry& registry, event_dispatcher* event_dispatcher, resource_manager* resource_manager);
  41. virtual ~tracking();
  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(entity::registry& registry, entity::id entity_id, entity::component::trackable& component);
  47. void on_component_destroy(entity::registry& registry, entity::id entity_id);
  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<entity::id, scene::model_instance*> trackers;
  57. };
  58. } // namespace system
  59. } // namespace entity
  60. #endif // ANTKEEPER_ENTITY_SYSTEM_TRACKING_HPP