- Removed the Threshold Key/hazard door/stairwell exit, anchors, events and HUD text - Added an aged 40%-larger Beacon GLB and a reproducible Blender generator - Added BeaconSystem: three walk-over beacons, grey->bright-red Hiss-wave activation - Added cheap plinth collision and a placeholder completion event/banner - Added a beacon QA flag, validation, tests and design notes
60 lines
1.9 KiB
C++
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;
|
|
}
|