#include "entities/player.hpp" #include "plate_system.hpp" #include "states/game_state.hpp" #include "levels/director.hpp" namespace Nimbin { void PlateSystem::update(double dt, const Player& player, const DynArray& plates) { const double px_min = player.pos.x - static_cast(player.radius); const double px_max = player.pos.x + static_cast(player.radius); const double py_min = player.pos.y - static_cast(player.height); [[maybe_unused]] const double py_max = player.pos.y; const double pz_min = player.pos.z - static_cast(player.radius); const double pz_max = player.pos.z + static_cast(player.radius); for (const Level::StepPlate& sp : plates) { Plate* plate = sp.plate; if (!plate) continue; plate->tick(dt); const Vec3 min = plate->aabb_Min(); const Vec3 max = plate->aabb_Max(); const bool xz_overlap = px_max >= min.x && px_min <= max.x && pz_max >= min.z && pz_min <= max.z; const bool y_close = py_min <= max.y + 0.2 && py_min >= min.y - 0.1; const bool was_active = plate->active; plate->active = xz_overlap && y_close; if (plate->active && !was_active) plate->pulse = 1.0; } } } // namespace Nimbin