@zylem/behaviors 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -0
- package/dist/behavior-system-DYbx-x_-.d.ts +307 -0
- package/dist/chunk-2C3Z5GE7.js +176 -0
- package/dist/chunk-2C3Z5GE7.js.map +1 -0
- package/dist/chunk-2CLT36VB.js +241 -0
- package/dist/chunk-2CLT36VB.js.map +1 -0
- package/dist/chunk-3PYGRHAL.js +35 -0
- package/dist/chunk-3PYGRHAL.js.map +1 -0
- package/dist/chunk-4I6E6DGV.js +212 -0
- package/dist/chunk-4I6E6DGV.js.map +1 -0
- package/dist/chunk-4URF65BR.js +44 -0
- package/dist/chunk-4URF65BR.js.map +1 -0
- package/dist/chunk-6C6NXNEW.js +38 -0
- package/dist/chunk-6C6NXNEW.js.map +1 -0
- package/dist/chunk-ARJWUNRE.js +431 -0
- package/dist/chunk-ARJWUNRE.js.map +1 -0
- package/dist/chunk-BXP4K7RF.js +1205 -0
- package/dist/chunk-BXP4K7RF.js.map +1 -0
- package/dist/chunk-DYLH6K7B.js +44 -0
- package/dist/chunk-DYLH6K7B.js.map +1 -0
- package/dist/chunk-EIWQM6U3.js +27 -0
- package/dist/chunk-EIWQM6U3.js.map +1 -0
- package/dist/chunk-EZNCCO4L.js +14 -0
- package/dist/chunk-EZNCCO4L.js.map +1 -0
- package/dist/chunk-F3KRX2V4.js +457 -0
- package/dist/chunk-F3KRX2V4.js.map +1 -0
- package/dist/chunk-FPTWVCPN.js +53 -0
- package/dist/chunk-FPTWVCPN.js.map +1 -0
- package/dist/chunk-GCNRXAKH.js +37 -0
- package/dist/chunk-GCNRXAKH.js.map +1 -0
- package/dist/chunk-GYURWCIQ.js +1985 -0
- package/dist/chunk-GYURWCIQ.js.map +1 -0
- package/dist/chunk-HZMY3TT4.js +244 -0
- package/dist/chunk-HZMY3TT4.js.map +1 -0
- package/dist/chunk-ID5QJYF5.js +50 -0
- package/dist/chunk-ID5QJYF5.js.map +1 -0
- package/dist/chunk-JAN34G6S.js +552 -0
- package/dist/chunk-JAN34G6S.js.map +1 -0
- package/dist/chunk-K3UNLQ7W.js +118 -0
- package/dist/chunk-K3UNLQ7W.js.map +1 -0
- package/dist/chunk-KDY5N6J4.js +82 -0
- package/dist/chunk-KDY5N6J4.js.map +1 -0
- package/dist/chunk-KOZUNIIE.js +413 -0
- package/dist/chunk-KOZUNIIE.js.map +1 -0
- package/dist/chunk-KS72RZHX.js +30 -0
- package/dist/chunk-KS72RZHX.js.map +1 -0
- package/dist/chunk-LD5SMIB3.js +32 -0
- package/dist/chunk-LD5SMIB3.js.map +1 -0
- package/dist/chunk-OHCPV2NT.js +86 -0
- package/dist/chunk-OHCPV2NT.js.map +1 -0
- package/dist/chunk-OYWFPIHF.js +115 -0
- package/dist/chunk-OYWFPIHF.js.map +1 -0
- package/dist/chunk-POZER3MQ.js +407 -0
- package/dist/chunk-POZER3MQ.js.map +1 -0
- package/dist/chunk-RTRVBEIB.js +56 -0
- package/dist/chunk-RTRVBEIB.js.map +1 -0
- package/dist/chunk-RTVRUNYR.js +29 -0
- package/dist/chunk-RTVRUNYR.js.map +1 -0
- package/dist/chunk-SS7ELMJ7.js +406 -0
- package/dist/chunk-SS7ELMJ7.js.map +1 -0
- package/dist/chunk-STCCNLPC.js +160 -0
- package/dist/chunk-STCCNLPC.js.map +1 -0
- package/dist/chunk-SVLNF434.js +261 -0
- package/dist/chunk-SVLNF434.js.map +1 -0
- package/dist/chunk-UYFOLI2X.js +24 -0
- package/dist/chunk-UYFOLI2X.js.map +1 -0
- package/dist/chunk-VAN4WW3F.js +67 -0
- package/dist/chunk-VAN4WW3F.js.map +1 -0
- package/dist/chunk-WOMHL23C.js +369 -0
- package/dist/chunk-WOMHL23C.js.map +1 -0
- package/dist/chunk-WWVD5DR5.js +120 -0
- package/dist/chunk-WWVD5DR5.js.map +1 -0
- package/dist/chunk-XG2YMCJW.js +201 -0
- package/dist/chunk-XG2YMCJW.js.map +1 -0
- package/dist/chunk-XIJNE67Y.js +210 -0
- package/dist/chunk-XIJNE67Y.js.map +1 -0
- package/dist/chunk-Y6UJOUE5.js +44 -0
- package/dist/chunk-Y6UJOUE5.js.map +1 -0
- package/dist/chunk-YUO6SKJD.js +348 -0
- package/dist/chunk-YUO6SKJD.js.map +1 -0
- package/dist/components--hjBMTnz.d.ts +120 -0
- package/dist/components-B29WHGQN.d.ts +39 -0
- package/dist/components-BWG1GkZA.d.ts +20 -0
- package/dist/components-XCpL6IYt.d.ts +18 -0
- package/dist/components-qWwOsvwh.d.ts +43 -0
- package/dist/cooldown.d.ts +116 -0
- package/dist/cooldown.js +20 -0
- package/dist/cooldown.js.map +1 -0
- package/dist/coordinators/boundary-ricochet-3d.d.ts +19 -0
- package/dist/coordinators/boundary-ricochet-3d.js +8 -0
- package/dist/coordinators/boundary-ricochet-3d.js.map +1 -0
- package/dist/coordinators/boundary-ricochet.d.ts +34 -0
- package/dist/coordinators/boundary-ricochet.js +8 -0
- package/dist/coordinators/boundary-ricochet.js.map +1 -0
- package/dist/coordinators/first-person-shooter.d.ts +35 -0
- package/dist/coordinators/first-person-shooter.js +9 -0
- package/dist/coordinators/first-person-shooter.js.map +1 -0
- package/dist/coordinators/multidirectional-space-shooter.d.ts +27 -0
- package/dist/coordinators/multidirectional-space-shooter.js +10 -0
- package/dist/coordinators/multidirectional-space-shooter.js.map +1 -0
- package/dist/coordinators/top-down-shooter.d.ts +27 -0
- package/dist/coordinators/top-down-shooter.js +10 -0
- package/dist/coordinators/top-down-shooter.js.map +1 -0
- package/dist/core.d.ts +25 -0
- package/dist/core.js +327 -0
- package/dist/core.js.map +1 -0
- package/dist/destructible-3d.d.ts +42 -0
- package/dist/destructible-3d.js +13 -0
- package/dist/destructible-3d.js.map +1 -0
- package/dist/destructible-prebake.d.ts +28 -0
- package/dist/destructible-prebake.js +23 -0
- package/dist/destructible-prebake.js.map +1 -0
- package/dist/entity-types-CmtQ-IBp.d.ts +15 -0
- package/dist/first-person-perspective-C9Mptl0-.d.ts +23 -0
- package/dist/first-person.d.ts +204 -0
- package/dist/first-person.js +27 -0
- package/dist/first-person.js.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +263 -0
- package/dist/index.js.map +1 -0
- package/dist/jumper-2d.d.ts +113 -0
- package/dist/jumper-2d.js +27 -0
- package/dist/jumper-2d.js.map +1 -0
- package/dist/jumper-3d.d.ts +164 -0
- package/dist/jumper-3d.js +29 -0
- package/dist/jumper-3d.js.map +1 -0
- package/dist/moveable-BCRpjAQb.d.ts +176 -0
- package/dist/particle-emitter/presets.d.ts +46 -0
- package/dist/particle-emitter/presets.js +15 -0
- package/dist/particle-emitter/presets.js.map +1 -0
- package/dist/particle-emitter.d.ts +78 -0
- package/dist/particle-emitter.js +15 -0
- package/dist/particle-emitter.js.map +1 -0
- package/dist/payload-BQzu-oY_.d.ts +89 -0
- package/dist/platformer-3d.d.ts +347 -0
- package/dist/platformer-3d.js +23 -0
- package/dist/platformer-3d.js.map +1 -0
- package/dist/ricochet-2d.d.ts +274 -0
- package/dist/ricochet-2d.js +16 -0
- package/dist/ricochet-2d.js.map +1 -0
- package/dist/ricochet-3d.d.ts +116 -0
- package/dist/ricochet-3d.js +16 -0
- package/dist/ricochet-3d.js.map +1 -0
- package/dist/runtime-2d.d.ts +2 -0
- package/dist/runtime-2d.js +32 -0
- package/dist/runtime-2d.js.map +1 -0
- package/dist/runtime-pong.d.ts +92 -0
- package/dist/runtime-pong.js +38 -0
- package/dist/runtime-pong.js.map +1 -0
- package/dist/screen-visibility.d.ts +74 -0
- package/dist/screen-visibility.js +10 -0
- package/dist/screen-visibility.js.map +1 -0
- package/dist/screen-wrap.d.ts +86 -0
- package/dist/screen-wrap.js +16 -0
- package/dist/screen-wrap.js.map +1 -0
- package/dist/shooter-2d.d.ts +77 -0
- package/dist/shooter-2d.js +12 -0
- package/dist/shooter-2d.js.map +1 -0
- package/dist/spark-DDlIg1nM.d.ts +148 -0
- package/dist/sync-state-machine-CZyspBpj.d.ts +16 -0
- package/dist/thruster.d.ts +132 -0
- package/dist/thruster.js +26 -0
- package/dist/thruster.js.map +1 -0
- package/dist/top-down-movement.d.ts +40 -0
- package/dist/top-down-movement.js +20 -0
- package/dist/top-down-movement.js.map +1 -0
- package/dist/use-behavior-D_82jAL3.d.ts +13 -0
- package/dist/vector-Bm65-FOG.d.ts +45 -0
- package/dist/world-boundary-2d.d.ts +141 -0
- package/dist/world-boundary-2d.js +21 -0
- package/dist/world-boundary-2d.js.map +1 -0
- package/dist/world-boundary-3d.d.ts +75 -0
- package/dist/world-boundary-3d.js +21 -0
- package/dist/world-boundary-3d.js.map +1 -0
- package/package.json +161 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/behaviors/ricochet-2d/ricochet-2d-fsm.ts","../src/lib/behaviors/ricochet-2d/ricochet-2d.descriptor.ts"],"sourcesContent":["/**\n * Ricochet2DFSM\n *\n * FSM + extended state to track ricochet events and results.\n * The FSM state tracks whether a ricochet is currently occurring.\n */\nimport { BaseEntityInterface } from \"../../types/entity-types\";\nimport { SyncStateMachine, t } from '../../core/utility/sync-state-machine';\n\nexport interface Ricochet2DResult {\n\t/** The reflected velocity vector */\n\tvelocity: { x: number; y: number; z?: number };\n\t/** The resulting speed after reflection */\n\tspeed: number;\n\t/** The collision normal used for reflection */\n\tnormal: { x: number; y: number; z?: number };\n}\n\nexport interface Ricochet2DCollisionContext {\n\tentity?: BaseEntityInterface;\n\totherEntity?: BaseEntityInterface;\n\t/** Current velocity of the entity (optional if entity is provided) */\n\tselfVelocity?: { x: number; y: number; z?: number };\n\t/** Contact information from the collision */\n\tcontact: {\n\t\t/** The collision normal */\n\t\tnormal?: { x: number; y: number; z?: number };\n\t\t/**\n\t\t * Optional position where the collision occurred.\n\t\t * If provided, used for precise offset calculation.\n\t\t */\n\t\tposition?: { x: number; y: number; z?: number };\n\t};\n\t/**\n\t * Optional position of the entity that owns this behavior.\n\t * Used with contact.position for offset calculations.\n\t */\n\tselfPosition?: { x: number; y: number; z?: number };\n\t/**\n\t * Optional position of the other entity in the collision.\n\t * Used for paddle-style deflection: offset = (contactY - otherY) / halfHeight.\n\t */\n\totherPosition?: { x: number; y: number; z?: number };\n\t/**\n\t * Optional size of the other entity (e.g., paddle size).\n\t * If provided, used to normalize the offset based on the collision face.\n\t */\n\totherSize?: { x: number; y: number; z?: number };\n}\n\nexport enum Ricochet2DState {\n\tIdle = 'idle',\n\tRicocheting = 'ricocheting',\n}\n\nexport enum Ricochet2DEvent {\n\tStartRicochet = 'start-ricochet',\n\tEndRicochet = 'end-ricochet',\n}\n\nfunction clamp(value: number, min: number, max: number): number {\n\treturn Math.max(min, Math.min(max, value));\n}\n\n/**\n * Callback type for ricochet event listeners.\n */\nexport type RicochetCallback = (result: Ricochet2DResult) => void;\n\n/**\n * FSM wrapper with extended state (lastResult).\n * Systems or consumers call `computeRicochet(...)` when a collision occurs.\n */\nexport class Ricochet2DFSM {\n\tpublic readonly machine: SyncStateMachine<Ricochet2DState, Ricochet2DEvent, never>;\n\n\tprivate lastResult: Ricochet2DResult | null = null;\n\tprivate lastUpdatedAtMs: number | null = null;\n\tprivate currentTimeMs: number = 0;\n\tprivate listeners: Set<RicochetCallback> = new Set();\n\n\tconstructor() {\n\t\tthis.machine = new SyncStateMachine<Ricochet2DState, Ricochet2DEvent, never>(\n\t\t\tRicochet2DState.Idle,\n\t\t\t[\n\t\t\t\tt(Ricochet2DState.Idle, Ricochet2DEvent.StartRicochet, Ricochet2DState.Ricocheting),\n\t\t\t\tt(Ricochet2DState.Ricocheting, Ricochet2DEvent.EndRicochet, Ricochet2DState.Idle),\n\n\t\t\t\t// Self transitions (no-ops)\n\t\t\t\tt(Ricochet2DState.Idle, Ricochet2DEvent.EndRicochet, Ricochet2DState.Idle),\n\t\t\t\tt(Ricochet2DState.Ricocheting, Ricochet2DEvent.StartRicochet, Ricochet2DState.Ricocheting),\n\t\t\t]\n\t\t);\n\t}\n\n\t/**\n\t * Add a listener for ricochet events.\n\t * @returns Unsubscribe function\n\t */\n\taddListener(callback: RicochetCallback): () => void {\n\t\tthis.listeners.add(callback);\n\t\treturn () => this.listeners.delete(callback);\n\t}\n\n\t/**\n\t * Emit result to all listeners.\n\t */\n\tprivate emitToListeners(result: Ricochet2DResult): void {\n\t\tfor (const callback of this.listeners) {\n\t\t\ttry {\n\t\t\t\tcallback(result);\n\t\t\t} catch (e) {\n\t\t\t\tconsole.error('[Ricochet2DFSM] Listener error:', e);\n\t\t\t}\n\t\t}\n\t}\n\n\tgetState(): Ricochet2DState {\n\t\treturn this.machine.getState();\n\t}\n\n\t/**\n\t * Returns the last computed ricochet result, or null if none.\n\t */\n\tgetLastResult(): Ricochet2DResult | null {\n\t\treturn this.lastResult;\n\t}\n\n\t/**\n\t * Best-effort timestamp (ms) of the last computation.\n\t */\n\tgetLastUpdatedAtMs(): number | null {\n\t\treturn this.lastUpdatedAtMs;\n\t}\n\n\t/**\n\t * Set current game time (called by system each frame).\n\t * Used for cooldown calculations.\n\t */\n\tsetCurrentTimeMs(timeMs: number): void {\n\t\tthis.currentTimeMs = timeMs;\n\t}\n\n\t/**\n\t * Check if ricochet is on cooldown (to prevent rapid duplicate applications).\n\t * @param cooldownMs Cooldown duration in milliseconds (default: 50ms)\n\t */\n\tisOnCooldown(cooldownMs: number = 50): boolean {\n\t\tif (this.lastUpdatedAtMs === null) return false;\n\t\treturn (this.currentTimeMs - this.lastUpdatedAtMs) < cooldownMs;\n\t}\n\n\t/**\n\t * Reset cooldown state (e.g., on entity respawn).\n\t */\n\tresetCooldown(): void {\n\t\tthis.lastUpdatedAtMs = null;\n\t}\n\n\t/**\n\t * Compute a ricochet result from collision context.\n\t * Returns the result for the consumer to apply, or null if invalid input.\n\t */\n\tcomputeRicochet(\n\t\tctx: Ricochet2DCollisionContext,\n\t\toptions: {\n\t\t\tminSpeed?: number;\n\t\t\tmaxSpeed?: number;\n\t\t\tspeedMultiplier?: number;\n\t\t\treflectionMode?: 'simple' | 'angled';\n\t\t\tmaxAngleDeg?: number;\n\t\t} = {}\n\t): Ricochet2DResult | null {\n\t\tconst {\n\t\t\tminSpeed = 2,\n\t\t\tmaxSpeed = 20,\n\t\t\tspeedMultiplier = 1.05,\n\t\t\treflectionMode = 'angled',\n\t\t\tmaxAngleDeg = 60,\n\t\t} = options;\n\n\t\t// Extract data from entities if provided\n\t\tconst { selfVelocity, selfPosition, otherPosition, otherSize } = this.extractDataFromEntities(ctx);\n\n\t\tif (!selfVelocity) {\n\t\t\tthis.dispatch(Ricochet2DEvent.EndRicochet);\n\t\t\treturn null;\n\t\t}\n\n\t\tconst speed = Math.hypot(selfVelocity.x, selfVelocity.y);\n\t\tif (speed === 0) {\n\t\t\tthis.dispatch(Ricochet2DEvent.EndRicochet);\n\t\t\treturn null;\n\t\t}\n\n\t\t// Compute or extract collision normal\n\t\tconst normal = ctx.contact.normal ?? this.computeNormalFromPositions(selfPosition, otherPosition);\n\t\tif (!normal) {\n\t\t\tthis.dispatch(Ricochet2DEvent.EndRicochet);\n\t\t\treturn null;\n\t\t}\n\n\t\t// Compute basic reflection\n\t\tlet reflected = this.computeBasicReflection(selfVelocity, normal);\n\n\t\t// Apply angled deflection if requested\n\t\tif (reflectionMode === 'angled') {\n\t\t\treflected = this.computeAngledDeflection(\n\t\t\t\tselfVelocity,\n\t\t\t\tnormal,\n\t\t\t\tspeed,\n\t\t\t\tmaxAngleDeg,\n\t\t\t\tspeedMultiplier,\n\t\t\t\tselfPosition,\n\t\t\t\totherPosition,\n\t\t\t\totherSize,\n\t\t\t\tctx.contact.position\n\t\t\t);\n\t\t}\n\n\t\t// Apply final speed constraints\n\t\treflected = this.applySpeedClamp(reflected, minSpeed, maxSpeed);\n\n\t\tconst result: Ricochet2DResult = {\n\t\t\tvelocity: { x: reflected.x, y: reflected.y, z: 0 },\n\t\t\tspeed: Math.hypot(reflected.x, reflected.y),\n\t\t\tnormal: { x: normal.x, y: normal.y, z: 0 },\n\t\t};\n\n\t\tthis.lastResult = result;\n\t\tthis.lastUpdatedAtMs = this.currentTimeMs;\n\t\tthis.dispatch(Ricochet2DEvent.StartRicochet);\n\t\tthis.emitToListeners(result);\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Extract velocity, position, and size data from entities or context.\n\t */\n\tprivate extractDataFromEntities(ctx: Ricochet2DCollisionContext) {\n\t\tlet selfVelocity = ctx.selfVelocity;\n\t\tlet selfPosition = ctx.selfPosition;\n\t\tlet otherPosition = ctx.otherPosition;\n\t\tlet otherSize = ctx.otherSize;\n\n\t\tif (ctx.entity?.body) {\n\t\t\tconst vel = ctx.entity.body.linvel();\n\t\t\tselfVelocity = selfVelocity ?? { x: vel.x, y: vel.y, z: vel.z };\n\t\t\tconst pos = ctx.entity.body.translation();\n\t\t\tselfPosition = selfPosition ?? { x: pos.x, y: pos.y, z: pos.z };\n\t\t}\n\n\t\tif (ctx.otherEntity?.body) {\n\t\t\tconst pos = ctx.otherEntity.body.translation();\n\t\t\totherPosition = otherPosition ?? { x: pos.x, y: pos.y, z: pos.z };\n\t\t}\n\n\t\tif (ctx.otherEntity && 'size' in ctx.otherEntity) {\n\t\t\tconst size = (ctx.otherEntity as any).size;\n\t\t\tif (size && typeof size.x === 'number') {\n\t\t\t\totherSize = otherSize ?? { x: size.x, y: size.y, z: size.z };\n\t\t\t}\n\t\t}\n\n\t\treturn { selfVelocity, selfPosition, otherPosition, otherSize };\n\t}\n\n\t/**\n\t * Compute collision normal from entity positions using AABB heuristic.\n\t */\n\tprivate computeNormalFromPositions(\n\t\tselfPosition?: { x: number; y: number; z?: number },\n\t\totherPosition?: { x: number; y: number; z?: number }\n\t): { x: number; y: number; z?: number } | null {\n\t\tif (!selfPosition || !otherPosition) return null;\n\n\t\tconst dx = selfPosition.x - otherPosition.x;\n\t\tconst dy = selfPosition.y - otherPosition.y;\n\n\t\t// Simple \"which face was hit\" logic for box collisions\n\t\tif (Math.abs(dx) > Math.abs(dy)) {\n\t\t\treturn { x: dx > 0 ? 1 : -1, y: 0, z: 0 };\n\t\t} else {\n\t\t\treturn { x: 0, y: dy > 0 ? 1 : -1, z: 0 };\n\t\t}\n\t}\n\n\t/**\n\t * Compute basic reflection using the formula: v' = v - 2(v·n)n\n\t */\n\tprivate computeBasicReflection(\n\t\tvelocity: { x: number; y: number },\n\t\tnormal: { x: number; y: number; z?: number }\n\t): { x: number; y: number } {\n\t\tconst vx = velocity.x;\n\t\tconst vy = velocity.y;\n\t\tconst dotProduct = vx * normal.x + vy * normal.y;\n\n\t\treturn {\n\t\t\tx: vx - 2 * dotProduct * normal.x,\n\t\t\ty: vy - 2 * dotProduct * normal.y,\n\t\t};\n\t}\n\n\t/**\n\t * Compute angled deflection for paddle-style reflections.\n\t */\n\tprivate computeAngledDeflection(\n\t\tvelocity: { x: number; y: number },\n\t\tnormal: { x: number; y: number; z?: number },\n\t\tspeed: number,\n\t\tmaxAngleDeg: number,\n\t\tspeedMultiplier: number,\n\t\tselfPosition?: { x: number; y: number; z?: number },\n\t\totherPosition?: { x: number; y: number; z?: number },\n\t\totherSize?: { x: number; y: number; z?: number },\n\t\tcontactPosition?: { x: number; y: number; z?: number }\n\t): { x: number; y: number } {\n\t\tconst maxAngleRad = (maxAngleDeg * Math.PI) / 180;\n\n\t\t// Tangent vector (perpendicular to normal)\n\t\tlet tx = -normal.y;\n\t\tlet ty = normal.x;\n\n\t\t// Ensure tangent points in positive direction of the deflection axis\n\t\t// so that positive offset (right/top) results in positive deflection\n\t\tif (Math.abs(normal.x) > Math.abs(normal.y)) {\n\t\t\t// Vertical face (Normal is X-aligned). Deflection axis is Y.\n\t\t\t// We want ty > 0.\n\t\t\tif (ty < 0) {\n\t\t\t\ttx = -tx;\n\t\t\t\tty = -ty;\n\t\t\t}\n\t\t} else {\n\t\t\t// Horizontal face (Normal is Y-aligned). Deflection axis is X.\n\t\t\t// We want tx > 0.\n\t\t\tif (tx < 0) {\n\t\t\t\ttx = -tx;\n\t\t\t\tty = -ty;\n\t\t\t}\n\t\t}\n\n\t\t// Compute offset based on hit position\n\t\tconst offset = this.computeHitOffset(\n\t\t\tvelocity,\n\t\t\tnormal,\n\t\t\tspeed,\n\t\t\ttx,\n\t\t\tty,\n\t\t\tselfPosition,\n\t\t\totherPosition,\n\t\t\totherSize,\n\t\t\tcontactPosition\n\t\t);\n\n\t\tconst angle = clamp(offset, -1, 1) * maxAngleRad;\n\n\t\tconst cosA = Math.cos(angle);\n\t\tconst sinA = Math.sin(angle);\n\n\t\tconst newSpeed = speed * speedMultiplier;\n\n\t\treturn {\n\t\t\tx: newSpeed * (normal.x * cosA + tx * sinA),\n\t\t\ty: newSpeed * (normal.y * cosA + ty * sinA),\n\t\t};\n\t}\n\n\t/**\n\t * Compute hit offset for angled deflection (-1 to 1).\n\t */\n\tprivate computeHitOffset(\n\t\tvelocity: { x: number; y: number },\n\t\tnormal: { x: number; y: number; z?: number },\n\t\tspeed: number,\n\t\ttx: number,\n\t\tty: number,\n\t\tselfPosition?: { x: number; y: number; z?: number },\n\t\totherPosition?: { x: number; y: number; z?: number },\n\t\totherSize?: { x: number; y: number; z?: number },\n\t\tcontactPosition?: { x: number; y: number; z?: number }\n\t): number {\n\t\t// Use position-based offset if available\n\t\tif (otherPosition && otherSize) {\n\t\t\tconst useY = Math.abs(normal.x) > Math.abs(normal.y);\n\t\t\tconst halfExtent = useY ? otherSize.y / 2 : otherSize.x / 2;\n\n\t\t\tif (useY) {\n\t\t\t\tconst selfY = selfPosition?.y ?? contactPosition?.y ?? 0;\n\t\t\t\tconst paddleY = otherPosition.y;\n\t\t\t\treturn (selfY - paddleY) / halfExtent;\n\t\t\t} else {\n\t\t\t\tconst selfX = selfPosition?.x ?? contactPosition?.x ?? 0;\n\t\t\t\tconst paddleX = otherPosition.x;\n\t\t\t\treturn (selfX - paddleX) / halfExtent;\n\t\t\t}\n\t\t}\n\n\t\t// Fallback: use velocity-based offset\n\t\treturn (velocity.x * tx + velocity.y * ty) / speed;\n\t}\n\n\t/**\n\t * Apply speed constraints to the reflected velocity.\n\t */\n\tprivate applySpeedClamp(\n\t\tvelocity: { x: number; y: number },\n\t\tminSpeed: number,\n\t\tmaxSpeed: number\n\t): { x: number; y: number } {\n\t\tconst currentSpeed = Math.hypot(velocity.x, velocity.y);\n\t\tif (currentSpeed === 0) return velocity;\n\n\t\tconst targetSpeed = clamp(currentSpeed, minSpeed, maxSpeed);\n\t\tconst scale = targetSpeed / currentSpeed;\n\n\t\treturn {\n\t\t\tx: velocity.x * scale,\n\t\t\ty: velocity.y * scale,\n\t\t};\n\t}\n\n\t/**\n\t * Clear the ricochet state (call after consumer has applied the result).\n\t */\n\tclearRicochet(): void {\n\t\tthis.dispatch(Ricochet2DEvent.EndRicochet);\n\t}\n\n\tprivate dispatch(event: Ricochet2DEvent): void {\n\t\tif (this.machine.can(event)) {\n\t\t\tthis.machine.syncDispatch(event);\n\t\t}\n\t}\n}\n","/**\n * Ricochet2DBehavior\n *\n * Computes 2D ricochet/reflection results for entities during collisions.\n * The behavior computes the result; the consumer decides how to apply it.\n *\n * Use `getRicochet(ctx)` on the behavior handle to compute reflection results.\n */\n\nimport { defineBehavior, type BehaviorRef } from '../behavior-descriptor';\nimport type { BehaviorEntityLink, BehaviorSystem } from '../behavior-system';\nimport { Ricochet2DFSM, type Ricochet2DResult, type Ricochet2DCollisionContext, type RicochetCallback } from './ricochet-2d-fsm';\nimport {\n\tStageRicochetDim,\n\tStageRicochetReflection,\n\ttype WasmStageRuntime,\n} from '../../runtime/wasm-stage-runtime';\nexport type { Ricochet2DResult };\n\nexport interface Ricochet2DOptions {\n\t/**\n\t * Minimum speed after reflection.\n\t * Default: 2\n\t */\n\tminSpeed: number;\n\n\t/**\n\t * Maximum speed after reflection.\n\t * Default: 20\n\t */\n\tmaxSpeed: number;\n\n\t/**\n\t * Speed multiplier applied during angled reflection.\n\t * Default: 1.05\n\t */\n\tspeedMultiplier: number;\n\n\t/**\n\t * Reflection mode:\n\t * - 'simple': Basic axis inversion\n\t * - 'angled': Paddle-style deflection based on contact point\n\t * Default: 'angled'\n\t */\n\treflectionMode: 'simple' | 'angled';\n\n\t/**\n\t * Maximum deflection angle in degrees for angled mode.\n\t * Default: 60\n\t */\n\tmaxAngleDeg: number;\n}\n\n/**\n * Handle methods provided by Ricochet2DBehavior\n */\nexport interface Ricochet2DHandle {\n\t/**\n\t * Compute a ricochet/reflection result from collision context.\n\t * Returns the result for the consumer to apply, or null if invalid input.\n\t *\n\t * @param ctx - Collision context with selfVelocity and contact normal\n\t * @returns Ricochet result with velocity, speed, and normal, or null\n\t */\n\tgetRicochet(ctx: Ricochet2DCollisionContext): Ricochet2DResult | null;\n\n\t/**\n\t * Compute ricochet and apply velocity directly via transformStore.\n\t * Emits to onRicochet listeners if successful.\n\t *\n\t * @param ctx - Collision context with entity and contact normal\n\t * @returns true if ricochet was computed and applied, false otherwise\n\t */\n\tapplyRicochet(ctx: Ricochet2DCollisionContext): boolean;\n\n\t/**\n\t * Get the last computed ricochet result, or null if none.\n\t */\n\tgetLastResult(): Ricochet2DResult | null;\n\n\t/**\n\t * Register a listener for ricochet events.\n\t * Called whenever a ricochet is computed (from getRicochet or applyRicochet).\n\t *\n\t * @param callback - Function to call with ricochet result\n\t * @returns Unsubscribe function\n\t */\n\tonRicochet(callback: RicochetCallback): () => void;\n}\n\nconst defaultOptions: Ricochet2DOptions = {\n\tminSpeed: 2,\n\tmaxSpeed: 20,\n\tspeedMultiplier: 1.05,\n\treflectionMode: 'angled',\n\tmaxAngleDeg: 60,\n};\n\nconst RICOCHET_BEHAVIOR_KEY = Symbol.for('zylem:behavior:ricochet-2d');\n\n/**\n * Creates behavior-specific handle methods for Ricochet2DBehavior.\n */\nfunction createRicochet2DHandle(\n\tref: BehaviorRef<Ricochet2DOptions>\n): Ricochet2DHandle {\n\treturn {\n\t\tgetRicochet: (ctx: Ricochet2DCollisionContext) => {\n\t\t\tconst fsm = ref.fsm as Ricochet2DFSM | undefined;\n\t\t\tif (!fsm) return null;\n\t\t\treturn fsm.computeRicochet(ctx, ref.options);\n\t\t},\n\t\tapplyRicochet: (ctx: Ricochet2DCollisionContext): boolean => {\n\t\t\tconst fsm = ref.fsm as Ricochet2DFSM | undefined;\n\t\t\tif (!fsm) return false;\n\n\t\t\t// Skip if on cooldown (prevents rapid duplicate applications)\n\t\t\tif (fsm.isOnCooldown()) return false;\n\n\t\t\tconst result = fsm.computeRicochet(ctx, ref.options);\n\t\t\tif (!result) return false;\n\n\t\t\t// Apply velocity via transformStore\n\t\t\tconst entity = ctx.entity as any;\n\t\t\tif (entity?.transformStore) {\n\t\t\t\tentity.transformStore.velocity.x = result.velocity.x;\n\t\t\t\tentity.transformStore.velocity.y = result.velocity.y;\n\t\t\t\tentity.transformStore.velocity.z = result.velocity.z ?? 0;\n\t\t\t\tentity.transformStore.dirty.velocity = true;\n\t\t\t}\n\n\t\t\treturn true;\n\t\t},\n\t\tgetLastResult: () => {\n\t\t\tconst fsm = ref.fsm as Ricochet2DFSM | undefined;\n\t\t\treturn fsm?.getLastResult() ?? null;\n\t\t},\n\t\tonRicochet: (callback: RicochetCallback): (() => void) => {\n\t\t\tconst fsm = ref.fsm as Ricochet2DFSM | undefined;\n\t\t\tif (!fsm) {\n\t\t\t\t// FSM not ready yet - queue callback for later\n\t\t\t\t// System will apply pending callbacks when FSM is created\n\t\t\t\tif (!(ref as any).pendingListeners) {\n\t\t\t\t\t(ref as any).pendingListeners = [];\n\t\t\t\t}\n\t\t\t\t(ref as any).pendingListeners.push(callback);\n\t\t\t\t\n\t\t\t\t// Return unsubscribe that removes from pending queue\n\t\t\t\treturn () => {\n\t\t\t\t\tconst pending = (ref as any).pendingListeners as RicochetCallback[];\n\t\t\t\t\tconst idx = pending.indexOf(callback);\n\t\t\t\t\tif (idx >= 0) pending.splice(idx, 1);\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn fsm.addListener(callback);\n\t\t},\n\t};\n}\n\n/**\n * Ricochet2DSystem\n *\n * Stage-level system that:\n * - finds entities with this behavior attached\n * - lazily creates FSM instances for each entity\n *\n * Note: This behavior is consumer-driven. The system only manages FSM lifecycle.\n * Consumers call `getRicochet(ctx)` during collision callbacks to compute results.\n */\nclass Ricochet2DSystem implements BehaviorSystem {\n\tprivate elapsedMs: number = 0;\n\tprivate attachedRuntimeSlots = new Set<number>();\n\n\tconstructor(\n\t\tprivate world: any,\n\t\tprivate wasmStage: WasmStageRuntime | null,\n\t\tprivate getBehaviorLinks?: (key: symbol) => Iterable<BehaviorEntityLink>,\n\t) {}\n\n\tupdate(_ecs: unknown, delta: number): void {\n\t\tthis.elapsedMs += delta * 1000;\n\n\t\tconst links = this.getBehaviorLinks?.(RICOCHET_BEHAVIOR_KEY);\n\t\tif (!links) return;\n\n\t\tfor (const link of links) {\n\t\t\tconst ricochetRef = link.ref as any;\n\t\t\tconst gameEntity = link.entity as any;\n\n\t\t\tif (!ricochetRef.fsm) {\n\t\t\t\tricochetRef.fsm = new Ricochet2DFSM();\n\n\t\t\t\tconst pending = (ricochetRef as any).pendingListeners as RicochetCallback[] | undefined;\n\t\t\t\tif (pending) {\n\t\t\t\t\tfor (const cb of pending) {\n\t\t\t\t\t\tricochetRef.fsm.addListener(cb);\n\t\t\t\t\t}\n\t\t\t\t\t(ricochetRef as any).pendingListeners = [];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tricochetRef.fsm.setCurrentTimeMs(this.elapsedMs);\n\n\t\t\tconst handle = (gameEntity?.runtimeHandle ?? -1) as number;\n\t\t\tif (this.wasmStage && handle >= 0) {\n\t\t\t\tthis.ensureWasmAttached(handle, ricochetRef.options as Ricochet2DOptions);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate ensureWasmAttached(handle: number, options: Ricochet2DOptions): void {\n\t\tif (!this.wasmStage || this.attachedRuntimeSlots.has(handle)) return;\n\t\tconst reflectionMode = options.reflectionMode === 'simple'\n\t\t\t? StageRicochetReflection.Mirror\n\t\t\t: StageRicochetReflection.Angled;\n\t\tthis.wasmStage.attachRicochet(handle, StageRicochetDim.Two, {\n\t\t\tminSpeed: options.minSpeed,\n\t\t\tmaxSpeed: options.maxSpeed,\n\t\t\tspeedMultiplier: options.speedMultiplier,\n\t\t\tmaxAngleDeg: options.maxAngleDeg,\n\t\t\treflectionMode,\n\t\t});\n\t\tthis.attachedRuntimeSlots.add(handle);\n\t}\n\n\tdestroy(_ecs: unknown): void {\n\t\tconst links = this.getBehaviorLinks?.(RICOCHET_BEHAVIOR_KEY);\n\t\tif (links) {\n\t\t\tfor (const link of links) {\n\t\t\t\tconst ricochetRef = link.ref as any;\n\t\t\t\tif (ricochetRef?.fsm) {\n\t\t\t\t\tricochetRef.fsm.resetCooldown();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.attachedRuntimeSlots.clear();\n\t}\n}\n\n/**\n * Ricochet2DBehavior\n *\n * @example\n * ```ts\n * import { Ricochet2DBehavior } from \"@zylem/game-lib/behavior\";\n *\n * const ball = createSphere({ ... });\n * const ricochet = ball.use(Ricochet2DBehavior, {\n * minSpeed: 3,\n * maxSpeed: 15,\n * reflectionMode: 'angled',\n * });\n *\n * ball.onCollision(({ entity, other }) => {\n * const velocity = entity.body.linvel();\n * const result = ricochet.getRicochet({\n * selfVelocity: velocity,\n * contact: { normal: { x: 1, y: 0 } }, // from collision data\n * });\n *\n * if (result) {\n * entity.body.setLinvel(result.velocity, true);\n * }\n * });\n * ```\n */\nexport const Ricochet2DBehavior = defineBehavior({\n\tname: 'ricochet-2d',\n\tdefaultOptions,\n\tsystemFactory: (ctx) =>\n\t\tnew Ricochet2DSystem(ctx.world, ctx.wasmStage ?? null, ctx.getBehaviorLinks),\n\tcreateHandle: createRicochet2DHandle,\n});\n"],"mappings":";;;;;;;;;;;;;AAkDO,IAAK,kBAAL,kBAAKA,qBAAL;AACN,EAAAA,iBAAA,UAAO;AACP,EAAAA,iBAAA,iBAAc;AAFH,SAAAA;AAAA,GAAA;AAKL,IAAK,kBAAL,kBAAKC,qBAAL;AACN,EAAAA,iBAAA,mBAAgB;AACh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UAAM,QAAQ,KAAK,mBAAmB,qBAAqB;AAC3D,QAAI,OAAO;AACV,iBAAW,QAAQ,OAAO;AACzB,cAAM,cAAc,KAAK;AACzB,YAAI,aAAa,KAAK;AACrB,sBAAY,IAAI,cAAc;AAAA,QAC/B;AAAA,MACD;AAAA,IACD;AACA,SAAK,qBAAqB,MAAM;AAAA,EACjC;AACD;AA6BO,IAAM,qBAAqB,eAAe;AAAA,EAChD,MAAM;AAAA,EACN;AAAA,EACA,eAAe,CAAC,QACf,IAAI,iBAAiB,IAAI,OAAO,IAAI,aAAa,MAAM,IAAI,gBAAgB;AAAA,EAC5E,cAAc;AACf,CAAC;","names":["Ricochet2DState","Ricochet2DEvent"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// src/lib/behaviors/thruster/components.ts
|
|
2
|
+
function createThrusterMovementComponent(linearThrust, angularThrust, options) {
|
|
3
|
+
return {
|
|
4
|
+
linearThrust,
|
|
5
|
+
angularThrust,
|
|
6
|
+
linearDamping: options?.linearDamping,
|
|
7
|
+
angularDamping: options?.angularDamping
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function createThrusterInputComponent() {
|
|
11
|
+
return {
|
|
12
|
+
thrust: 0,
|
|
13
|
+
rotate: 0,
|
|
14
|
+
thrustX: 0,
|
|
15
|
+
thrustY: 0
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function createThrusterStateComponent() {
|
|
19
|
+
return {
|
|
20
|
+
enabled: true,
|
|
21
|
+
currentThrust: 0
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
createThrusterMovementComponent,
|
|
27
|
+
createThrusterInputComponent,
|
|
28
|
+
createThrusterStateComponent
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=chunk-KS72RZHX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/behaviors/thruster/components.ts"],"sourcesContent":["/**\n * Thruster-specific ECS Components\n * \n * These components are specific to the thruster movement system.\n */\n\n// ─────────────────────────────────────────────────────────────────────────────\n// ThrusterMovementComponent (capability / hardware spec)\n// Defines the thrust capabilities of an entity\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport interface ThrusterMovementComponent {\n\t/** Linear thrust force in Newtons (or scaled units) */\n\tlinearThrust: number;\n\t/** Angular thrust torque scalar */\n\tangularThrust: number;\n\t/** Optional linear damping override */\n\tlinearDamping?: number;\n\t/** Optional angular damping override */\n\tangularDamping?: number;\n}\n\nexport function createThrusterMovementComponent(\n\tlinearThrust: number,\n\tangularThrust: number,\n\toptions?: { linearDamping?: number; angularDamping?: number }\n): ThrusterMovementComponent {\n\treturn {\n\t\tlinearThrust,\n\t\tangularThrust,\n\t\tlinearDamping: options?.linearDamping,\n\t\tangularDamping: options?.angularDamping,\n\t};\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// ThrusterInputComponent (intent)\n// Written by: Player controller, AI controller, FSM adapter\n// Read by: ThrusterMovementBehavior\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport interface ThrusterInputComponent {\n\t/** Forward thrust intent: 0..1 */\n\tthrust: number;\n\t/** Rotation intent: -1..1 */\n\trotate: number;\n\t/** World-space X thrust intent: -1..1 */\n\tthrustX: number;\n\t/** World-space Y thrust intent: -1..1 */\n\tthrustY: number;\n}\n\nexport function createThrusterInputComponent(): ThrusterInputComponent {\n\treturn {\n\t\tthrust: 0,\n\t\trotate: 0,\n\t\tthrustX: 0,\n\t\tthrustY: 0,\n\t};\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// ThrusterStateComponent (optional but useful)\n// Useful for: damage, EMP, overheating, UI feedback\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport interface ThrusterStateComponent {\n\t/** Whether the thruster is enabled */\n\tenabled: boolean;\n\t/** Current thrust after FSM/gating */\n\tcurrentThrust: number;\n}\n\nexport function createThrusterStateComponent(): ThrusterStateComponent {\n\treturn {\n\t\tenabled: true,\n\t\tcurrentThrust: 0,\n\t};\n}\n"],"mappings":";AAsBO,SAAS,gCACf,cACA,eACA,SAC4B;AAC5B,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA,eAAe,SAAS;AAAA,IACxB,gBAAgB,SAAS;AAAA,EAC1B;AACD;AAmBO,SAAS,+BAAuD;AACtE,SAAO;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,SAAS;AAAA,EACV;AACD;AAcO,SAAS,+BAAuD;AACtE,SAAO;AAAA,IACN,SAAS;AAAA,IACT,eAAe;AAAA,EAChB;AACD;","names":[]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// src/lib/behaviors/first-person/components.ts
|
|
2
|
+
function createFirstPersonMovementComponent(options = {}) {
|
|
3
|
+
return {
|
|
4
|
+
walkSpeed: options.walkSpeed ?? 8,
|
|
5
|
+
runSpeed: options.runSpeed ?? 16,
|
|
6
|
+
lookSensitivity: options.lookSensitivity ?? 2,
|
|
7
|
+
eyeHeight: options.eyeHeight ?? 1.7
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function createFirstPersonInputComponent() {
|
|
11
|
+
return {
|
|
12
|
+
moveX: 0,
|
|
13
|
+
moveZ: 0,
|
|
14
|
+
lookX: 0,
|
|
15
|
+
lookY: 0,
|
|
16
|
+
sprint: false
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function createFirstPersonStateComponent() {
|
|
20
|
+
return {
|
|
21
|
+
yaw: 0,
|
|
22
|
+
pitch: 0,
|
|
23
|
+
currentSpeed: 0
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
createFirstPersonMovementComponent,
|
|
29
|
+
createFirstPersonInputComponent,
|
|
30
|
+
createFirstPersonStateComponent
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=chunk-LD5SMIB3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/behaviors/first-person/components.ts"],"sourcesContent":["/**\n * First Person Controller ECS Components\n *\n * Components for first-person movement and camera control:\n * - Movement configuration (walk/run speed, sensitivity, eye height)\n * - Input intent (WASD movement + mouse look deltas)\n * - Runtime state (yaw, pitch, speed)\n */\n\n// ─────────────────────────────────────────────────────────────────────────────\n// FirstPersonMovementComponent (capability / configuration)\n// Defines movement capabilities and look parameters\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport interface FirstPersonMovementComponent {\n\t/** Base walking speed (units/sec) */\n\twalkSpeed: number;\n\t/** Sprint/run speed (units/sec) */\n\trunSpeed: number;\n\t/** Look sensitivity multiplier applied to raw input deltas */\n\tlookSensitivity: number;\n\t/** Vertical offset above entity position for eye/camera placement */\n\teyeHeight: number;\n}\n\nexport function createFirstPersonMovementComponent(\n\toptions: Partial<FirstPersonMovementComponent> = {},\n): FirstPersonMovementComponent {\n\treturn {\n\t\twalkSpeed: options.walkSpeed ?? 8,\n\t\trunSpeed: options.runSpeed ?? 16,\n\t\tlookSensitivity: options.lookSensitivity ?? 2,\n\t\teyeHeight: options.eyeHeight ?? 1.7,\n\t};\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// FirstPersonInputComponent (intent)\n// Written by: Player controller (game.onUpdate / entity.onUpdate)\n// Read by: FirstPersonControllerBehavior\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport interface FirstPersonInputComponent {\n\t/** Horizontal movement input (-1 to 1, strafe) */\n\tmoveX: number;\n\t/** Forward/backward movement input (-1 to 1) */\n\tmoveZ: number;\n\t/** Horizontal look delta (mouse/stick, raw value before sensitivity) */\n\tlookX: number;\n\t/** Vertical look delta (mouse/stick, raw value before sensitivity) */\n\tlookY: number;\n\t/** Sprint button held */\n\tsprint: boolean;\n}\n\nexport function createFirstPersonInputComponent(): FirstPersonInputComponent {\n\treturn {\n\t\tmoveX: 0,\n\t\tmoveZ: 0,\n\t\tlookX: 0,\n\t\tlookY: 0,\n\t\tsprint: false,\n\t};\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// FirstPersonStateComponent (runtime state)\n// Tracks the current state of the first-person entity\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport interface FirstPersonStateComponent {\n\t/** Current yaw in radians */\n\tyaw: number;\n\t/** Current pitch in radians */\n\tpitch: number;\n\t/** Current movement speed being applied */\n\tcurrentSpeed: number;\n}\n\nexport function createFirstPersonStateComponent(): FirstPersonStateComponent {\n\treturn {\n\t\tyaw: 0,\n\t\tpitch: 0,\n\t\tcurrentSpeed: 0,\n\t};\n}\n"],"mappings":";AAyBO,SAAS,mCACf,UAAiD,CAAC,GACnB;AAC/B,SAAO;AAAA,IACN,WAAW,QAAQ,aAAa;AAAA,IAChC,UAAU,QAAQ,YAAY;AAAA,IAC9B,iBAAiB,QAAQ,mBAAmB;AAAA,IAC5C,WAAW,QAAQ,aAAa;AAAA,EACjC;AACD;AAqBO,SAAS,kCAA6D;AAC5E,SAAO;AAAA,IACN,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,QAAQ;AAAA,EACT;AACD;AAgBO,SAAS,kCAA6D;AAC5E,SAAO;AAAA,IACN,KAAK;AAAA,IACL,OAAO;AAAA,IACP,cAAc;AAAA,EACf;AACD;","names":[]}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// src/lib/behaviors/shared/bounds-3d.ts
|
|
2
|
+
function normalizeBounds3DPadding(padding) {
|
|
3
|
+
if (typeof padding === "number") {
|
|
4
|
+
return { x: padding, y: padding, z: padding };
|
|
5
|
+
}
|
|
6
|
+
return {
|
|
7
|
+
x: padding?.x ?? 0,
|
|
8
|
+
y: padding?.y ?? 0,
|
|
9
|
+
z: padding?.z ?? 0
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function insetBounds3D(bounds, padding) {
|
|
13
|
+
const resolved = normalizeBounds3DPadding(padding);
|
|
14
|
+
return {
|
|
15
|
+
minX: bounds.minX + resolved.x,
|
|
16
|
+
maxX: bounds.maxX - resolved.x,
|
|
17
|
+
minY: bounds.minY + resolved.y,
|
|
18
|
+
maxY: bounds.maxY - resolved.y,
|
|
19
|
+
minZ: bounds.minZ + resolved.z,
|
|
20
|
+
maxZ: bounds.maxZ - resolved.z
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function computeBounds3DHits(position, bounds) {
|
|
24
|
+
const hits = {
|
|
25
|
+
left: false,
|
|
26
|
+
right: false,
|
|
27
|
+
top: false,
|
|
28
|
+
bottom: false,
|
|
29
|
+
back: false,
|
|
30
|
+
front: false
|
|
31
|
+
};
|
|
32
|
+
if (position.x <= bounds.minX) hits.left = true;
|
|
33
|
+
else if (position.x >= bounds.maxX) hits.right = true;
|
|
34
|
+
if (position.y <= bounds.minY) hits.bottom = true;
|
|
35
|
+
else if (position.y >= bounds.maxY) hits.top = true;
|
|
36
|
+
if (position.z <= bounds.minZ) hits.back = true;
|
|
37
|
+
else if (position.z >= bounds.maxZ) hits.front = true;
|
|
38
|
+
return hits;
|
|
39
|
+
}
|
|
40
|
+
function hasAnyBounds3DHit(hits) {
|
|
41
|
+
return hits.left || hits.right || hits.top || hits.bottom || hits.back || hits.front;
|
|
42
|
+
}
|
|
43
|
+
function constrainMovementToBounds3D(hits, moveX, moveY, moveZ) {
|
|
44
|
+
let adjustedX = moveX;
|
|
45
|
+
let adjustedY = moveY;
|
|
46
|
+
let adjustedZ = moveZ;
|
|
47
|
+
if (hits.left && moveX < 0 || hits.right && moveX > 0) {
|
|
48
|
+
adjustedX = 0;
|
|
49
|
+
}
|
|
50
|
+
if (hits.bottom && moveY < 0 || hits.top && moveY > 0) {
|
|
51
|
+
adjustedY = 0;
|
|
52
|
+
}
|
|
53
|
+
if (hits.back && moveZ < 0 || hits.front && moveZ > 0) {
|
|
54
|
+
adjustedZ = 0;
|
|
55
|
+
}
|
|
56
|
+
return { moveX: adjustedX, moveY: adjustedY, moveZ: adjustedZ };
|
|
57
|
+
}
|
|
58
|
+
function clampPointToBounds3D(position, bounds) {
|
|
59
|
+
return {
|
|
60
|
+
x: Math.min(bounds.maxX, Math.max(bounds.minX, position.x)),
|
|
61
|
+
y: Math.min(bounds.maxY, Math.max(bounds.minY, position.y)),
|
|
62
|
+
z: Math.min(bounds.maxZ, Math.max(bounds.minZ, position.z))
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function getBounds3DNormalFromHits(hits) {
|
|
66
|
+
let x = 0;
|
|
67
|
+
let y = 0;
|
|
68
|
+
let z = 0;
|
|
69
|
+
if (hits.left) x = 1;
|
|
70
|
+
if (hits.right) x = -1;
|
|
71
|
+
if (hits.bottom) y = 1;
|
|
72
|
+
if (hits.top) y = -1;
|
|
73
|
+
if (hits.back) z = 1;
|
|
74
|
+
if (hits.front) z = -1;
|
|
75
|
+
return { x, y, z };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export {
|
|
79
|
+
insetBounds3D,
|
|
80
|
+
computeBounds3DHits,
|
|
81
|
+
hasAnyBounds3DHit,
|
|
82
|
+
constrainMovementToBounds3D,
|
|
83
|
+
clampPointToBounds3D,
|
|
84
|
+
getBounds3DNormalFromHits
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=chunk-OHCPV2NT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/behaviors/shared/bounds-3d.ts"],"sourcesContent":["export interface Bounds3DPoint {\n\tx: number;\n\ty: number;\n\tz: number;\n}\n\nexport interface Bounds3DBox {\n\tminX: number;\n\tmaxX: number;\n\tminY: number;\n\tmaxY: number;\n\tminZ: number;\n\tmaxZ: number;\n}\n\nexport interface Bounds3DSize {\n\twidth: number;\n\theight: number;\n\tdepth: number;\n\tcenterX?: number;\n\tcenterY?: number;\n\tcenterZ?: number;\n}\n\nexport interface Bounds3DHits {\n\tleft: boolean;\n\tright: boolean;\n\ttop: boolean;\n\tbottom: boolean;\n\tback: boolean;\n\tfront: boolean;\n}\n\nexport interface Bounds3DPadding {\n\tx: number;\n\ty: number;\n\tz: number;\n}\n\nexport type Bounds3DPaddingInput =\n\t| number\n\t| Partial<Bounds3DPadding>\n\t| undefined;\n\nexport function createBounds3DBox({\n\twidth,\n\theight,\n\tdepth,\n\tcenterX = 0,\n\tcenterY = 0,\n\tcenterZ = 0,\n}: Bounds3DSize): Bounds3DBox {\n\tconst halfWidth = width / 2;\n\tconst halfHeight = height / 2;\n\tconst halfDepth = depth / 2;\n\treturn {\n\t\tminX: centerX - halfWidth,\n\t\tmaxX: centerX + halfWidth,\n\t\tminY: centerY - halfHeight,\n\t\tmaxY: centerY + halfHeight,\n\t\tminZ: centerZ - halfDepth,\n\t\tmaxZ: centerZ + halfDepth,\n\t};\n}\n\nexport function normalizeBounds3DPadding(\n\tpadding?: Bounds3DPaddingInput,\n): Bounds3DPadding {\n\tif (typeof padding === 'number') {\n\t\treturn { x: padding, y: padding, z: padding };\n\t}\n\n\treturn {\n\t\tx: padding?.x ?? 0,\n\t\ty: padding?.y ?? 0,\n\t\tz: padding?.z ?? 0,\n\t};\n}\n\nexport function insetBounds3D(\n\tbounds: Bounds3DBox,\n\tpadding?: Bounds3DPaddingInput,\n): Bounds3DBox {\n\tconst resolved = normalizeBounds3DPadding(padding);\n\treturn {\n\t\tminX: bounds.minX + resolved.x,\n\t\tmaxX: bounds.maxX - resolved.x,\n\t\tminY: bounds.minY + resolved.y,\n\t\tmaxY: bounds.maxY - resolved.y,\n\t\tminZ: bounds.minZ + resolved.z,\n\t\tmaxZ: bounds.maxZ - resolved.z,\n\t};\n}\n\nexport function computeBounds3DHits(\n\tposition: Bounds3DPoint,\n\tbounds: Bounds3DBox,\n): Bounds3DHits {\n\tconst hits: Bounds3DHits = {\n\t\tleft: false,\n\t\tright: false,\n\t\ttop: false,\n\t\tbottom: false,\n\t\tback: false,\n\t\tfront: false,\n\t};\n\n\tif (position.x <= bounds.minX) hits.left = true;\n\telse if (position.x >= bounds.maxX) hits.right = true;\n\n\tif (position.y <= bounds.minY) hits.bottom = true;\n\telse if (position.y >= bounds.maxY) hits.top = true;\n\n\tif (position.z <= bounds.minZ) hits.back = true;\n\telse if (position.z >= bounds.maxZ) hits.front = true;\n\n\treturn hits;\n}\n\nexport function hasAnyBounds3DHit(hits: Bounds3DHits): boolean {\n\treturn hits.left || hits.right || hits.top || hits.bottom || hits.back || hits.front;\n}\n\nexport function constrainMovementToBounds3D(\n\thits: Bounds3DHits,\n\tmoveX: number,\n\tmoveY: number,\n\tmoveZ: number,\n): { moveX: number; moveY: number; moveZ: number } {\n\tlet adjustedX = moveX;\n\tlet adjustedY = moveY;\n\tlet adjustedZ = moveZ;\n\n\tif ((hits.left && moveX < 0) || (hits.right && moveX > 0)) {\n\t\tadjustedX = 0;\n\t}\n\n\tif ((hits.bottom && moveY < 0) || (hits.top && moveY > 0)) {\n\t\tadjustedY = 0;\n\t}\n\n\tif ((hits.back && moveZ < 0) || (hits.front && moveZ > 0)) {\n\t\tadjustedZ = 0;\n\t}\n\n\treturn { moveX: adjustedX, moveY: adjustedY, moveZ: adjustedZ };\n}\n\nexport function clampPointToBounds3D(\n\tposition: Bounds3DPoint,\n\tbounds: Bounds3DBox,\n): Bounds3DPoint {\n\treturn {\n\t\tx: Math.min(bounds.maxX, Math.max(bounds.minX, position.x)),\n\t\ty: Math.min(bounds.maxY, Math.max(bounds.minY, position.y)),\n\t\tz: Math.min(bounds.maxZ, Math.max(bounds.minZ, position.z)),\n\t};\n}\n\nexport function getBounds3DNormalFromHits(\n\thits: Bounds3DHits,\n): { x: number; y: number; z: number } {\n\tlet x = 0;\n\tlet y = 0;\n\tlet z = 0;\n\n\tif (hits.left) x = 1;\n\tif (hits.right) x = -1;\n\tif (hits.bottom) y = 1;\n\tif (hits.top) y = -1;\n\tif (hits.back) z = 1;\n\tif (hits.front) z = -1;\n\n\treturn { x, y, z };\n}\n"],"mappings":";AAiEO,SAAS,yBACf,SACkB;AAClB,MAAI,OAAO,YAAY,UAAU;AAChC,WAAO,EAAE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gBAAY;AAAA,EACb;AAEA,MAAK,KAAK,UAAU,QAAQ,KAAO,KAAK,OAAO,QAAQ,GAAI;AAC1D,gBAAY;AAAA,EACb;AAEA,MAAK,KAAK,QAAQ,QAAQ,KAAO,KAAK,SAAS,QAAQ,GAAI;AAC1D,gBAAY;AAAA,EACb;AAEA,SAAO,EAAE,OAAO,WAAW,OAAO,WAAW,OAAO,UAAU;AAC/D;AAEO,SAAS,qBACf,UACA,QACgB;AAChB,SAAO;AAAA,IACN,GAAG,KAAK,IAAI,OAAO,MAAM,KAAK,IAAI,OAAO,MAAM,SAAS,CAAC,CAAC;AAAA,IAC1D,GAAG,KAAK,IAAI,OAAO,MAAM,KAAK,IAAI,OAAO,MAAM,SAAS,CAAC,CAAC;AAAA,IAC1D,GAAG,KAAK,IAAI,OAAO,MAAM,KAAK,IAAI,OAAO,MAAM,SAAS,CAAC,CAAC;AAAA,EAC3D;AACD;AAEO,SAAS,0BACf,MACsC;AACtC,MAAI,IAAI;AACR,MAAI,IAAI;AACR,MAAI,IAAI;AAER,MAAI,KAAK,KAAM,KAAI;AACnB,MAAI,KAAK,MAAO,KAAI;AACpB,MAAI,KAAK,OAAQ,KAAI;AACrB,MAAI,KAAK,IAAK,KAAI;AAClB,MAAI,KAAK,KAAM,KAAI;AACnB,MAAI,KAAK,MAAO,KAAI;AAEpB,SAAO,EAAE,GAAG,GAAG,EAAE;AAClB;","names":[]}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createTopDownMovementComponent,
|
|
3
|
+
createTopDownMovementInputComponent,
|
|
4
|
+
createTopDownMovementStateComponent
|
|
5
|
+
} from "./chunk-EIWQM6U3.js";
|
|
6
|
+
import {
|
|
7
|
+
angleFromDirection2D,
|
|
8
|
+
normalizeDirection2D
|
|
9
|
+
} from "./chunk-ID5QJYF5.js";
|
|
10
|
+
import {
|
|
11
|
+
StageTopDownPlane
|
|
12
|
+
} from "./chunk-Y6UJOUE5.js";
|
|
13
|
+
import {
|
|
14
|
+
defineBehavior
|
|
15
|
+
} from "./chunk-EZNCCO4L.js";
|
|
16
|
+
|
|
17
|
+
// src/lib/behaviors/top-down-movement/top-down-movement.behavior.ts
|
|
18
|
+
var TopDownMovementRuntimeBehavior = class {
|
|
19
|
+
updateEntity(entity, _delta) {
|
|
20
|
+
if (!entity.body || !entity.transformStore || !entity.topDownMovement || !entity.$topDownMovement || !entity.topDownMovementState) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const movement = entity.topDownMovement;
|
|
24
|
+
const input = entity.$topDownMovement;
|
|
25
|
+
const state = entity.topDownMovementState;
|
|
26
|
+
const moveDirection = normalizeDirection2D(input.moveX, input.moveY);
|
|
27
|
+
const velocity = entity.body.linvel();
|
|
28
|
+
state.moving = moveDirection !== null;
|
|
29
|
+
entity.transformStore.velocity.x = (moveDirection?.x ?? 0) * movement.moveSpeed;
|
|
30
|
+
entity.transformStore.velocity.y = (moveDirection?.y ?? 0) * movement.moveSpeed;
|
|
31
|
+
entity.transformStore.velocity.z = velocity.z;
|
|
32
|
+
entity.transformStore.dirty.velocity = true;
|
|
33
|
+
const facingDirection = normalizeDirection2D(input.faceX, input.faceY);
|
|
34
|
+
if (facingDirection) {
|
|
35
|
+
state.facingAngle = angleFromDirection2D(facingDirection);
|
|
36
|
+
}
|
|
37
|
+
entity.setRotationZ?.(state.facingAngle);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// src/lib/behaviors/top-down-movement/top-down-movement.descriptor.ts
|
|
42
|
+
var defaultOptions = {
|
|
43
|
+
moveSpeed: 8
|
|
44
|
+
};
|
|
45
|
+
var TOP_DOWN_MOVEMENT_BEHAVIOR_KEY = /* @__PURE__ */ Symbol.for(
|
|
46
|
+
"zylem:behavior:top-down-movement"
|
|
47
|
+
);
|
|
48
|
+
function createTopDownMovementHandle(ref) {
|
|
49
|
+
return {
|
|
50
|
+
getFacingAngle: () => ref.__entity?.topDownMovementState?.facingAngle ?? 0
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
var TopDownMovementBehaviorSystem = class {
|
|
54
|
+
constructor(wasmStage, getBehaviorLinks) {
|
|
55
|
+
this.wasmStage = wasmStage;
|
|
56
|
+
this.getBehaviorLinks = getBehaviorLinks;
|
|
57
|
+
}
|
|
58
|
+
wasmStage;
|
|
59
|
+
getBehaviorLinks;
|
|
60
|
+
behavior = new TopDownMovementRuntimeBehavior();
|
|
61
|
+
attachedRuntimeSlots = /* @__PURE__ */ new Set();
|
|
62
|
+
update(_ecs, delta) {
|
|
63
|
+
const links = this.getBehaviorLinks?.(TOP_DOWN_MOVEMENT_BEHAVIOR_KEY);
|
|
64
|
+
if (!links) return;
|
|
65
|
+
for (const link of links) {
|
|
66
|
+
const entity = link.entity;
|
|
67
|
+
const ref = link.ref;
|
|
68
|
+
if (!entity.topDownMovement) {
|
|
69
|
+
entity.topDownMovement = createTopDownMovementComponent(ref.options);
|
|
70
|
+
}
|
|
71
|
+
if (!entity.$topDownMovement) {
|
|
72
|
+
entity.$topDownMovement = createTopDownMovementInputComponent();
|
|
73
|
+
}
|
|
74
|
+
if (!entity.topDownMovementState) {
|
|
75
|
+
entity.topDownMovementState = createTopDownMovementStateComponent();
|
|
76
|
+
}
|
|
77
|
+
ref.__entity = entity;
|
|
78
|
+
const handle = entity.runtimeHandle ?? -1;
|
|
79
|
+
if (this.wasmStage && handle >= 0) {
|
|
80
|
+
this.ensureWasmAttached(handle, ref.options);
|
|
81
|
+
const input = entity.$topDownMovement;
|
|
82
|
+
if (input) {
|
|
83
|
+
this.wasmStage.setTopDownInput(handle, input.moveX ?? 0, input.moveY ?? input.moveZ ?? 0);
|
|
84
|
+
}
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (!entity.body || !entity.transformStore) continue;
|
|
88
|
+
this.behavior.updateEntity(entity, delta);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
ensureWasmAttached(handle, options) {
|
|
92
|
+
if (!this.wasmStage || this.attachedRuntimeSlots.has(handle)) return;
|
|
93
|
+
this.wasmStage.attachTopDown(handle, {
|
|
94
|
+
plane: StageTopDownPlane.Xy,
|
|
95
|
+
speed: options.moveSpeed ?? defaultOptions.moveSpeed,
|
|
96
|
+
faceMovement: true
|
|
97
|
+
});
|
|
98
|
+
this.attachedRuntimeSlots.add(handle);
|
|
99
|
+
}
|
|
100
|
+
destroy(_ecs) {
|
|
101
|
+
this.attachedRuntimeSlots.clear();
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
var TopDownMovementBehavior = defineBehavior({
|
|
105
|
+
name: "top-down-movement",
|
|
106
|
+
defaultOptions,
|
|
107
|
+
systemFactory: (ctx) => new TopDownMovementBehaviorSystem(ctx.wasmStage ?? null, ctx.getBehaviorLinks),
|
|
108
|
+
createHandle: createTopDownMovementHandle
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
export {
|
|
112
|
+
TopDownMovementRuntimeBehavior,
|
|
113
|
+
TopDownMovementBehavior
|
|
114
|
+
};
|
|
115
|
+
//# sourceMappingURL=chunk-OYWFPIHF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/behaviors/top-down-movement/top-down-movement.behavior.ts","../src/lib/behaviors/top-down-movement/top-down-movement.descriptor.ts"],"sourcesContent":["import {\n\tangleFromDirection2D,\n\tnormalizeDirection2D,\n} from '../shared/direction-2d';\nimport type {\n\tTopDownMovementComponent,\n\tTopDownMovementInputComponent,\n\tTopDownMovementStateComponent,\n} from './components';\n\nexport interface TopDownMovementEntity {\n\tbody: {\n\t\tlinvel(): { x: number; y: number; z: number };\n\t};\n\ttransformStore?: {\n\t\tvelocity: { x: number; y: number; z: number };\n\t\tdirty: { velocity: boolean };\n\t};\n\tsetRotationZ?: (angle: number) => void;\n\ttopDownMovement: TopDownMovementComponent;\n\t$topDownMovement: TopDownMovementInputComponent;\n\ttopDownMovementState: TopDownMovementStateComponent;\n}\n\nexport class TopDownMovementRuntimeBehavior {\n\tupdateEntity(entity: TopDownMovementEntity, _delta: number): void {\n\t\tif (\n\t\t\t!entity.body\n\t\t\t|| !entity.transformStore\n\t\t\t|| !entity.topDownMovement\n\t\t\t|| !entity.$topDownMovement\n\t\t\t|| !entity.topDownMovementState\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst movement = entity.topDownMovement;\n\t\tconst input = entity.$topDownMovement;\n\t\tconst state = entity.topDownMovementState;\n\t\tconst moveDirection = normalizeDirection2D(input.moveX, input.moveY);\n\t\tconst velocity = entity.body.linvel();\n\n\t\tstate.moving = moveDirection !== null;\n\t\tentity.transformStore.velocity.x = (moveDirection?.x ?? 0) * movement.moveSpeed;\n\t\tentity.transformStore.velocity.y = (moveDirection?.y ?? 0) * movement.moveSpeed;\n\t\tentity.transformStore.velocity.z = velocity.z;\n\t\tentity.transformStore.dirty.velocity = true;\n\n\t\tconst facingDirection = normalizeDirection2D(input.faceX, input.faceY);\n\t\tif (facingDirection) {\n\t\t\tstate.facingAngle = angleFromDirection2D(facingDirection);\n\t\t}\n\n\t\tentity.setRotationZ?.(state.facingAngle);\n\t}\n}\n","import { defineBehavior, type BehaviorRef } from '../behavior-descriptor';\nimport type { BehaviorEntityLink, BehaviorSystem } from '../behavior-system';\nimport {\n\tcreateTopDownMovementComponent,\n\tcreateTopDownMovementInputComponent,\n\tcreateTopDownMovementStateComponent,\n} from './components';\nimport {\n\tTopDownMovementRuntimeBehavior,\n\ttype TopDownMovementEntity,\n} from './top-down-movement.behavior';\nimport {\n\tStageTopDownPlane,\n\ttype WasmStageRuntime,\n} from '../../runtime/wasm-stage-runtime';\n\nexport interface TopDownMovementBehaviorOptions {\n\tmoveSpeed?: number;\n}\n\nexport interface TopDownMovementHandle {\n\tgetFacingAngle(): number;\n}\n\nconst defaultOptions: TopDownMovementBehaviorOptions = {\n\tmoveSpeed: 8,\n};\n\nconst TOP_DOWN_MOVEMENT_BEHAVIOR_KEY = Symbol.for(\n\t'zylem:behavior:top-down-movement',\n);\n\nfunction createTopDownMovementHandle(\n\tref: BehaviorRef<TopDownMovementBehaviorOptions>,\n): TopDownMovementHandle {\n\treturn {\n\t\tgetFacingAngle: () =>\n\t\t\t(ref as any).__entity?.topDownMovementState?.facingAngle ?? 0,\n\t};\n}\n\nclass TopDownMovementBehaviorSystem implements BehaviorSystem {\n\tprivate behavior = new TopDownMovementRuntimeBehavior();\n\tprivate attachedRuntimeSlots = new Set<number>();\n\n\tconstructor(\n\t\tprivate wasmStage: WasmStageRuntime | null,\n\t\tprivate getBehaviorLinks?: (key: symbol) => Iterable<BehaviorEntityLink>,\n\t) {}\n\n\tupdate(_ecs: unknown, delta: number): void {\n\t\tconst links = this.getBehaviorLinks?.(TOP_DOWN_MOVEMENT_BEHAVIOR_KEY);\n\t\tif (!links) return;\n\n\t\tfor (const link of links) {\n\t\t\tconst entity = link.entity as any;\n\t\t\tconst ref = link.ref as any;\n\n\t\t\tif (!entity.topDownMovement) {\n\t\t\t\tentity.topDownMovement = createTopDownMovementComponent(ref.options);\n\t\t\t}\n\t\t\tif (!entity.$topDownMovement) {\n\t\t\t\tentity.$topDownMovement = createTopDownMovementInputComponent();\n\t\t\t}\n\t\t\tif (!entity.topDownMovementState) {\n\t\t\t\tentity.topDownMovementState = createTopDownMovementStateComponent();\n\t\t\t}\n\n\t\t\tref.__entity = entity;\n\n\t\t\tconst handle = (entity.runtimeHandle ?? -1) as number;\n\t\t\tif (this.wasmStage && handle >= 0) {\n\t\t\t\tthis.ensureWasmAttached(handle, ref.options as TopDownMovementBehaviorOptions);\n\t\t\t\tconst input = entity.$topDownMovement;\n\t\t\t\tif (input) {\n\t\t\t\t\tthis.wasmStage.setTopDownInput(handle, input.moveX ?? 0, input.moveY ?? input.moveZ ?? 0);\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (!entity.body || !entity.transformStore) continue;\n\t\t\tthis.behavior.updateEntity(entity, delta);\n\t\t}\n\t}\n\n\tprivate ensureWasmAttached(handle: number, options: TopDownMovementBehaviorOptions): void {\n\t\tif (!this.wasmStage || this.attachedRuntimeSlots.has(handle)) return;\n\t\tthis.wasmStage.attachTopDown(handle, {\n\t\t\tplane: StageTopDownPlane.Xy,\n\t\t\tspeed: options.moveSpeed ?? defaultOptions.moveSpeed!,\n\t\t\tfaceMovement: true,\n\t\t});\n\t\tthis.attachedRuntimeSlots.add(handle);\n\t}\n\n\tdestroy(_ecs: unknown): void {\n\t\tthis.attachedRuntimeSlots.clear();\n\t}\n}\n\nexport const TopDownMovementBehavior = defineBehavior<\n\tTopDownMovementBehaviorOptions,\n\tTopDownMovementHandle,\n\tTopDownMovementEntity\n>({\n\tname: 'top-down-movement',\n\tdefaultOptions,\n\tsystemFactory: (ctx) =>\n\t\tnew TopDownMovementBehaviorSystem(ctx.wasmStage ?? null, ctx.getBehaviorLinks),\n\tcreateHandle: createTopDownMovementHandle,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;AAwBO,IAAM,iCAAN,MAAqC;AAAA,EAC3C,aAAa,QAA+B,QAAsB;AACjE,QACC,CAAC,OAAO,QACL,CAAC,OAAO,kBACR,CAAC,OAAO,mBACR,CAAC,OAAO,oBACR,CAAC,OAAO,sBACV;AACD;AAAA,IACD;AAEA,UAAM,WAAW,OAAO;AACxB,UAAM,QAAQ,OAAO;AACrB,UAAM,QAAQ,OAAO;AACrB,UAAM,gBAAgB,qBAAqB,MAAM,OAAO,MAAM,KAAK;AACnE,UAAM,WAAW,OAAO,KAAK,OAAO;AAEpC,UAAM,SAAS,kBAAkB;AACjC,WAAO,eAAe,SAAS,KAAK,eAAe,KAAK,KAAK,SAAS;AACtE,WAAO,eAAe,SAAS,KAAK,eAAe,KAAK,KAAK,SAAS;AACtE,WAAO,eAAe,SAAS,IAAI,SAAS;AAC5C,WAAO,eAAe,MAAM,WAAW;AAEvC,UAAM,kBAAkB,qBAAqB,MAAM,OAAO,MAAM,KAAK;AACrE,QAAI,iBAAiB;AACpB,YAAM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