47 std::optional<float> ceilingBottomY;
48 std::optional<float> floorTopY;
54 if ((t ==
nullptr) || (scroll ==
nullptr))
58 const float scaledHeight = (s ? s->
y : 1.0f) * scroll->original_height;
59 ceilingBottomY = t->y + scaledHeight;
73 std::vector<ecs::Entity> projectilesToRemove;
74 std::vector<ecs::Entity> enemiesToRemove;
80 if ((projectileTransform ==
nullptr) || (projectileHitbox ==
nullptr))
89 if ((enemyTransform ==
nullptr) || (enemyHitbox ==
nullptr))
97 enemy.health -= projectile.damage;
100 projectile.pierce_remaining -= 1;
104 projectilesToRemove.push_back(projectileEntity);
107 if (enemy.health <= 0.0f)
110 enemiesToRemove.push_back(enemyEntity);
123 for (
const ecs::Entity entity : projectilesToRemove)
131 if (ceilingBottomY.has_value() || floorTopY.has_value())
133 for (
const auto &playerEntity : registry.
getAll<
ecs::Player>() | std::views::keys)
138 if ((t ==
nullptr) || (hb ==
nullptr))
142 const float hitboxY = t->
y + hb->offsetY;
143 if (ceilingBottomY.has_value() && (hitboxY - hb->radius < ceilingBottomY.value()))
145 t->
y = ceilingBottomY.value() + hb->radius - hb->offsetY;
148 vel->y = std::max(0.0f, vel->y);
151 if (floorTopY.has_value() && (hitboxY + hb->radius > floorTopY.value()))
153 t->y = floorTopY.value() - hb->radius - hb->offsetY;
156 vel->y = std::min(0.0f, vel->y);
160 for (
const auto &enemyEntity : registry.
getAll<
ecs::Enemy>() | std::views::keys)
165 if ((t ==
nullptr) || (hb ==
nullptr))
169 const float hitboxY = t->
y + hb->offsetY;
170 if (ceilingBottomY.has_value() && (hitboxY - hb->radius < ceilingBottomY.value()))
172 t->
y = ceilingBottomY.value() + hb->radius - hb->offsetY;
175 vel->y = std::max(0.0f, vel->y);
178 if (floorTopY.has_value() && (hitboxY + hb->radius > floorTopY.value()))
180 t->y = floorTopY.value() - hb->radius - hb->offsetY;
183 vel->y = std::min(0.0f, vel->y);
constexpr auto TEXTURE_EXPLOSION