15 explicit CollisionSystem(
const std::shared_ptr<eng::IRenderer> &renderer,
bool &showDebug)
27 void setEnable(
bool enable)
override { (void)enable; }
31 std::optional<float> ceilingBottomY;
32 std::optional<float> floorTopY;
36 const auto entity = pair.first;
40 if ((t ==
nullptr) || (scroll ==
nullptr))
44 const float scaledHeight = (s ? s->
y : 1.0f) * scroll->original_height;
45 ceilingBottomY = t->y + scaledHeight;
51 const auto entity = pair.first;
61 if (ceilingBottomY.has_value() || floorTopY.has_value())
66 const auto playerEntity = pair.first;
75 float hitboxY = t->
y + hb->offsetY;
77 if (ceilingBottomY.has_value() && (hitboxY - hb->radius < ceilingBottomY.value()))
79 t->
y = ceilingBottomY.value() + hb->radius - hb->offsetY;
82 vel->y = std::max(0.0f, vel->y);
86 if (floorTopY.has_value() && (hitboxY + hb->radius > floorTopY.value()))
88 t->y = floorTopY.value() - hb->radius - hb->offsetY;
91 vel->y = std::min(0.0f, vel->y);
This file contains the component definitions.
This file contains the IRenderer class declaration.
This file contains the interface for systems.
This file contains the Registry class declaration.
Abstract class for system.
Class for managing entities and their components.
std::unordered_map< Entity, T > & getAll()
T * getComponent(Entity e)
Server-authoritative collision detection and response system.
CollisionSystem(CollisionSystem &&)=delete
void update(ecs::Registry ®istry, float dt) override
~CollisionSystem() override=default
CollisionSystem(const std::shared_ptr< eng::IRenderer > &renderer, bool &showDebug)
const std::shared_ptr< eng::IRenderer > & m_renderer
void setEnable(bool enable) override
CollisionSystem & operator=(const CollisionSystem &)=delete
CollisionSystem & operator=(const CollisionSystem &&)=delete
CollisionSystem(const CollisionSystem &)=delete