cubeforge 0.3.16 → 0.4.1

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +549 -20
  2. package/dist/index.js +10806 -1766
  3. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -1,19 +1,19 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as React from 'react';
3
3
  import React__default, { CSSProperties, ReactNode, ReactElement } from 'react';
4
- import { Plugin, EntityId, ECSWorld, ScriptUpdateFn, NavGrid, WorldSnapshot, EventBus } from '@cubeforge/core';
5
- export { AssetProgress, Component, ECSWorld, Ease, EntityId, GameTimer, HotReloadablePlugin, MergedRect, NavGrid, Plugin, PreloadManifest, ScriptUpdateFn, TimelineEntry, TransformComponent, TweenHandle, TweenTimeline, Vec2Like, WorldSnapshot, arrive, createTag, createTimeline, createTimer, createTransform, definePlugin, findByTag, flee, hotReloadPlugin, mergeTileColliders, patrol, preloadManifest, seek, tween, wander } from '@cubeforge/core';
6
- import { Sampling, BlendMode, AnimatorStateDefinition, AnimatorParamValue, PostProcessEffect } from '@cubeforge/renderer';
7
- export { AnimationClipDefinition, AnimationStateComponent, AnimatorComponent, AnimatorCondition, AnimatorParamValue, AnimatorStateDefinition, AnimatorTransition, BlendMode, MagFilterValue, NineSliceComponent, ParallaxLayerComponent, Particle, ParticlePoolComponent, PostProcessEffect, PostProcessStack, RenderLayer, RenderLayerManager, RenderSystem, Sampling, SpriteComponent, SquashStretchComponent, TextComponent, TextureFilter, TextureFilterValue, TrailComponent, chromaticAberrationEffect, createNineSlice, createPostProcessStack, createRenderLayerManager, createSprite, defaultLayers, scanlineEffect, vignetteEffect } from '@cubeforge/renderer';
8
- import { ColliderShape } from '@cubeforge/physics';
9
- export { BoxColliderComponent, CapsuleColliderComponent, CircleColliderComponent, ColliderShape, CompoundColliderComponent, RaycastHit, RigidBodyComponent, createCompoundCollider, overlapBox, overlapCircle, raycast, raycastAll, sweepBox } from '@cubeforge/physics';
10
- import { InputManager, ActionBindings, InputContextName, PlayerInput, InputRecorderControls } from '@cubeforge/input';
11
- export { ActionBindings, AxisBinding, InputContextName, InputManager, InputMap, InputRecorderControls, InputRecording, InputRecording as InputRecordingData, PlayerInput, createInputMap, createInputRecorder, createPlayerInput, globalInputContext } from '@cubeforge/input';
4
+ import { Plugin, EntityId, ECSWorld, ScriptUpdateFn, NavGrid, WorldSnapshot, EventBus, AccessibilityOptions } from '@cubeforge/core';
5
+ export { AccessibilityOptions, AssetProgress, Component, ECSWorld, Ease, EntityId, GameTimer, HierarchyComponent, HierarchySystem, HotReloadablePlugin, MergedRect, NavGrid, Plugin, PreloadManifest, ScriptUpdateFn, SpatialHash, TimelineEntry, TransformComponent, TweenHandle, TweenTimeline, Vec2Like, WorldSnapshot, WorldTransformComponent, announceToScreenReader, arrive, createHierarchy, createTag, createTimeline, createTimer, createTransform, definePlugin, findByTag, flee, getAccessibilityOptions, getDescendants, hmrClearState, hmrLoadState, hmrSaveState, hotReloadPlugin, mergeTileColliders, patrol, preloadManifest, removeParent, seek, setAccessibilityOptions, setParent, tween, wander } from '@cubeforge/core';
6
+ import { Sampling, BlendMode, AnimatorStateDefinition, AnimatorParamValue, GradientType, GradientStop, MaskShape, PostProcessEffect } from '@cubeforge/renderer';
7
+ export { AnimationClipDefinition, AnimationStateComponent, AnimatorComponent, AnimatorCondition, AnimatorParamValue, AnimatorStateDefinition, AnimatorTransition, BlendMode, CircleShapeComponent, GradientComponent, GradientStop, GradientType, LineShapeComponent, MagFilterValue, MaskComponent, MaskShape, NineSliceComponent, ParallaxLayerComponent, Particle, ParticlePoolComponent, PolygonShapeComponent, PostProcessEffect, PostProcessStack, RenderLayer, RenderLayerManager, RenderSystem, Sampling, SpriteComponent, SquashStretchComponent, TextComponent, TextureFilter, TextureFilterValue, TrailComponent, chromaticAberrationEffect, createCircleShape, createGradient, createLineShape, createMask, createNineSlice, createPolygonShape, createPostProcessStack, createRenderLayerManager, createSprite, defaultLayers, scanlineEffect, vignetteEffect } from '@cubeforge/renderer';
8
+ import { CombineRule, ColliderShape, JointType } from '@cubeforge/physics';
9
+ export { AxisLock, BVH, BoxColliderComponent, BroadPhaseAABB, BroadPhasePair, COLLISION_DYNAMIC_DYNAMIC, COLLISION_DYNAMIC_KINEMATIC, COLLISION_DYNAMIC_STATIC, COLLISION_KINEMATIC_KINEMATIC, COLLISION_KINEMATIC_STATIC, CapsuleColliderComponent, CharacterCollision, CharacterController, CharacterControllerConfig, CircleColliderComponent, ColliderShape, CollisionPair, CollisionPipeline, CollisionPipelineResult, CombineRule, CompoundColliderComponent, ContactManifold, ContactPoint, ConvexPolygonColliderComponent, ConvexShape, DEFAULT_ACTIVE_COLLISION_TYPES, DebugCircle, DebugLine, DebugPoint, DebugRenderBackend, DebugRenderColors, DebugRenderFlags, DebugRenderOutput, DebugRenderPipeline, EPAResult, Float64Pool, GJKContactManifold, GJKResult, HalfSpaceColliderComponent, HeightFieldColliderComponent, Island, IslandDetector, JointComponent, JointMotor, JointSnapshot, JointType, KahanSum, MotorMode, MoveResult, MultibodyArticulation, MultibodyLink, PhysicsBodySnapshot, PhysicsHooks, ObjectPool as PhysicsObjectPool, PhysicsSnapshot, PointProjection, QueryOpts, QueryShape, RaycastHit, RigidBodyComponent, SegmentColliderComponent, Spatial3, SpatialInertia3, SweepAndPrune, TOIBody, TOIResult, TriMeshColliderComponent, Triangle2D, TriangleColliderComponent, addForce, addForceAtPoint, addTorque, applyImpulse, applyImpulseAtPoint, applyTorqueImpulse, boxArea, boxShape, buildBVH, capsuleArea, capsuleShape, circleArea, circleShape, computeTOI, containsPoint, createCompoundCollider, createConvexPolygonCollider, createHalfSpaceCollider, createHeightFieldCollider, createJoint, createLink, createMultibody, createSegmentCollider, createTriMeshCollider, createTriangleCollider, dMath, deterministicAtan2, deterministicCos, deterministicSin, deterministicSqrt, epa, generateDeterministicPairs, gjk, gjkEpaQuery, intersectAABB, intersectRay, intersectShape, isDeterministicMode, kineticEnergy, overlapBox, overlapCircle, pairKey, polygonArea, polygonMassProperties, polygonShape, potentialEnergy, predictPosition, projectPoint, queryBVH, queryBVHCircle, raycast, raycastAll, recomputeMassFromColliders, resetAllPools, resetForces, resetTorques, resolveTOI, restoreSnapshot, setAdditionalMass, setDeterministicMode, setMassProperties, setNextKinematicPosition, setNextKinematicRotation, shapeCast, snapshotFromBytes, snapshotFromJSON, snapshotHash, snapshotToBytes, snapshotToJSON, sortEntities, sweepBox, takeSnapshot, triangleArea, triangleMassProperties, velocityAtPoint } from '@cubeforge/physics';
10
+ import { InputManager, ActionBindings, InputContextName, PlayerInput, InputRecorderControls, TouchPoint, InputBufferOptions, InputBuffer, ComboDefinition } from '@cubeforge/input';
11
+ export { ActionBindings, AxisBinding, BufferedAction, ComboDefinition, ComboDetector, ComboDetectorOptions, InputBuffer, InputBufferOptions, InputContextName, InputManager, InputMap, InputRecorderControls, InputRecording, InputRecording as InputRecordingData, PlayerInput, TouchPoint, createInputMap, createInputRecorder, createPlayerInput, globalInputContext } from '@cubeforge/input';
12
12
  import { AnimationClip } from '@cubeforge/gameplay';
