import type { PhysicsWorld } from "./physicsWorld.js"; export interface StructureMaterial { id: string; /** Node integrity and edge strength default to this — brittle glass vs load-bearing concrete. */ strength: number; /** Debris body mass when a node of this material collapses. Default 1. */ mass?: number; } export type StructureMaterialTable = Readonly>; export interface StructureNodeSpec { id: string; /** Body centre in world coordinates — also where its debris spawns. */ position: readonly [number, number, number]; halfExtents: readonly [number, number, number]; /** Overrides material mass for the collapsed debris body. */ mass?: number; /** Hit points before the piece shatters. Default from `material.strength`, else 100. */ integrity?: number; material?: string; /** Foundation piece — reachability to any anchor is what keeps the rest standing. */ anchor?: boolean; } export interface StructureEdgeSpec { a: string; b: string; /** Accumulated edge damage past this severs the connection. Default from `material.strength`, else 100. */ strength?: number; } export interface CollapseEvent { /** * Node ids that left the structure this operation — the shattered node plus every piece the loss * disconnected from an anchor. This is the replicated collapse: broadcast the id list, not each * fragment's physics (games re-derive the debris locally). */ fell: readonly string[]; collapsed: boolean; } export interface DebrisConfig { /** Outward kick magnitude applied to each debris body from `origin`. Default 3. */ impulse?: number; /** Blast origin the kick radiates from. Defaults to each node's own position (straight drop). */ origin?: readonly [number, number, number]; } /** * A structural-integrity graph over a building — nodes are pieces (walls, beams, floors), edges are * load-bearing connections, some nodes are anchored foundations. `damage`/`damageEdge` wear pieces and * connections down; when a piece shatters or an edge severs, the graph recomputes which pieces still * reach an anchor and hands back every newly-disconnected piece as one `CollapseEvent`. Feed that to * `toDebris` to sink the fallen pieces into a `PhysicsWorld` as rigid bodies ("The Finals" smooth * destruction, Rainbow Six walls). Coarse by design: it replicates the collapse event, not per fragment. */ export declare class StructureGraph { private readonly nodes; private readonly integrity; private readonly adj; private readonly edgeStrength; private readonly edgeDamage; private readonly fallenSpecs; private readonly materials; constructor(config: { nodes: readonly StructureNodeSpec[]; edges: readonly StructureEdgeSpec[]; materials?: StructureMaterialTable; }); private materialStrength; has(id: string): boolean; integrityOf(id: string): number; nodeSpec(id: string): StructureNodeSpec | undefined; neighbors(id: string): string[]; standing(): string[]; isSupported(id: string): boolean; private supportedSet; private removeNode; private settle; /** Wear a piece down; at ≤0 integrity it shatters and the loss cascades through unsupported pieces. */ damage(id: string, amount: number): CollapseEvent; /** Wear a connection down; past its strength it severs and unsupported pieces cascade off. */ damageEdge(a: string, b: string, amount: number): CollapseEvent; /** Cut a connection outright (a beam sheared by a blast), then cascade. */ severEdge(a: string, b: string): CollapseEvent; /** Spawn one rigid debris body per fallen piece into `world`; returns the new body indices. */ toDebris(world: PhysicsWorld, event: CollapseEvent, config?: DebrisConfig): number[]; }