#ifndef COLLISIONCOMPONENT_H #define COLLISIONCOMPONENT_H #include "Game/Components/CollisionComponents/BoundingShape.h" #include #include #include "Game/TypeMap.h" #include "Graphics/modeltransform.h" #include "glm/glm.hpp" #include "Game/Components/Component.h" class CollisionComponent : public Component { public: template void addCollisionShape(std::shared_ptr &&component){ m_collision_shapes.put(std::forward>(component)); } template bool hasCollisionShape(){ return m_collision_shapes.contains(); } template T* getCollisionShape(){ auto comp = m_collision_shapes.find(); assert(comp != m_collision_shapes.end()); return static_cast(comp->second.get()); } CollisionComponent(std::string shapeType, std::shared_ptr mt, const glm::vec3 &initial_pos, std::vector &obj_data); CollisionComponent(std::string shapeType, std::shared_ptr mt, const glm::vec3 &initial_pos); CollisionComponent(std::string shapeType, const std::vector &obj_data, const std::shared_ptr &mt, bool isGround = false); bool isRigidBody(); float getReboundVel(); float getAcceleration(); private: TypeMap> m_collision_shapes; bool m_isRigid = true; float m_rebound_vel = 0.f; float m_acceleration = 0.f; }; #endif // COLLISIONCOMPONENT_H