#pragma once #include #include #include #include #include #include #include #include #include class PlayerInputComponent; class Player : public GameObject { std::vector& LevelSectors; Sector* CurrentSector; float Yaw = -90.0f; float MouseSensitivity = 0.1f; // movement variables float WalkSpeed = 5.0f; float RunSpeed = 15.0f; bool bIsRunning = false; float JumpForce = 5.0f; float JumpVelocity = 0.0f; bool bJumping = false; const float GRAVITY = 9.8f; // collision constants const float STEP_HEIGHT = 0.25f; const float PLAYER_HEIGHT = 2.0f; const float PLAYER_RADIUS = 1.0f; bool CrossingWall(glm::vec3 NewPosition); bool LineSegmentsIntersect(const glm::vec2& p1, const glm::vec2& p2, const glm::vec2& q1, const glm::vec2& q2); float PointToLineSegmentDistance(const glm::vec2& point, const glm::vec2& segA, const glm::vec2& segB); bool PointInPolygon(glm::vec2 point, std::vector polygon); bool CanFitInNextSector(Sector Sector); std::unique_ptr cPlayerInput; public: std::unique_ptr PlayerCamera; Player(glm::vec3 Position, glm::vec3 Rotation, std::vector& LevelSectors, GLFWwindow* Window); ~Player() = default; void Update(float DeltaTime); void Move(EInputDirection Direction, float Delta); void Jump(); void Sprint(); void StopSprint(); void Look(float XOffset, float YOffset, GLboolean bConstrainPitch = true); glm::mat4 GetViewMatrix() const; };