Structural integrity
The module PulseBuildIntegrity gives pieces a stability between 0 and 1. Pieces on the ground are fully stable; every piece resting on another or hanging on its side loses some. Pieces without enough stability cannot be placed, and pieces that lose their support collapse.
Setup
- Add the Integrity trait to the pieces that take part:
| Property | Meaning |
|---|---|
Profile | VerticalLoss (resting on a piece, default 0.1), HorizontalLoss (held only from the side, default 0.25) for tier 0 |
TierProfiles | Losses of higher tiers (entry 0 = tier 1); stone and metal hold more |
bGroundSupport | Touching the ground gives full stability (foundations, pillars) |
bSupportsOthers | Other pieces can rest on this one or hang on it |
- Add the Integrity rule (to the pieces or the settings’ default rules):
MinStabilityis the least stability a new piece must get;bTintPreviewcolors the preview by the stability it would get.
How it is computed
Pieces with the trait form a graph: two pieces are linked when their boxes touch (ConnectTolerance) and overlap on two axes. The link is below (resting on), above or side by height. Grounded pieces start at 1; every other piece gets the best support of its neighbours minus the vertical or horizontal loss. A piece touches the ground when the world is at most GroundTraceDistance below it (keep it below the height of foundations).
UPulseBuildIntegritySubsystem runs on every machine, so the preview and GetStability work on clients. Changes mark their structure, and the next frame solves only the connected structures around them (up to MaxStructureSize pieces).
Collapse
On the authority, pieces at or below CollapseThreshold (default 0) collapse through DestroyPiece (so they count as destroyed, with message and refund rules), together with everything that loses its support with them. With bSpawnDebris they fall as replicated physics debris (APulseBuildDebris, at most MaxDebrisPerCollapse per collapse). bCollapse off keeps the stability for previews but never collapses. OnPiecesCollapsed and the message Pulse.Message.Build.Collapsed (FPulseBuildCollapseMessage) report a collapse.
Games without ground collision (or specs) can bind IsGroundedOverride.
The ground test of a piece is cached until the piece changes. When the ground itself changes (digging, filling), call Notify Ground Changed with the box that changed, once its new collision is there: the pieces whose ground test reaches into it look again on the next frame, and what lost its ground collapses on the authority. PulseWorldBuildBridge calls it for the terrain operations of Pulse World.
Debugging
Pulse.Build.Integrity.Debug 1draws the stability of pieces near the player.PulseBuildStabilityprints the stability of the piece under the crosshair.PulseBuildIntegrityRecomputesolves every structure again (RecomputeAll).