13
- export { AISteering, AnimationClip, AnimationControllerResult, BindingControls, CutsceneControls, CutsceneStep, DialogueControls, DialogueLine, DialogueScript, GameState as GameStateDefinition, GameStateMachineResult, HealthControls, HealthOptions, KinematicBodyControls, LevelTransitionControls, ObjectPool, PathfindingControls, PlatformerControllerOptions, RestartControls, SaveControls, SaveOptions, TopDownMovementOptions, TransitionOptions, TransitionType, TweenControls, useAISteering, useAnimationController, useCutscene, useDamageZone, useDialogue, useDropThrough, useGameStateMachine, useGameStore, useHealth, useKinematicBody, useLevelTransition, useObjectPool, usePathfinding, usePersistedBindings, usePlatformerController, useRestart, useSave, useTopDownMovement, useTween } from '@cubeforge/gameplay';
13
+ export { AISteering, AnimationClip, AnimationControllerResult, BindingControls, CharacterControls, CutsceneControls, CutsceneStep, DialogueControls, DialogueLine, DialogueScript, ForceControls, GameState as GameStateDefinition, GameStateMachineResult, HealthControls, HealthOptions, KinematicBodyControls, LevelTransitionControls, ObjectPool, PathfindingControls, PlatformerControllerOptions, RestartControls, SaveControls, SaveOptions, TopDownMovementOptions, TransitionOptions, TransitionType, TweenControls, useAISteering, useAnimationController, useCharacterController, useCutscene, useDamageZone, useDialogue, useDropThrough, useForces, useGameStateMachine, useGameStore, useHealth, useKinematicBody, useLevelTransition, useObjectPool, usePathfinding, usePersistedBindings, usePlatformerController, useRestart, useSave, useTopDownMovement, useTween } from '@cubeforge/gameplay';
14
14
  import { EngineState } from '@cubeforge/context';
15
15
  export { EngineState, useCircleEnter, useCircleExit, useCircleStay, useCollidingWith, useCollisionEnter, useCollisionExit, useCollisionStay, useTriggerEnter, useTriggerExit, useTriggerStay } from '@cubeforge/context';
16
- export { AudioGroup, SoundControls, duck, getGroupVolume, setGroupMute, setGroupVolume, setMasterVolume, stopGroup, useSound } from '@cubeforge/audio';
16
+ export { AudioGroup, SoundControls, SpatialSoundControls, SpatialSoundOptions, duck, getGroupVolume, getListenerPosition, setGroupMute, setGroupVolume, setListenerPosition, setMasterVolume, stopGroup, useSound, useSpatialSound } from '@cubeforge/audio';
17
17
  export { DevToolsHandle } from '@cubeforge/devtools';
