#include "CameraControlSystem.hpp" #include "Components/Transform.hpp" #include "Core/Coordinator.hpp" extern Coordinator gCoordinator; void CameraControlSystem::Init() { gCoordinator.AddEventListener(METHOD_LISTENER(Events::Window::INPUT, CameraControlSystem::InputListener)); } void CameraControlSystem::Update(float dt) { for (auto& entity : mEntities) { auto& transform = gCoordinator.GetComponent(entity); float speed = 20.0f; if (mButtons.test(static_cast(InputButtons::W))) { transform.position.z -= (dt * speed); } else if (mButtons.test(static_cast(InputButtons::S))) { transform.position.z += (dt * speed); } if (mButtons.test(static_cast(InputButtons::Q))) { transform.position.y += (dt * speed); } else if (mButtons.test(static_cast(InputButtons::E))) { transform.position.y -= (dt * speed); } if (mButtons.test(static_cast(InputButtons::A))) { transform.position.x -= (dt * speed); } else if (mButtons.test(static_cast(InputButtons::D))) { transform.position.x += (dt * speed); } } } void CameraControlSystem::InputListener(Event& event) { mButtons = event.GetParam>(Events::Window::Input::INPUT); }