Skip to main content

WorldBoundary2DFSM

@zylem/game-lib


@zylem/game-lib / behavior / WorldBoundary2DFSM

Class: WorldBoundary2DFSM

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/world-boundary-2d.d.ts:51

FSM wrapper with "extended state" (lastHits / lastPosition). Systems should call update(...) once per frame.

Constructors​

Constructor​

new WorldBoundary2DFSM(): WorldBoundary2DFSM

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/world-boundary-2d.d.ts:56

Returns​

WorldBoundary2DFSM

Properties​

machine​

readonly machine: SyncStateMachine<WorldBoundary2DState, WorldBoundary2DEvent, never>

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/world-boundary-2d.d.ts:52

Methods​

getLastHits()​

getLastHits(): WorldBoundary2DHits

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/world-boundary-2d.d.ts:61

Returns the last computed hits (always available after first update call).

Returns​

WorldBoundary2DHits


getLastPosition()​

getLastPosition(): WorldBoundary2DPosition | null

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/world-boundary-2d.d.ts:78

Returns the last position passed to update, if any.

Returns​

WorldBoundary2DPosition | null


getLastUpdatedAtMs()​

getLastUpdatedAtMs(): number | null

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/world-boundary-2d.d.ts:83

Best-effort timestamp (ms) of the last update(...) call. This is optional metadata; systems can ignore it.

Returns​

number | null


getMovement()​

getMovement(moveX, moveY): object

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/world-boundary-2d.d.ts:71

Returns adjusted movement values based on boundary hits. If the entity is touching a boundary and trying to move further into it, that axis component is zeroed out.

Parameters​

moveX​

number

The desired X movement

moveY​

number

The desired Y movement

Returns​

object

Adjusted { moveX, moveY } with boundary-blocked axes zeroed

moveX​

moveX: number

moveY​

moveY: number


getState()​

getState(): WorldBoundary2DState

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/world-boundary-2d.d.ts:57

Returns​

WorldBoundary2DState


update()​

update(position, bounds): WorldBoundary2DHits

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/world-boundary-2d.d.ts:88

Update FSM + extended state based on current position and bounds. Returns the computed hits for convenience.

Parameters​

position​

WorldBoundary2DPosition

bounds​

WorldBoundary2DBounds

Returns​

WorldBoundary2DHits