level_system.hpp 947 Bytes
Newer Older
Georg Schäfer's avatar
Georg Schäfer committed
1
2
#pragma once

Georg Schäfer's avatar
Georg Schäfer committed
3
#include "../util/collision.hpp"
Georg Schäfer's avatar
Georg Schäfer committed
4
5
#include "level.hpp"

6
7
8
#include <functional>
#include <unordered_map>

Georg Schäfer's avatar
Georg Schäfer committed
9
10
#include <glm/vec3.hpp>

Georg Schäfer's avatar
Georg Schäfer committed
11
12
13
14
15
16
17
18
19
20
21
22
23
24
namespace mirrage::ecs {
	class Entity_manager;
}

namespace mirrage::asset {
	class Asset_manager;
}

namespace phase_shifter::level {
	class Level_system {
	  public:
		Level_system(mirrage::ecs::Entity_manager& entities, mirrage::asset::Asset_manager& assets);

		auto load(const std::string& name) -> void;
Georg Schäfer's avatar
Georg Schäfer committed
25
		auto ray_cast(const glm::vec2& origin, const glm::vec2& direction) -> std::pair<bool, util::Contact>;
Georg Schäfer's avatar
Georg Schäfer committed
26
27

	  private:
28
29
30
		auto _spawn_function(const std::string& key)
		        -> std::function<auto(const Tile&, const glm::vec3&)->void>;

Georg Schäfer's avatar
Georg Schäfer committed
31
32
33
34
		mirrage::ecs::Entity_manager&  _entities;
		mirrage::asset::Asset_manager& _assets;

		Level_ptr _current_level;
35
		std::unordered_map<std::string, std::function<auto(const Tile&, const glm::vec3&)->void>> _spawners;
Georg Schäfer's avatar
Georg Schäfer committed
36
37
	};
} // namespace phase_shifter::level