enemy_system.cpp 720 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "enemy_system.hpp"

#include "movement_comp.hpp"

namespace phase_shifter::gameplay {
	
	Enemy_system::Enemy_system(mirrage::ecs::Entity_manager& entity_manager) : _entity_manager(entity_manager)
	{
		_entity_manager.register_component_type<Fixed_path_comp>();
	}

	void Enemy_system::update(mirrage::util::Time dt)
	{
		for (auto&& [movement, fixed_path] : _entity_manager.list<Movement_comp, Fixed_path_comp>()) {
			if (!movement.move) {
				float rad_direction = fixed_path.next_direction() * mirrage::util::PI / 180.f;
				if (rad_direction >= 0) {
					movement.aim.x      = std::sin(rad_direction);
					movement.aim.y      = -std::cos(rad_direction);
					movement.move       = true;
				}
			}
		}
	}
}