18
18
 
19
19
  interface GameControls {
@@ -129,8 +129,12 @@ interface SpriteProps {
129
129
  blendMode?: BlendMode;
130
130
  /** Render layer name — sprites are sorted by layer order first, then zIndex */
131
131
  layer?: string;
132
+ /** Color tint applied on top of the image (multiplied). e.g. '#ff0000' for red tint */
133
+ tint?: string;
134
+ /** Tint opacity 0-1 */
135
+ tintOpacity?: number;
132
136
  }
133
- declare function Sprite({ width, height, color, src, offsetX, offsetY, zIndex, visible, flipX, flipY, anchorX, anchorY, frameIndex, frameWidth, frameHeight, frameColumns, atlas, frame, tileX, tileY, tileSizeX, tileSizeY, sampling, blendMode, layer, }: SpriteProps): null;
137
+ declare function Sprite({ width, height, color, src, offsetX, offsetY, zIndex, visible, flipX, flipY, anchorX, anchorY, frameIndex, frameWidth, frameHeight, frameColumns, atlas, frame, tileX, tileY, tileSizeX, tileSizeY, sampling, blendMode, layer, tint, tintOpacity, }: SpriteProps): null;
134
138
 
135
139
  interface TextProps {
136
140
  text: string;
@@ -144,14 +148,26 @@ interface TextProps {
144
148
  maxWidth?: number;
145
149
  offsetX?: number;
146
150
  offsetY?: number;
151
+ strokeColor?: string;
152
+ strokeWidth?: number;
153
+ shadowColor?: string;
154
+ shadowOffsetX?: number;
155
+ shadowOffsetY?: number;
156
+ shadowBlur?: number;
157
+ wordWrap?: boolean;
158
+ lineHeight?: number;
159
+ opacity?: number;
147
160
  }
148
- declare function Text({ text, fontSize, fontFamily, color, align, baseline, zIndex, visible, maxWidth, offsetX, offsetY, }: TextProps): null;
161
+ declare function Text({ text, fontSize, fontFamily, color, align, baseline, zIndex, visible, maxWidth, offsetX, offsetY, strokeColor, strokeWidth, shadowColor, shadowOffsetX, shadowOffsetY, shadowBlur, wordWrap, lineHeight, opacity, }: TextProps): null;
149
162
 
150
163
  interface RigidBodyProps {
164
+ /** Explicit mass. 0 (default) auto-computes from density × collider area */
151
165
  mass?: number;
152
166
  gravityScale?: number;
153
167
  isStatic?: boolean;
168
+ /** @deprecated Use restitution on BoxCollider/CircleCollider instead */
154
169
  bounce?: number;
170
+ /** @deprecated Use friction on BoxCollider/CircleCollider instead */
155
171
  friction?: number;
156
172
  vx?: number;
157
173
  vy?: number;
@@ -159,6 +175,8 @@ interface RigidBodyProps {
159
175
  lockX?: boolean;
160
176
  /** Prevent any vertical movement — velocity.y is zeroed every frame (disables gravity) */
161
177
  lockY?: boolean;
178
+ /** Lock rotation — angular velocity stays 0 */
179
+ lockRotation?: boolean;
162
180
  /** Enable continuous collision detection to prevent tunneling through thin colliders */
163
181
  ccd?: boolean;
164
182
  /** Angular velocity in radians per second */
@@ -167,8 +185,24 @@ interface RigidBodyProps {
167
185
  angularDamping?: number;
168
186
  /** Linear damping (0–1): velocity reduction applied every fixed step (air resistance) */
169
187
  linearDamping?: number;
188
+ /** Density for auto-computing mass (mass = density × area). Default 1.0 */
189
+ density?: number;
190
+ /** Coefficient of restitution for this body (0 = no bounce, 1 = full bounce) */
191
+ restitution?: number;
192
+ /** Dominance group (-127 to 127). Higher dominance acts as infinite mass in contacts */
193
+ dominance?: number;
194
+ /** Kinematic bodies skip gravity/integration but resolve collisions without impulse response */
195
+ isKinematic?: boolean;
196
+ /** Whether this body is enabled. Disabled bodies are completely skipped */
197
+ enabled?: boolean;
198
+ /** Max linear velocity magnitude. 0 = unlimited */
199
+ maxLinearVelocity?: number;
200
+ /** Max angular velocity magnitude. 0 = unlimited */
201
+ maxAngularVelocity?: number;
202
+ /** Extra velocity solver iterations for constraints involving this body. Default 0 */
203
+ additionalSolverIterations?: number;
170
204
  }
171
- declare function RigidBody({ mass, gravityScale, isStatic, bounce, friction, vx, vy, lockX, lockY, ccd, angularVelocity, angularDamping, linearDamping, }: RigidBodyProps): null;
205
+ declare function RigidBody({ mass, gravityScale, isStatic, bounce, friction, vx, vy, lockX, lockY, lockRotation, ccd, angularVelocity, angularDamping, linearDamping, density, restitution, dominance, isKinematic, enabled, maxLinearVelocity, maxAngularVelocity, additionalSolverIterations, }: RigidBodyProps): null;
172
206
 
173
207
  interface BoxColliderProps {
174
208
  width: number;
@@ -184,8 +218,18 @@ interface BoxColliderProps {
184
218
  * Entities below pass through freely (useful for jump-through ledges).
185
219
  */
186
220
  oneWay?: boolean;
221
+ /** Per-collider friction coefficient (0–1). Default 0.5 */
222
+ friction?: number;
223
+ /** Per-collider restitution (bounciness) coefficient (0–1). Default 0.0 */
224
+ restitution?: number;
225
+ /** How to combine friction with the other collider. Default 'average' */
226
+ frictionCombineRule?: CombineRule;
227
+ /** How to combine restitution with the other collider. Default 'average' */
228
+ restitutionCombineRule?: CombineRule;
229
+ /** Whether this collider is enabled. Disabled colliders skip all detection */
230
+ enabled?: boolean;
187
231
  }
188
- declare function BoxCollider({ width, height, offsetX, offsetY, isTrigger, layer, mask, oneWay, }: BoxColliderProps): null;
232
+ declare function BoxCollider({ width, height, offsetX, offsetY, isTrigger, layer, mask, oneWay, friction, restitution, frictionCombineRule, restitutionCombineRule, enabled, }: BoxColliderProps): null;
189
233
 
190
234
  interface CircleColliderProps {
191
235
  radius: number;
@@ -195,8 +239,18 @@ interface CircleColliderProps {
195
239
  layer?: string;
196
240
  /** Which layers this collider interacts with. '*' = all (default). */
197
241
  mask?: string | string[];
242
+ /** Per-collider friction coefficient (0–1). Default 0.5 */
243
+ friction?: number;
244
+ /** Per-collider restitution (bounciness) coefficient (0–1). Default 0.0 */
245
+ restitution?: number;
246
+ /** How to combine friction with the other collider. Default 'average' */
247
+ frictionCombineRule?: CombineRule;
248
+ /** How to combine restitution with the other collider. Default 'average' */
249
+ restitutionCombineRule?: CombineRule;
250
+ /** Whether this collider is enabled. Disabled colliders skip all detection */
251
+ enabled?: boolean;
198
252
  }
199
- declare function CircleCollider({ radius, offsetX, offsetY, isTrigger, layer, mask, }: CircleColliderProps): null;
253
+ declare function CircleCollider({ radius, offsetX, offsetY, isTrigger, layer, mask, friction, restitution, frictionCombineRule, restitutionCombineRule, enabled, }: CircleColliderProps): null;
200
254
 
201
255
  interface CapsuleColliderProps {
202
256
  width: number;
@@ -206,8 +260,13 @@ interface CapsuleColliderProps {
206
260
  isTrigger?: boolean;
207
261
  layer?: string;
208
262
  mask?: string | string[];
263
+ friction?: number;
264
+ restitution?: number;
265
+ frictionCombineRule?: CombineRule;
266
+ restitutionCombineRule?: CombineRule;
267
+ enabled?: boolean;
209
268
  }
210
- declare function CapsuleCollider({ width, height, offsetX, offsetY, isTrigger, layer, mask, }: CapsuleColliderProps): null;
269
+ declare function CapsuleCollider({ width, height, offsetX, offsetY, isTrigger, layer, mask, friction, restitution, frictionCombineRule, restitutionCombineRule, enabled, }: CapsuleColliderProps): null;
211
270
 
212
271
  interface CompoundColliderProps {
213
272
  shapes: ColliderShape[];
@@ -216,7 +275,7 @@ interface CompoundColliderProps {
216
275
  /** Which layers this collider interacts with. '*' = all (default). */
217
276
  mask?: string | string[];
218
277
  }
219
- declare function CompoundCollider({ shapes, isTrigger, layer, mask, }: CompoundColliderProps): null;
278
+ declare function CompoundCollider({ shapes, isTrigger, layer, mask }: CompoundColliderProps): null;
220
279
 
221
280
  interface ScriptProps {
222
281
  /** Called once when the entity is mounted — use to attach extra components */
@@ -426,8 +485,28 @@ interface ParticleEmitterProps {
426
485
  emitWidth?: number;
427
486
  /** Height for 'box' emission shape */
428
487
  emitHeight?: number;
488
+ /** Sprite/texture source for particles (if undefined, renders as colored rect) */
489
+ textureSrc?: string;
490
+ /** Enable particle rotation. Default false */
491
+ enableRotation?: boolean;
492
+ /** Random rotation speed range [min, max] in radians/s */
493
+ rotationSpeedRange?: [number, number];
494
+ /** Size over lifetime: start and end size. If set, overrides particleSize */
495
+ sizeOverLife?: {
496
+ start: number;
497
+ end: number;
498
+ };
499
+ /** Attractor points that pull particles toward them */
500
+ attractors?: Array<{
501
+ x: number;
502
+ y: number;
503
+ strength: number;
504
+ radius: number;
505
+ }>;
506
+ /** Color over lifetime: array of colors to interpolate through */
507
+ colorOverLife?: string[];
429
508
  }
430
- declare function ParticleEmitter({ active, preset, rate, speed, spread, angle, particleLife, particleSize, color, gravity, maxParticles, burstCount, emitShape, emitRadius, emitWidth, emitHeight, }: ParticleEmitterProps): null;
509
+ declare function ParticleEmitter({ active, preset, rate, speed, spread, angle, particleLife, particleSize, color, gravity, maxParticles, burstCount, emitShape, emitRadius, emitWidth, emitHeight, textureSrc, enableRotation, rotationSpeedRange, sizeOverLife, attractors, colorOverLife, }: ParticleEmitterProps): null;
431
510
 
432
511
  interface VirtualJoystickProps {
433
512
  /** Diameter of the joystick base in pixels (default 120) */
@@ -643,7 +722,7 @@ interface CameraZoneProps {
643
722
  * <CameraZone x={500} y={300} width={200} height={150} watchTag="player" />
644
723
  * ```
645
724
  */
646
- declare function CameraZone({ x, y, width, height, watchTag, targetX, targetY, children, }: CameraZoneProps): react_jsx_runtime.JSX.Element;
725
+ declare function CameraZone({ x, y, width, height, watchTag, targetX, targetY, children }: CameraZoneProps): react_jsx_runtime.JSX.Element;
647
726
 
648
727
  interface TrailProps {
649
728
  /** Maximum number of trail points (default 20) */
@@ -740,6 +819,204 @@ interface AssetLoaderProps {
740
819
  */
741
820
  declare function AssetLoader({ assets, fallback, onError, children }: AssetLoaderProps): react_jsx_runtime.JSX.Element;
742
821
 
822
+ interface CircleProps {
823
+ radius?: number;
824
+ color?: string;
825
+ strokeColor?: string;
826
+ strokeWidth?: number;
827
+ zIndex?: number;
828
+ opacity?: number;
829
+ }
830
+ declare function Circle({ radius, color, strokeColor, strokeWidth, zIndex, opacity, }: CircleProps): null;
831
+
832
+ interface LineProps {
833
+ endX: number;
834
+ endY: number;
835
+ color?: string;
836
+ lineWidth?: number;
837
+ zIndex?: number;
838
+ opacity?: number;
839
+ lineCap?: CanvasLineCap;
840
+ }
841
+ declare function Line({ endX, endY, color, lineWidth, zIndex, opacity, lineCap, }: LineProps): null;
842
+
843
+ interface PolygonProps {
844
+ points: {
845
+ x: number;
846
+ y: number;
847
+ }[];
848
+ color?: string;
849
+ strokeColor?: string;
850
+ strokeWidth?: number;
851
+ zIndex?: number;
852
+ opacity?: number;
853
+ closed?: boolean;
854
+ }
855
+ declare function Polygon({ points, color, strokeColor, strokeWidth, zIndex, opacity, closed, }: PolygonProps): null;
856
+
857
+ interface GradientProps {
858
+ gradientType?: GradientType;
859
+ stops: GradientStop[];
860
+ /** For linear: angle in radians (0 = left to right) */
861
+ angle?: number;
862
+ /** For radial: inner radius ratio (0-1) */
863
+ innerRadius?: number;
864
+ width: number;
865
+ height: number;
866
+ zIndex?: number;
867
+ visible?: boolean;
868
+ anchorX?: number;
869
+ anchorY?: number;
870
+ }
871
+ declare function Gradient({ gradientType, stops, angle, innerRadius, width, height, zIndex, visible, anchorX, anchorY, }: GradientProps): null;
872
+
873
+ interface MaskProps {
874
+ shape?: MaskShape;
875
+ width?: number;
876
+ height?: number;
877
+ radius?: number;
878
+ inverted?: boolean;
879
+ }
880
+ /**
881
+ * Clips the parent entity's sprite to a shape.
882
+ *
883
+ * @example
884
+ * <Entity>
885
+ * <Transform x={100} y={100} />
886
+ * <Sprite src="/health-bar-bg.png" width={200} height={20} />
887
+ * <Mask shape="rect" width={120} height={20} />
888
+ * </Entity>
889
+ */
890
+ declare function Mask({ shape, width, height, radius, inverted }: MaskProps): null;
891
+
892
+ interface JointProps {
893
+ type: JointType;
894
+ /** Entity ID of the connected entity */
895
+ target: string;
896
+ anchorA?: {
897
+ x: number;
898
+ y: number;
899
+ };
900
+ anchorB?: {
901
+ x: number;
902
+ y: number;
903
+ };
904
+ length?: number;
905
+ stiffness?: number;
906
+ damping?: number;
907
+ maxLength?: number;
908
+ }
909
+ declare function Joint({ type, target, anchorA, anchorB, length, stiffness, damping, maxLength }: JointProps): null;
910
+
911
+ interface ConvexColliderProps {
912
+ /** Vertices in CCW order (max 8 for performance). Positions relative to entity center. */
913
+ vertices: {
914
+ x: number;
915
+ y: number;
916
+ }[];
917
+ offsetX?: number;
918
+ offsetY?: number;
919
+ isTrigger?: boolean;
920
+ layer?: string;
921
+ mask?: string | string[];
922
+ friction?: number;
923
+ restitution?: number;
924
+ frictionCombineRule?: CombineRule;
925
+ restitutionCombineRule?: CombineRule;
926
+ enabled?: boolean;
927
+ }
928
+ declare function ConvexCollider({ vertices, offsetX, offsetY, isTrigger, layer, mask, friction, restitution, frictionCombineRule, restitutionCombineRule, enabled, }: ConvexColliderProps): null;
929
+
930
+ interface TriangleColliderProps {
931
+ a: {
932
+ x: number;
933
+ y: number;
934
+ };
935
+ b: {
936
+ x: number;
937
+ y: number;
938
+ };
939
+ c: {
940
+ x: number;
941
+ y: number;
942
+ };
943
+ offsetX?: number;
944
+ offsetY?: number;
945
+ isTrigger?: boolean;
946
+ layer?: string;
947
+ mask?: string | string[];
948
+ friction?: number;
949
+ restitution?: number;
950
+ frictionCombineRule?: CombineRule;
951
+ restitutionCombineRule?: CombineRule;
952
+ enabled?: boolean;
953
+ }
954
+ declare function TriangleCollider({ a, b, c, offsetX, offsetY, isTrigger, layer, mask, friction, restitution, frictionCombineRule, restitutionCombineRule, enabled, }: TriangleColliderProps): null;
955
+
956
+ interface SegmentColliderProps {
957
+ start: {
958
+ x: number;
959
+ y: number;
960
+ };
961
+ end: {
962
+ x: number;
963
+ y: number;
964
+ };
965
+ isTrigger?: boolean;
966
+ layer?: string;
967
+ mask?: string | string[];
968
+ oneWay?: boolean;
969
+ friction?: number;
970
+ restitution?: number;
971
+ frictionCombineRule?: CombineRule;
972
+ restitutionCombineRule?: CombineRule;
973
+ enabled?: boolean;
974
+ }
975
+ declare function SegmentCollider({ start, end, isTrigger, layer, mask, oneWay, friction, restitution, frictionCombineRule, restitutionCombineRule, enabled, }: SegmentColliderProps): null;
976
+
977
+ interface HeightFieldColliderProps {
978
+ heights: number[];
979
+ scaleX?: number;
980
+ scaleY?: number;
981
+ layer?: string;
982
+ mask?: string | string[];
983
+ friction?: number;
984
+ restitution?: number;
985
+ frictionCombineRule?: CombineRule;
986
+ restitutionCombineRule?: CombineRule;
987
+ enabled?: boolean;
988
+ }
989
+ declare function HeightFieldCollider({ heights, scaleX, scaleY, layer, mask, friction, restitution, frictionCombineRule, restitutionCombineRule, enabled, }: HeightFieldColliderProps): null;
990
+
991
+ interface HalfSpaceColliderProps {
992
+ normalX?: number;
993
+ normalY?: number;
994
+ layer?: string;
995
+ mask?: string | string[];
996
+ friction?: number;
997
+ restitution?: number;
998
+ frictionCombineRule?: CombineRule;
999
+ restitutionCombineRule?: CombineRule;
1000
+ enabled?: boolean;
1001
+ }
1002
+ declare function HalfSpaceCollider({ normalX, normalY, layer, mask, friction, restitution, frictionCombineRule, restitutionCombineRule, enabled, }: HalfSpaceColliderProps): null;
1003
+
1004
+ interface TriMeshColliderProps {
1005
+ vertices: {
1006
+ x: number;
1007
+ y: number;
1008
+ }[];
1009
+ indices: number[];
1010
+ layer?: string;
1011
+ mask?: string | string[];
1012
+ friction?: number;
1013
+ restitution?: number;
1014
+ frictionCombineRule?: CombineRule;
1015
+ restitutionCombineRule?: CombineRule;
1016
+ enabled?: boolean;
1017
+ }
1018
+ declare function TriMeshCollider({ vertices, indices, layer, mask, friction, restitution, frictionCombineRule, restitutionCombineRule, enabled, }: TriMeshColliderProps): null;
1019
+
743
1020
  declare function useGame(): EngineState;
744
1021
 
745
1022
  interface CameraControls {
@@ -1130,6 +1407,258 @@ declare function useProfiler(): ProfilerData;
1130
1407
  */
1131
1408
  declare function usePostProcess(effect: PostProcessEffect): void;
1132
1409
 
1410
+ interface TouchControls {
1411
+ /** All currently active touches */
1412
+ touches: TouchPoint[];
1413
+ /** Touches that started this frame */
1414
+ justStarted: TouchPoint[];
1415
+ /** Touches that ended this frame */
1416
+ justEnded: TouchPoint[];
1417
+ /** Number of active touches */
1418
+ count: number;
1419
+ /** Whether any touch is active */
1420
+ isTouching: boolean;
1421
+ }
1422
+ declare function useTouch(): TouchControls;
1423
+
1424
+ interface TimerControls {
1425
+ /** Start/restart the timer */
1426
+ start(): void;
1427
+ /** Stop the timer */
1428
+ stop(): void;
1429
+ /** Reset timer to initial duration */
1430
+ reset(): void;
1431
+ /** Whether the timer is currently running */
1432
+ readonly isRunning: boolean;
1433
+ /** Remaining time in seconds */
1434
+ readonly remaining: number;
1435
+ /** Elapsed time since start in seconds */
1436
+ readonly elapsed: number;
1437
+ /** Progress 0-1 (0 = just started, 1 = finished) */
1438
+ readonly progress: number;
1439
+ }
1440
+ /**
1441
+ * Game-loop aware timer that integrates with the engine's update cycle.
1442
+ *
1443
+ * @param duration - Timer duration in seconds
1444
+ * @param onComplete - Called when timer reaches 0
1445
+ * @param opts - { autoStart?: boolean, loop?: boolean }
1446
+ *
1447
+ * @example
1448
+ * const timer = useTimer(3, () => console.log('Done!'))
1449
+ * timer.start()
1450
+ */
1451
+ declare function useTimer(duration: number, onComplete?: () => void, opts?: {
1452
+ autoStart?: boolean;
1453
+ loop?: boolean;
1454
+ }): TimerControls;
1455
+
1456
+ type CoroutineGenerator = Generator<CoroutineYield, void, number>;
1457
+ type CoroutineFactory = () => CoroutineGenerator;
1458
+ /** What a coroutine can yield */
1459
+ type CoroutineYield = {
1460
+ type: 'wait';
1461
+ seconds: number;
1462
+ } | {
1463
+ type: 'waitFrames';
1464
+ frames: number;
1465
+ } | {
1466
+ type: 'waitUntil';
1467
+ condition: () => boolean;
1468
+ } | null;
1469
+ /** Convenience helpers for yielding */
1470
+ declare const wait: (seconds: number) => CoroutineYield;
1471
+ declare const waitFrames: (frames: number) => CoroutineYield;
1472
+ declare const waitUntil: (condition: () => boolean) => CoroutineYield;
1473
+ interface CoroutineControls {
1474
+ /** Start a coroutine. Returns an ID for cancellation. */
1475
+ start(factory: CoroutineFactory): number;
1476
+ /** Cancel a running coroutine by ID */
1477
+ cancel(id: number): void;
1478
+ /** Cancel all running coroutines */
1479
+ cancelAll(): void;
1480
+ /** Number of running coroutines */
1481
+ readonly activeCount: number;
1482
+ }
1483
+ /**
1484
+ * Unity-style coroutine system for sequencing game logic.
1485
+ *
1486
+ * @example
1487
+ * const co = useCoroutine()
1488
+ *
1489
+ * co.start(function* () {
1490
+ * sprite.color = '#ff0000'
1491
+ * yield wait(0.2)
1492
+ * sprite.color = '#ffffff'
1493
+ * yield waitFrames(10)
1494
+ * sprite.color = '#ff0000'
1495
+ * yield waitUntil(() => rb.onGround)
1496
+ * console.log('Landed!')
1497
+ * })
1498
+ */
1499
+ declare function useCoroutine(): CoroutineControls;
1500
+
1501
+ interface SceneManagerControls {
1502
+ /** Currently active scene (top of stack) */
1503
+ current: string;
1504
+ /** Full scene stack (bottom to top) */
1505
+ stack: string[];
1506
+ /** Push a scene onto the stack */
1507
+ push(scene: string): void;
1508
+ /** Pop the top scene. Returns the popped scene name or undefined if only one scene. */
1509
+ pop(): string | undefined;
1510
+ /** Replace the current scene */
1511
+ replace(scene: string): void;
1512
+ /** Replace the entire stack with a single scene */
1513
+ reset(scene: string): void;
1514
+ /** Check if a specific scene is in the stack */
1515
+ has(scene: string): boolean;
1516
+ }
1517
+ /**
1518
+ * Manages a stack of game scenes/screens.
1519
+ *
1520
+ * @example
1521
+ * const scenes = useSceneManager('gameplay')
1522
+ * // Push pause menu on top: scenes.push('pause')
1523
+ * // Pop back to gameplay: scenes.pop()
1524
+ * // Switch to game over: scenes.replace('gameOver')
1525
+ * // Reset to main menu: scenes.reset('mainMenu')
1526
+ *
1527
+ * // In render:
1528
+ * {scenes.current === 'gameplay' && <GameplayScene />}
1529
+ * {scenes.current === 'pause' && <PauseMenu onResume={() => scenes.pop()} />}
1530
+ */
1531
+ declare function useSceneManager(initialScene: string): SceneManagerControls;
1532
+
1533
+ /**
1534
+ * Returns a stable `InputBuffer` instance that persists across renders.
1535
+ *
1536
+ * Call `buffer.record(action)` when an action is pressed, and
1537
+ * `buffer.consume(action)` to check & consume a buffered input.
1538
+ * The buffer auto-prunes expired entries via `update()` — call it
1539
+ * once per frame (e.g., at the top of a `<Script update>`).
1540
+ *
1541
+ * @example
1542
+ * ```tsx
1543
+ * function Player() {
1544
+ * const buffer = useInputBuffer({ bufferWindow: 0.15 })
1545
+ *
1546
+ * return (
1547
+ * <Script update={(id, world, input, dt) => {
1548
+ * buffer.update()
1549
+ * if (input.justPressed('Space')) buffer.record('jump')
1550
+ * if (canJump && buffer.consume('jump')) doJump()
1551
+ * }} />
1552
+ * )
1553
+ * }
1554
+ * ```
1555
+ */
1556
+ declare function useInputBuffer(opts?: InputBufferOptions): InputBuffer;
1557
+
1558
+ interface ComboDetectorResult {
1559
+ /** Feed an action into the detector */
1560
+ feed(action: string): string | null;
1561
+ /** Clear history */
1562
+ clear(): void;
1563
+ /** Last detected combo name, or null */
1564
+ lastCombo: string | null;
1565
+ }
1566
+ /**
1567
+ * Returns a stable combo detector that tracks input sequences.
1568
+ *
1569
+ * Feed actions (e.g., from `input.justPressed`) each frame. When a
1570
+ * combo sequence is completed within the time window the combo name
1571
+ * is returned from `feed()` and stored in `lastCombo`.
1572
+ *
1573
+ * @example
1574
+ * ```tsx
1575
+ * const combos: ComboDefinition[] = [
1576
+ * { name: 'hadouken', sequence: ['down', 'forward', 'punch'], maxInterval: 0.3 },
1577
+ * ]
1578
+ *
1579
+ * function Fighter() {
1580
+ * const combo = useComboDetector(combos)
1581
+ *
1582
+ * return (
1583
+ * <Script update={(id, world, input, dt) => {
1584
+ * if (input.justPressed('ArrowDown')) combo.feed('down')
1585
+ * if (input.justPressed('ArrowRight')) combo.feed('forward')
1586
+ * if (input.justPressed('KeyZ')) combo.feed('punch')
1587
+ * if (combo.lastCombo === 'hadouken') { ... }
1588
+ * }} />
1589
+ * )
1590
+ * }
1591
+ * ```
1592
+ */
1593
+ declare function useComboDetector(combos: ComboDefinition[]): ComboDetectorResult;
1594
+
1595
+ /**
1596
+ * Establishes a parent-child hierarchy relationship between two entities.
1597
+ * On mount: calls setParent(world, child, parent).
1598
+ * On unmount: calls removeParent(world, child).
1599
+ *
1600
+ * Usage inside an <Entity> script or component:
1601
+ * ```tsx
1602
+ * const entityId = useEntity()
1603
+ * const engine = useGame()
1604
+ * const parentId = engine.entityIds.get('player')!
1605
+ * useParent(entityId, parentId)
1606
+ * ```
1607
+ */
1608
+ declare function useParent(childEntityId: EntityId, parentEntityId: EntityId): void;
1609
+
1610
+ interface AccessibilityControls {
1611
+ options: Readonly<AccessibilityOptions>;
1612
+ setOptions(opts: Partial<AccessibilityOptions>): void;
1613
+ announce(text: string, priority?: 'polite' | 'assertive'): void;
1614
+ }
1615
+ declare function useAccessibility(): AccessibilityControls;
1616
+
1617
+ /**
1618
+ * Controls returned by {@link useHMR}.
1619
+ */
1620
+ interface HMRControls {
1621
+ /** Register a handler that serializes state before hot update */
1622
+ onDispose(handler: () => unknown): void;
1623
+ /** Register a handler that restores state after hot update */
1624
+ onAccept(handler: (prevState: unknown) => void): void;
1625
+ /** Whether this is a hot reload (vs initial load) */
1626
+ isHotReload: boolean;
1627
+ }
1628
+ /**
1629
+ * Hook that enables HMR-aware game development.
1630
+ * When a module is hot-updated, preserves game state instead of full reload.
1631
+ *
1632
+ * Uses the Vite `import.meta.hot` API under the hood; in production builds
1633
+ * (or bundlers without HMR support) the hook is a harmless no-op.
1634
+ *
1635
+ * @param hmrKey Optional stable key to identify this HMR slot. When omitted an
1636
+ * auto-incrementing id is used (stable across hot reloads because
1637
+ * the counter resets with each module re-evaluation).
1638
+ *
1639
+ * @example
1640
+ * ```tsx
1641
+ * function PlayerScript({ x, y }) {
1642
+ * const hmr = useHMR('player')
1643
+ *
1644
+ * // Serialize state on HMR dispose
1645
+ * hmr.onDispose(() => ({
1646
+ * health: playerHealth,
1647
+ * position: { x: transform.x, y: transform.y },
1648
+ * }))
1649
+ *
1650
+ * // Restore state on HMR accept
1651
+ * hmr.onAccept((prevState) => {
1652
+ * if (prevState) {
1653
+ * const s = prevState as { health: number }
1654
+ * playerHealth = s.health
1655
+ * }
1656
+ * })
1657
+ * }
1658
+ * ```
1659
+ */
1660
+ declare function useHMR(hmrKey?: string): HMRControls;
1661
+
1133
1662
  declare function playClip(world: ECSWorld, entityId: EntityId, clipName: string): void;
1134
1663
  declare function setAnimationState(world: ECSWorld, entityId: EntityId, stateName: string): void;
1135
1664
  declare function setAnimatorParam(world: ECSWorld, entityId: EntityId, name: string, value: AnimatorParamValue): void;
@@ -1159,4 +1688,4 @@ declare function setAnimatorParam(world: ECSWorld, entityId: EntityId, name: str
1159
1688
  */
1160
1689
  declare function definePrefab<D extends Record<string, unknown>>(name: string, defaults: D, render: (props: D) => ReactElement): React__default.FC<Partial<D>>;
1161
1690
 
1162
- export { AnimatedSprite, type AnimatedSpriteProps, Animation, type AnimationSet, Animator, AssetLoader, type BoundInputMap, BoxCollider, Camera2D, type CameraControls, CameraZone, CapsuleCollider, Checkpoint, CircleCollider, CompoundCollider, type CoordinateHelpers, Entity, Game, type GameControls, type GamepadState, type InputContextControls, MovingPlatform, NineSlice, ParallaxLayer, ParticleEmitter, type ParticlePreset, type PauseControls, type PreloadState, type ProfilerData, RigidBody, ScreenFlash, type ScreenFlashHandle, Script, type SnapshotControls, Sprite, type SpriteAtlas, SquashStretch, Text, type TiledLayer, type TiledObject, Tilemap, Trail, Transform, type VirtualInputState, VirtualJoystick, type VirtualJoystickProps, World, createAtlas, defineAnimations, definePrefab, playClip, setAnimationState, setAnimatorParam, useCamera, useCoordinates, useDestroyEntity, useEntity, useEvent, useEvents, useGame, useGamepad, useInput, useInputContext, useInputMap, useInputRecorder, useLocalMultiplayer, usePause, usePlayerInput, usePostProcess, usePreload, useProfiler, useSnapshot, useVirtualInput };
1691
+ export { type AccessibilityControls, AnimatedSprite, type AnimatedSpriteProps, Animation, type AnimationSet, Animator, AssetLoader, type BoundInputMap, BoxCollider, Camera2D, type CameraControls, CameraZone, CapsuleCollider, Checkpoint, Circle, CircleCollider, type ComboDetectorResult, CompoundCollider, ConvexCollider, type CoordinateHelpers, type CoroutineControls, type CoroutineFactory, type CoroutineYield, Entity, Game, type GameControls, type GamepadState, Gradient, type HMRControls, HalfSpaceCollider, HeightFieldCollider, type InputContextControls, Joint, Line, Mask, MovingPlatform, NineSlice, ParallaxLayer, ParticleEmitter, type ParticlePreset, type PauseControls, Polygon, type PreloadState, type ProfilerData, RigidBody, type SceneManagerControls, ScreenFlash, type ScreenFlashHandle, Script, SegmentCollider, type SnapshotControls, Sprite, type SpriteAtlas, SquashStretch, Text, type TiledLayer, type TiledObject, Tilemap, type TimerControls, type TouchControls, Trail, Transform, TriMeshCollider, TriangleCollider, type VirtualInputState, VirtualJoystick, type VirtualJoystickProps, World, createAtlas, defineAnimations, definePrefab, playClip, setAnimationState, setAnimatorParam, useAccessibility, useCamera, useComboDetector, useCoordinates, useCoroutine, useDestroyEntity, useEntity, useEvent, useEvents, useGame, useGamepad, useHMR, useInput, useInputBuffer, useInputContext, useInputMap, useInputRecorder, useLocalMultiplayer, useParent, usePause, usePlayerInput, usePostProcess, usePreload, useProfiler, useSceneManager, useSnapshot, useTimer, useTouch, useVirtualInput, wait, waitFrames, waitUntil };