breakaway
The breakawayKit front door: `require("breakawayKit.breakaway")`. Attach durability to any rig (a tumbleTroupe character, a ragdoll root, a table of entities), listen to the engine's impact events, wear parts down past their thresholds, break them off as free physics bodies with…
breakaway
The breakawayKit front door: require("breakawayKit.breakaway"). Attach durability to any rig (a tumbleTroupe character, a ragdoll root, a table of entities), listen to the engine's impact events, wear parts down past their thresholds, break them off as free physics bodies with their style's fx, score breaks, report integrity, repair, apply game modifiers, and replicate breaks and durability to every peer (the owner decides; others only watch). The package README documents every call.
Interface
What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.
conforms to
zero/source-extract/v2strict
vec(p: any) → V
| arg | type | description |
|---|---|---|
| p | any |
add(a: V, b: V) → V return
| arg | type | description |
|---|---|---|
| a | V | |
| b | V |
sub(a: V, b: V) → V return
| arg | type | description |
|---|---|---|
| a | V | |
| b | V |
mul(a: V, s: number) → V return
| arg | type | description |
|---|---|---|
| a | V | |
| s | number |
len(a: V) → number return math
| arg | type | description |
|---|---|---|
| a | V |
norm(a: V) → V
| arg | type | description |
|---|---|---|
| a | V |
q4(r: any) → void
| arg | type | description |
|---|---|---|
| r | any |
qconj(q: { number }) → void
| arg | type | description |
|---|---|---|
| q | { number } |
qmul(a: { number }, b: { number }) → void
| arg | type | description |
|---|---|---|
| a | { number } | |
| b | { number } |
qrot(q: { number }, v: V) → V
| arg | type | description |
|---|---|---|
| q | { number } | |
| v | V |
qrand(rng: any) → void
| arg | type | description |
|---|---|---|
| rng | any |
rngFor(seed: number) → void
| arg | type | description |
|---|---|---|
| seed | number |
myPeer( ) → number
send(ch: string, ...: any) → void
| arg | type | description |
|---|---|---|
| ch | string | |
| ... | any |
emit(kind: string, rig: any, ev: any) → void
| arg | type | description |
|---|---|---|
| kind | string | |
| rig | any | |
| ev | any |
registerAdapter(adapter: any) → void
Register an adapter: `{ name, matches(target) -> boolean, describe(target, opts) -> desc, remote? }`. The tumbleTroupe and generic adapters register on their own.
| arg | type | description |
|---|---|---|
| adapter | any |
pickAdapter(target: any, opts: any) → any
| arg | type | description |
|---|---|---|
| target | any | |
| opts | any |
styleFor(desc: any, opts: any, rigDefault: string?) → string
| arg | type | description |
|---|---|---|
| desc | any | |
| opts | any | |
| rigDefault | string? |
buildPart(rig: any, desc: any, opts: any) → any
| arg | type | description |
|---|---|---|
| rig | any | |
| desc | any | |
| opts | any |
recomputeMax(rig: any) → void
| arg | type | description |
|---|---|---|
| rig | any |
rigOf(r: any) → any
| arg | type | description |
|---|---|---|
| r | any |
integrity(r: any) → number
0..1 of what is left of a rig (weighted by part; broken parts count 0). Also works on other peers' rigs this peer mirrors.
| arg | type | description |
|---|---|---|
| r | any |
parts(r: any) → void
The live state of every part: `{ [name] = { name, label, class, hp, max, fraction, broken, style, threshold, points, band } }`.
| arg | type | description |
|---|---|---|
| r | any |
partOrder(r: any) → void
The part names of a rig in display order (head first, accessories last).
| arg | type | description |
|---|---|---|
| r | any |
score(r: any) → number
Points scored on a rig so far (every break, already multiplied by breakPointsMul).
| arg | type | description |
|---|---|---|
| r | any |
summary(r: any) → any
A summary: `{ integrity, score, broken = n, parts = n, wrecked, owner, key, local }`.
| arg | type | description |
|---|---|---|
| r | any |
rigs(filter: any?) → void
Every rig this peer knows: its own (`local = true`) and the ones it mirrors from other peers.
| arg | type | description |
|---|---|---|
| filter | any? |
on(kind: string, a: any, b: any?) → void
| arg | type | description |
|---|---|---|
| kind | string | |
| a | any | |
| b | any? |
onDamage(a: any, b: any?) → void
`onDamage(fn)` or `onDamage(rig, fn)`: every hit that wore a part down: `{ rig, part, amount, hp, max, fraction, strength, point, source }`. Returns the unsubscribe function.
| arg | type | description |
|---|---|---|
| a | any | |
| b | any? |
onBreak(a: any, b: any?) → void
`onBreak(fn)` or `onBreak(rig, fn)`: a part broke off: `{ rig, part, style, points, score, point, velocity, carried, integrity, hitstop, remote }`.
| arg | type | description |
|---|---|---|
| a | any | |
| b | any? |
onWrecked(a: any, b: any?) → void
`onWrecked(fn)` or `onWrecked(rig, fn)`: the rig is done for (core part broke or integrity fell to TUNING.wreckIntegrity): `{ rig, integrity, score, broken, reason }`.
| arg | type | description |
|---|---|---|
| a | any | |
| b | any? |
onRepair(a: any, b: any?) → void
`onRepair(fn)` or `onRepair(rig, fn)`: a part (or the whole rig) was repaired.
| arg | type | description |
|---|---|---|
| a | any | |
| b | any? |
markDirty(rig: any) → void
| arg | type | description |
|---|---|---|
| rig | any |
encodeState(rig: any) → void
| arg | type | description |
|---|---|---|
| rig | any |
partBodies(p: any) → void
| arg | type | description |
|---|---|---|
| p | any |
gatherVisuals(p: any) → void
every drawn mesh of a part as { model, material, worldPos, worldRot, scale, entity }
| arg | type | description |
|---|---|---|
| p | any |
setDrawnVisible(p: any, on: boolean) → void
| arg | type | description |
|---|---|---|
| p | any | |
| on | boolean |
ghostBodies(rig: any, p: any, on: boolean) → void
| arg | type | description |
|---|---|---|
| rig | any | |
| p | any | |
| on | boolean |
pieceShape(p: any, centre: V, rot: { number }, visuals: { any }) → any
the shape of the flying piece: around the part's colliders, else its adapter's hint, else a small box
| arg | type | description |
|---|---|---|
| p | any | |
| centre | V | |
| rot | { number } | |
| visuals | { any } |
spawnPieces(rig: any, p: any, visuals: { any }, info: any) → void
build the flying pieces for a part from its visuals (on any peer)
| arg | type | description |
|---|---|---|
| rig | any | |
| p | any | |
| visuals | { any } | |
| info | any |
partVelocity(p: any) → V
| arg | type | description |
|---|---|---|
| p | any |
rigCentre(rig: any) → V
| arg | type | description |
|---|---|---|
| rig | any |
partPose(p: any) → void
the pose a part leaves from: its main body, else its anchor entity, else its first drawn entity
| arg | type | description |
|---|---|---|
| p | any |
carriedWith(rig: any, p: any, out: { any }) → void
every part that leaves with `p` (its unbroken descendants)
| arg | type | description |
|---|---|---|
| rig | any | |
| p | any | |
| out | { any } |
doBreak(rig: any, p: any, info: any) → void
| arg | type | description |
|---|---|---|
| rig | any | |
| p | any | |
| info | any |
checkWrecked(rig: any, reason: string?) → void
| arg | type | description |
|---|---|---|
| rig | any | |
| reason | string? |
ownerCheck(rig: any, what: string) → boolean
| arg | type | description |
|---|---|---|
| rig | any | |
| what | string |
damage(r: any, partName: string, amount: number, info: any?) → number
Take `amount` durability off a part (no threshold: this IS the damage). `info`: { point, normal, strength, source }. Breaks the part when it runs out. Returns the damage taken. Only the rig's owner may call it.
| arg | type | description |
|---|---|---|
| r | any | |
| partName | string | |
| amount | number | |
| info | any? |
hit(r: any, partName: string, strength: number, info: any?) → number
A hit of `strength` (m/s of velocity change by default) on a part: nothing below the part's threshold, damage past it. Returns the damage taken. This is what the impact listeners call; call it yourself for hits that are not physics contacts (a hammer swing, an explosion).
| arg | type | description |
|---|---|---|
| r | any | |
| partName | string | |
| strength | number | |
| info | any? |
contact(r: any, partName: string, impulse: number, speed: number, info: any?) → number
Read a physics contact on a part (`impulse` N·s, `speed` m/s closing speed) and apply it as a hit; debounced per part by TUNING.hitCooldown. Adapters call this.
| arg | type | description |
|---|---|---|
| r | any | |
| partName | string | |
| impulse | number | |
| speed | number | |
| info | any? |
breakPart(r: any, partName: string, info: any?) → boolean
Break a part off now, whatever its durability (scripted breaks, a "pop the hat" button). Only the owner.
| arg | type | description |
|---|---|---|
| r | any | |
| partName | string | |
| info | any? |
restorePart(rig: any, p: any) → void
| arg | type | description |
|---|---|---|
| rig | any | |
| p | any |
repair(r: any, partName: string?, amount: number?) → void
Repair one part (`partName`) or every part (nil) by `amount` durability (nil: fully). A broken part comes back (its drawn parts show again and its bodies collide again). Clears `wrecked` once integrity is back above the wreck line. Only the owner.
| arg | type | description |
|---|---|---|
| r | any | |
| partName | string? | |
| amount | number? |
setModifiers(r: any, mods: any) → void
Game-set multipliers for a rig (upgrades, difficulty): `{ durabilityMul, thresholdMul, breakPointsMul, damageMul }`. Each part's max durability and threshold follow at once (its fraction is kept); points for later breaks use the new breakPointsMul.
| arg | type | description |
|---|---|---|
| r | any | |
| mods | any |
getModifiers(r: any) → any
The multipliers a rig runs with.
| arg | type | description |
|---|---|---|
| r | any |
setStyle(r: any, partName: string?, style: string) → void
Change a part's break style live (or every part's with partName = nil).
| arg | type | description |
|---|---|---|
| r | any | |
| partName | string? | |
| style | string |
setEnabled(r: any, on: boolean) → void
Stop listening for hits on a rig (true) or start again (false/nil) without detaching it.
| arg | type | description |
|---|---|---|
| r | any | |
| on | boolean |
orderParts(rig: any) → void
| arg | type | description |
|---|---|---|
| rig | any |
attach(target: any, opts: any?) → any
Attach durability to a rig and return it. `target`: a tumbleTroupe handle, a root entity (every descendant body becomes a part), or `{ [partName] = entityId | { entity, class, style, material, ... } }`. `opts`: profile, style, styles = { [part or class] = style }, materials = { [material] = style }, parts = { [part] = { max, threshold, damage, style, points, core, breakable, parent, label } }, points (number or table by part/class), mode ("spawn" | "joint"), modifiers = { durabilityMul, thresholdMul, breakPointsMul }, synced (default true), hits (default true: listen to impacts), display (default true), name, debrisLife, wreckIntegrity, measure.
| arg | type | description |
|---|---|---|
| target | any | |
| opts | any? |
detach(r: any) → void
Stop tracking a rig: its listeners go, its pieces fade, other peers drop their mirror. The rig's own entities are left as they are.
| arg | type | description |
|---|---|---|
| r | any |
detachAll( ) → void
Detach every rig this peer owns (and forget mirrored ones).
refresh(r: any) → void
Re-read a rig's drawn parts and bodies from its adapter (call after changing a character's outfit, e.g. tumbleTroupe's setStyle); broken parts stay hidden. Mirrors refresh on their own.
| arg | type | description |
|---|---|---|
| r | any |
styles( ) → void
Every break style name.
profiles( ) → void
Every toughness profile name.
defineStyle(name: string, spec: any) → void
Add or replace a break style (fields as in styles.module; missing ones from `base`).
| arg | type | description |
|---|---|---|
| name | string | |
| spec | any |
defineProfile(name: string, spec: any) → void
Add or replace a toughness profile: `{ description, classes = { head = { hp, threshold, damage }, ... } }`.
| arg | type | description |
|---|---|---|
| name | string | |
| spec | any |
configure(opts: any?) → any
Route the owner's break feel to your own camera: `{ shake = true | false | function(strength, point, style, info), hitstop = true | false | function(seconds, point, style) }`. true = juiceKit plays it (default), false = nothing, a function = the kit calls it instead (strength 0..1, info = { preset, hitstop }). The burst and sound always play. Only the keys given change; returns the current settings.
| arg | type | description |
|---|---|---|
| opts | any? |
setDisplay(kind: string?, look: string?) → void
Show the durability HUD as `kind` ("paperDoll" | "bars" | "chips" | "rings" | "line" | "hearts") in `look` ("cartoon" | "pixel" | "sciFi" | "fantasy"); either may be nil to keep the current one. One call swaps the whole HUD.
| arg | type | description |
|---|---|---|
| kind | string? | |
| look | string? |
display( ) → any
The display module (show, setTarget, configure, KINDS, LOOKS, THEMES).
_setDisplay(d: any) → void
Plug in a display (the display module does this itself): `{ changed(rig, kind, ev) }`.
| arg | type | description |
|---|---|---|
| d | any |
mirrorFor(from: number, key: string, meta: any?) → any
| arg | type | description |
|---|---|---|
| from | number | |
| key | string | |
| meta | any? |
applyState(rig: any, state: any) → void
| arg | type | description |
|---|---|---|
| rig | any | |
| state | any |
listenNet(ch: string, fn: (number, ...any) → void
| arg | type | description |
|---|---|---|
| ch | string | |
| fn | (number, ...any |
_listen( ) → void
Sub-parts
Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.
Showing up to 3 levels deep. Open a part to see what it holds further down.
Problems
Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.
agent_score is exposed.+ quality × 0.35
+ performance × 0.25
± compat factor
Usability ratings
Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".
Scoped to this part · feeds back into the world's score.