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

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