Skip to main content

useBehavior

@zylem/game-lib


@zylem/game-lib / behavior / useBehavior

Function: useBehavior()

useBehavior<E, O, H, I>(entity, descriptor, options?): E & I

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/components--RTwuT4S.d.ts:12

Type-safe helper to apply a behavior to an entity and return the entity cast to the behavior's interface.

Type Parameters​

E​

E extends GameEntity<any>

O​

O extends Record<string, any>

H​

H extends Record<string, any>

I​

I

Parameters​

entity​

E

The entity to apply the behavior to

descriptor​

BehaviorDescriptor<O, H, I>

The behavior descriptor

options?​

Partial<O>

Behavior options

Returns​

E & I

The entity, cast to E & I (where I is the behavior's interface)