Skip to main content

std-collision

Level: Atom | Entity: CollidableBody | Persistence: runtime

2 states, 4 events, 5 transitions

Live Preview

orbital CollidableBodyOrbital {
entity CollidableBody [runtime] {
id : string
name : string
description : string
status : string
createdAt : string
x : number
y : number
collisionStatus : string
targetId : string
}
trait CollidableBodyCollision -> CollidableBody [interaction] {
initial: idle
state idle {
INIT -> idle
(render-ui main { type: "stack", direction: "vertical", gap: "lg", children: [{ type: "stack", direction: "horizontal", gap: "md", align: "center", justify: "space-between", children: [{ type: "stack", direction: "horizontal", gap: "md", align: "center", children: [{ type: "icon", name: "crosshair", size: "lg" }, { type: "typography", content: "CollidableBody Collision", variant: "h2" }] }, { type: "status-dot", status: "inactive", label: "Idle" }] }, { type: "divider" }, { type: "simple-grid", columns: 2, children: [{ type: "stat-display", label: "X", value: ["object/get", ["array/first", "@entity"], "x"] }, { type: "stat-display", label: "Y", value: ["object/get", ["array/first", "@entity"], "y"] }] }, { type: "stack", direction: "horizontal", gap: "sm", justify: "center", children: [{ type: "button", label: "Check", event: "CHECK", variant: "primary", icon: "scan" }] }] })
CHECK -> detecting
(set @entity.collisionStatus detecting)
(render-ui main { type: "stack", direction: "vertical", gap: "lg", children: [{ type: "stack", direction: "horizontal", gap: "md", align: "center", justify: "space-between", children: [{ type: "stack", direction: "horizontal", gap: "md", align: "center", children: [{ type: "icon", name: "crosshair", size: "lg" }, { type: "typography", content: "CollidableBody Collision", variant: "h2" }] }, { type: "status-dot", status: "warning", pulse: true, label: "Detecting" }] }, { type: "divider" }, { type: "alert", variant: "warning", message: "Collision detection in progress..." }, { type: "simple-grid", columns: 2, children: [{ type: "stat-display", label: "X", value: ["object/get", ["array/first", "@entity"], "x"] }, { type: "stat-display", label: "Y", value: ["object/get", ["array/first", "@entity"], "y"] }] }, { type: "typography", variant: "caption", color: "muted", content: ["object/get", ["array/first", "@entity"], "targetId"] }, { type: "stack", direction: "horizontal", gap: "sm", justify: "center", children: [{ type: "button", label: "Clear", event: "CLEAR", variant: "ghost", icon: "x" }] }] })
}
state detecting {
COLLISION_DETECTED -> detecting
(set @entity.targetId @payload.targetId)
(set @entity.collisionStatus detected)
(render-ui main { type: "stack", direction: "vertical", gap: "lg", children: [{ type: "stack", direction: "horizontal", gap: "md", align: "center", justify: "space-between", children: [{ type: "stack", direction: "horizontal", gap: "md", align: "center", children: [{ type: "icon", name: "crosshair", size: "lg" }, { type: "typography", content: "CollidableBody Collision", variant: "h2" }] }, { type: "status-dot", status: "warning", pulse: true, label: "Detecting" }] }, { type: "divider" }, { type: "alert", variant: "warning", message: "Collision detection in progress..." }, { type: "simple-grid", columns: 2, children: [{ type: "stat-display", label: "X", value: ["object/get", ["array/first", "@entity"], "x"] }, { type: "stat-display", label: "Y", value: ["object/get", ["array/first", "@entity"], "y"] }] }, { type: "typography", variant: "caption", color: "muted", content: ["object/get", ["array/first", "@entity"], "targetId"] }, { type: "stack", direction: "horizontal", gap: "sm", justify: "center", children: [{ type: "button", label: "Clear", event: "CLEAR", variant: "ghost", icon: "x" }] }] })
CLEAR -> idle
(set @entity.collisionStatus idle)
(set @entity.targetId "")
(render-ui main { type: "stack", direction: "vertical", gap: "lg", children: [{ type: "stack", direction: "horizontal", gap: "md", align: "center", justify: "space-between", children: [{ type: "stack", direction: "horizontal", gap: "md", align: "center", children: [{ type: "icon", name: "crosshair", size: "lg" }, { type: "typography", content: "CollidableBody Collision", variant: "h2" }] }, { type: "status-dot", status: "inactive", label: "Idle" }] }, { type: "divider" }, { type: "simple-grid", columns: 2, children: [{ type: "stat-display", label: "X", value: ["object/get", ["array/first", "@entity"], "x"] }, { type: "stat-display", label: "Y", value: ["object/get", ["array/first", "@entity"], "y"] }] }, { type: "stack", direction: "horizontal", gap: "sm", justify: "center", children: [{ type: "button", label: "Check", event: "CHECK", variant: "primary", icon: "scan" }] }] })
INIT -> detecting
(render-ui main { type: "stack", direction: "vertical", gap: "lg", children: [{ type: "stack", direction: "horizontal", gap: "md", align: "center", justify: "space-between", children: [{ type: "stack", direction: "horizontal", gap: "md", align: "center", children: [{ type: "icon", name: "crosshair", size: "lg" }, { type: "typography", content: "CollidableBody Collision", variant: "h2" }] }, { type: "status-dot", status: "warning", pulse: true, label: "Detecting" }] }, { type: "divider" }, { type: "alert", variant: "warning", message: "Collision detection in progress..." }, { type: "simple-grid", columns: 2, children: [{ type: "stat-display", label: "X", value: ["object/get", ["array/first", "@entity"], "x"] }, { type: "stat-display", label: "Y", value: ["object/get", ["array/first", "@entity"], "y"] }] }, { type: "typography", variant: "caption", color: "muted", content: ["object/get", ["array/first", "@entity"], "targetId"] }, { type: "stack", direction: "horizontal", gap: "sm", justify: "center", children: [{ type: "button", label: "Clear", event: "CLEAR", variant: "ghost", icon: "x" }] }] })
}
}
page "/collidablebodys/collision" -> CollidableBodyCollision
}
Loading preview...

Orbital Visualization

Loading visualization...

Entity Fields

FieldTypeDefault
idstring-
namestring-
descriptionstring-
statusstring"active"
createdAtstring-
xnumber0
ynumber0
collisionStatusstring"idle"
targetIdstring""

States

StateType
idleInitial
detecting-

Events

EventPayload
INIT-
CHECK-
COLLISION_DETECTEDtargetId: string
CLEAR-

Transitions

FromEventToEffects
idleINITidle1 effect
idleCHECKdetecting2 effects
detectingCOLLISION_DETECTEDdetecting3 effects
detectingCLEARidle3 effects
detectingINITdetecting1 effect