2022-11-07 20:15:26 +00:00
|
|
|
#pragma once
|
|
|
|
|
2023-01-05 13:21:33 +00:00
|
|
|
#include "ecs_system.hpp"
|
2023-02-09 15:21:37 +00:00
|
|
|
#include "event_system.hpp"
|
|
|
|
|
2023-02-09 20:44:37 +00:00
|
|
|
#include "components/transform.hpp"
|
2023-02-09 15:21:37 +00:00
|
|
|
#include "systems/collisions.hpp"
|
2022-11-07 20:15:26 +00:00
|
|
|
|
2023-01-05 13:21:33 +00:00
|
|
|
struct CameraControllerComponent {
|
2022-11-07 20:15:26 +00:00
|
|
|
float m_cameraSensitivity = 0.007f;
|
|
|
|
|
|
|
|
float m_yaw = 0.0f;
|
|
|
|
float m_pitch = 0.0f;
|
|
|
|
|
2022-11-23 15:40:10 +00:00
|
|
|
const float walk_speed = 4.0f;
|
2022-11-07 20:15:26 +00:00
|
|
|
|
2023-01-28 00:24:04 +00:00
|
|
|
bool isGrounded = false;
|
2022-11-07 20:15:26 +00:00
|
|
|
float dy = 0.0f;
|
|
|
|
float standingHeight = 0.0f;
|
2022-11-23 15:40:10 +00:00
|
|
|
const float thrust = 25.0f;
|
2023-01-22 18:20:10 +00:00
|
|
|
|
2023-02-12 14:50:29 +00:00
|
|
|
glm::vec3 lastCollisionNormal{};
|
|
|
|
glm::vec3 lastCollisionPoint{};
|
|
|
|
bool justCollided = false;
|
2023-01-05 13:21:33 +00:00
|
|
|
};
|
|
|
|
|
2023-02-09 15:21:37 +00:00
|
|
|
class CameraControllerSystem : public engine::System, public engine::EventHandler<engine::PhysicsSystem::CollisionEvent> {
|
2023-01-05 13:21:33 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
CameraControllerSystem(engine::Scene* scene);
|
2022-11-07 20:15:26 +00:00
|
|
|
|
2023-02-09 15:21:37 +00:00
|
|
|
// engine::System overrides
|
2023-04-29 14:22:25 +00:00
|
|
|
void OnUpdate(float ts) override;
|
2023-02-09 15:21:37 +00:00
|
|
|
|
|
|
|
// engine::EventHandler overrides
|
2023-04-29 14:22:25 +00:00
|
|
|
void OnEvent(engine::PhysicsSystem::CollisionEvent info) override;
|
2023-02-09 20:44:37 +00:00
|
|
|
|
|
|
|
engine::TransformComponent* t = nullptr;
|
|
|
|
engine::ColliderComponent* col = nullptr;
|
|
|
|
CameraControllerComponent* c = nullptr;
|
2022-11-07 20:15:26 +00:00
|
|
|
};
|