cntrl/tests/beacon_test.cpp
dandovlatov 27bf6e511f Replace Threshold exit flow with walk-to-activate Beacons
- Remove Threshold Key/hazard door/stairwell exit, anchors, events and HUD text
- Add aged 40%-larger Beacon GLB and reproducible Blender generator
- Add BeaconSystem: three walk-over beacons, grey->bright-red Hiss-wave activation
- Add cheap plinth collision and a placeholder completion event/banner
- Add beacon QA flag, validation, tests and design notes
2026-11-25 02:46:19 +04:00

60 lines
1.9 KiB
C++

#include "game/beacon.hpp"
#include "game/floor.hpp"
#include <cstdio>
namespace {
int failures = 0;
void check(bool ok, const char* what) {
if (!ok) {
std::printf("FAIL: %s\n", what);
++failures;
}
}
int count_events(const EventQueue& events, EventType type) {
int n = 0;
for (int i = 0; i < events.count; ++i) {
if (events.items[i].type == type) ++n;
}
return n;
}
} // namespace
int main() {
Floor floor;
BeaconSystem beacons;
beacons.init(floor);
check(beacons.count() == 3, "three beacons authored in the level");
check(floor.beacon_colliders().size() == 3, "three beacon collision boxes");
const Vec2 first = beacons.beacons().front().pos;
check(floor.blocked(first, 0.45f), "beacon plinth blocks the player");
check(distance(floor.resolve(first, 0.45f), first) > 1.0f,
"resolve pushes the player out of the beacon");
check(!floor.blocked(first + Vec2{4.0f, 0.0f}, 0.45f),
"floor beside the beacon stays walkable");
EventQueue events;
for (const auto& b : beacons.beacons()) beacons.update(b.pos, events);
check(beacons.active_count() == 3, "walking over each beacon activates it");
check(beacons.complete(), "third beacon completes the set");
check(count_events(events, EventType::BeaconActivated) == 3,
"one activation event per beacon");
check(count_events(events, EventType::BeaconsComplete) == 1,
"one completion event when all beacons are active");
beacons.update(beacons.beacons().front().pos, events);
check(count_events(events, EventType::BeaconsComplete) == 1,
"completion event does not repeat");
beacons.reset();
check(beacons.active_count() == 0 && !beacons.complete(),
"reset clears beacon progress");
if (failures == 0) std::printf("beacon tests passed\n");
else std::printf("%d failures\n", failures);
return failures == 0 ? 0 : 1;
}