scene.hpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // scene.hpp
  3. // engine
  4. //
  5. // Created by Sam Jaffe on 9/2/16.
  6. //
  7. #pragma once
  8. #include <memory>
  9. #include <vector>
  10. #include "game/math/math_fwd.hpp"
  11. #include "game/util/identity.hpp"
  12. #include "vector/vector.hpp"
  13. #include "engine_fwd.hpp"
  14. namespace graphics {
  15. class renderer;
  16. }
  17. namespace engine {
  18. class entity;
  19. class scene : public identity<scene, std::string> {
  20. public:
  21. using identity<scene, std::string>::identity;
  22. virtual ~scene();
  23. virtual void update(float delta);
  24. virtual void render();
  25. virtual void handle_key_event(event::key_event evt);
  26. virtual void handle_mouse_event(event::mouse_event evt);
  27. math::vec2 size() const;
  28. key_binding const & keys() const;
  29. protected:
  30. void change_scene(std::string const & scene_id);
  31. protected:
  32. graphics::renderer * renderer;
  33. std::vector<entity> entities;
  34. // Map from entity::collides_with -> [entity*]
  35. std::unordered_map<collision_t, std::vector<entity *>> colliders;
  36. // Map from entity::collides_as -> [entity*]
  37. std::unordered_map<collision_t, std::vector<entity *>> collidables;
  38. private:
  39. math::vec2 local_scene_dimension_;
  40. key_binding keys_;
  41. std::weak_ptr<game_dispatch> dispatch_;
  42. };
  43. }