- Skills shake nearby shelves, tables and garbage cans into paper + rock debris; props stay intact, destroyed bins stop shedding, and rock debris can originate from prop surfaces - Manual K always casts WARP (field drops ahead of the agent when no crowd is in range); autoplay still waits for a real target - Add opt-in --trace categories for silent skill decisions, debris bursts, input and consumed events, with zero cost when disabled - Add debris_surface_wiring and debug_trace_toggle regression tests
103 lines
4 KiB
C++
103 lines
4 KiB
C++
// Debris integration: skills shed paper + rock from shelves, tables and bins.
|
|
// The props must stay intact; only their surface positions feed the bursts.
|
|
#include <cstdio>
|
|
|
|
#include "game/floor.hpp"
|
|
#include "level/level_data.hpp"
|
|
#include "render/debris.hpp"
|
|
#include "render/dressing.hpp"
|
|
|
|
namespace {
|
|
|
|
bool failed = false;
|
|
|
|
void check(bool ok, const char* what) {
|
|
if (!ok) {
|
|
std::printf("FAIL: %s\n", what);
|
|
failed = true;
|
|
}
|
|
}
|
|
|
|
level::Prop decor(const char* model = "") {
|
|
level::Prop p;
|
|
p.kind = PropKind::Decor;
|
|
p.model = model;
|
|
return p;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
int main() {
|
|
// --- Classification: shelves, tables and garbage cans shed debris -----
|
|
{
|
|
level::Prop p;
|
|
p.kind = PropKind::Shelf;
|
|
check(level::is_debris_source(p), "Shelf is a debris source");
|
|
p.kind = PropKind::ArchiveShelf;
|
|
check(level::is_debris_source(p), "ArchiveShelf is a debris source");
|
|
p.kind = PropKind::MeetingTable;
|
|
check(level::is_debris_source(p), "MeetingTable is a debris source");
|
|
p.kind = PropKind::Desk;
|
|
check(level::is_debris_source(p), "Desk is a debris source");
|
|
p.kind = PropKind::Pillar;
|
|
check(!level::is_debris_source(p), "Pillar is not a debris source");
|
|
check(level::is_debris_source(decor("GarbageCan")),
|
|
"GarbageCan outfit is a debris source");
|
|
check(level::is_debris_source(decor("Cabinet")),
|
|
"Cabinet outfit is a debris source");
|
|
check(level::is_debris_source(decor("OfficeDesk")),
|
|
"OfficeDesk outfit is a debris source");
|
|
check(!level::is_debris_source(decor("LooseSheet")),
|
|
"LooseSheet is destroyed, not a surface source");
|
|
}
|
|
|
|
// --- Real floor data produces surface origins near furniture ----------
|
|
Floor floor;
|
|
Dressing dressing;
|
|
dressing.init(&floor);
|
|
|
|
Vector3 origins[24];
|
|
// Plaza bins sit ~34-39 m from the room centre; a skill cast there must
|
|
// still find them as surfaces.
|
|
const int plaza = dressing.surface_sources_in_radius(
|
|
{-22.5f, 13.5f}, 45.0f, origins, static_cast<int>(std::size(origins)));
|
|
check(plaza > 0, "plaza garbage cans are debris surfaces");
|
|
|
|
// A bin destroyed by a blast stops shedding: it is no longer in the scene.
|
|
const Vec2 bin{-58.5f, -1.5f};
|
|
int before = dressing.surface_sources_in_radius(bin, 2.0f, origins,
|
|
static_cast<int>(std::size(origins)));
|
|
check(before > 0, "bin is a surface before the blast");
|
|
dressing.destroy_in_radius(bin, 2.0f, nullptr, 0);
|
|
const int after = dressing.surface_sources_in_radius(
|
|
bin, 2.0f, origins, static_cast<int>(std::size(origins)));
|
|
check(after < before, "destroyed bin stops shedding debris");
|
|
|
|
const int gate = dressing.surface_sources_in_radius(
|
|
{12.0f, 70.0f}, 40.0f, origins, static_cast<int>(std::size(origins)));
|
|
check(gate > 0, "gate archive aisle has debris surfaces");
|
|
bool tall_surface = false;
|
|
for (int i = 0; i < gate; ++i) tall_surface |= origins[i].y > 1.5f;
|
|
check(tall_surface, "shelf surfaces sit above the floor");
|
|
|
|
// Props stay intact: shedding must not reduce the destructible dressing.
|
|
const int alive_before = dressing.alive_count();
|
|
dressing.surface_sources_in_radius({12.0f, 70.0f}, 40.0f, origins,
|
|
static_cast<int>(std::size(origins)));
|
|
check(dressing.alive_count() == alive_before,
|
|
"surface shedding does not destroy props");
|
|
|
|
// --- Both debris systems accept surface origins -----------------------
|
|
{
|
|
PaperDebris paper;
|
|
ConcreteDebris rocks;
|
|
paper.burst({12.0f, 70.0f}, 0.9f, 4.0f, origins, gate, 12);
|
|
rocks.burst({12.0f, 70.0f}, 4.0f, 12, origins, gate);
|
|
check(paper.count() > 0, "paper debris spawns from surface origins");
|
|
check(rocks.count() > 0, "rock debris spawns from surface origins");
|
|
}
|
|
|
|
if (failed) return 1;
|
|
std::printf("debris: OK\n");
|
|
return 0;
|
|
}
|