incanto 0.7.1 → 0.8.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/bin/incanto-check.mjs +6 -4
- package/dist/2d.d.ts +91 -3
- package/dist/2d.js +4 -4
- package/dist/3d.d.ts +43 -4
- package/dist/3d.js +4 -4
- package/dist/{audio-player-C3bH_eZ5.d.ts → audio-player-Dyjg5k92.d.ts} +1 -1
- package/dist/audit-C6rMyict.js +58 -0
- package/dist/{behavior-q3cejJgs.d.ts → behavior-Bod1AyJS.d.ts} +31 -1
- package/dist/{create-game-rFulaS3s.js → create-game-66c4iYJE.js} +4 -5
- package/dist/{create-game-DuDkqnjl.js → create-game-BNDSbhy-.js} +4 -5
- package/dist/debug.d.ts +1 -1
- package/dist/{errors-BMFaY68Q.d.ts → errors-1dXlIwoR.d.ts} +7 -1
- package/dist/{gameplay-CDFgSG6z.js → gameplay-DPMgZk9W.js} +108 -1
- package/dist/gameplay.d.ts +44 -3
- package/dist/gameplay.js +2 -2
- package/dist/index.d.ts +151 -9
- package/dist/index.js +189 -4
- package/dist/{loader-DnLMMRy8.d.ts → loader-BcUDfNHn.d.ts} +1 -1
- package/dist/net.d.ts +46 -2
- package/dist/net.js +54 -2
- package/dist/particle-sim-CyUU7HVU.js +281 -0
- package/dist/{physics-2d-CZM5Y90X.js → physics-2d-q2N362ph.js} +45 -4
- package/dist/{physics-3d-DT5e8izo.js → physics-3d-CvHr31d4.js} +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +1 -1
- package/dist/{register-CpXcMiEk.js → register-Cbs7QxoV.js} +139 -4
- package/dist/{register-Cl3pAxX-.js → register-Cqjxrfq0.js} +254 -4
- package/dist/{register-C35HDZpm.js → register-CxmuI9FL.js} +1 -1
- package/dist/{particle-sim-m3CdTGSl.js → register-DRPIjrKG.js} +1178 -278
- package/dist/test.d.ts +4 -10
- package/dist/test.js +11 -16
- package/editor/assets/{agent8-N4bwVH7C.js → agent8-B8QnWCeP.js} +1 -1
- package/editor/assets/{index-CXFNanuR.js → index-CVhnNkb3.js} +81 -81
- package/editor/index.html +1 -1
- package/package.json +1 -1
- package/schemas/scene.schema.json +427 -0
- package/skills/incanto-3d-character.md +14 -0
- package/skills/incanto-audio.md +23 -0
- package/skills/incanto-building-2d-games.md +31 -0
- package/skills/incanto-building-3d-games.md +21 -0
- package/skills/incanto-gameplay-behaviors.md +28 -0
- package/skills/incanto-hud.md +24 -0
- package/skills/incanto-multiplayer.md +27 -0
- package/skills/incanto-node-reference.md +73 -0
- package/skills/incanto-physics-and-input.md +9 -0
- package/skills/incanto-verifying-your-game.md +31 -0
- package/dist/register-Dl_ixIJe.js +0 -834
package/bin/incanto-check.mjs
CHANGED
|
@@ -71,7 +71,7 @@ if (files.length === 0) {
|
|
|
71
71
|
process.exit(1);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
const { validateScene } = await import(pathToFileURL(join(DIST, 'test.js')).href);
|
|
74
|
+
const { auditScene, validateScene } = await import(pathToFileURL(join(DIST, 'test.js')).href);
|
|
75
75
|
|
|
76
76
|
const results = files.map((file) => {
|
|
77
77
|
let json;
|
|
@@ -84,7 +84,7 @@ const results = files.map((file) => {
|
|
|
84
84
|
strictBehaviors: args.strict,
|
|
85
85
|
resolveScene: (p) => JSON.parse(readFileSync(resolve(dirname(file), p), 'utf-8')),
|
|
86
86
|
});
|
|
87
|
-
if (res.ok) return { file, ok: true };
|
|
87
|
+
if (res.ok) return { file, ok: true, warnings: auditScene(json) };
|
|
88
88
|
return {
|
|
89
89
|
file,
|
|
90
90
|
ok: false,
|
|
@@ -99,8 +99,10 @@ if (args.json) {
|
|
|
99
99
|
console.log(JSON.stringify({ ok: failed.length === 0, results }, null, 2));
|
|
100
100
|
} else {
|
|
101
101
|
for (const r of results) {
|
|
102
|
-
if (r.ok)
|
|
103
|
-
|
|
102
|
+
if (r.ok) {
|
|
103
|
+
console.log(` ok ${r.file}`);
|
|
104
|
+
for (const w of r.warnings ?? []) console.log(` warn: ${w}`);
|
|
105
|
+
} else console.log(`FAIL ${r.file}\n [${r.code}] ${r.message}`);
|
|
104
106
|
}
|
|
105
107
|
console.log(`\n${results.length - failed.length}/${results.length} scene(s) valid`);
|
|
106
108
|
}
|
package/dist/2d.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { s as JsonObject } from "./schema-CcoWb32N.js";
|
|
2
|
-
import {
|
|
3
|
-
import { t as LoadSceneOptions } from "./loader-
|
|
2
|
+
import { $ as Node, C as RendererStats, S as GameStats, b as Scheduler, l as PropSchema, n as BehaviorCtor, v as Engine, w as Scene$1 } from "./behavior-Bod1AyJS.js";
|
|
3
|
+
import { t as LoadSceneOptions } from "./loader-BcUDfNHn.js";
|
|
4
4
|
import { t as ParticleSim } from "./particle-sim-CwJ5rI_P.js";
|
|
5
5
|
import { Group, Mesh, Object3D, Scene, Texture } from "three";
|
|
6
6
|
import * as RapierNs from "@dimforge/rapier2d-compat";
|
|
@@ -559,6 +559,66 @@ declare class Particles2D extends Node2D {
|
|
|
559
559
|
override _syncObject2D(assets: AssetStore2D | null): void;
|
|
560
560
|
}
|
|
561
561
|
//#endregion
|
|
562
|
+
//#region src/2d/nodes/tile-map-2d.d.ts
|
|
563
|
+
/**
|
|
564
|
+
* A whole tile level as ONE node — grid render in a single draw call plus
|
|
565
|
+
* greedy-merged static colliders. Author the level as rows of characters:
|
|
566
|
+
*
|
|
567
|
+
* { "name": "Level", "type": "TileMap2D", "props": {
|
|
568
|
+
* "texture": "$tiles", "tileSize": 32,
|
|
569
|
+
* "cells": [
|
|
570
|
+
* "..................",
|
|
571
|
+
* "......111.........",
|
|
572
|
+
* "000000000000000000"
|
|
573
|
+
* ],
|
|
574
|
+
* "solid": [0, 1] } }
|
|
575
|
+
*
|
|
576
|
+
* `.` / space = empty, digits 0-9 = atlas tile index, other chars map through
|
|
577
|
+
* `legend` (e.g. `{"G": 12}`). The atlas is read left-to-right, top-to-bottom
|
|
578
|
+
* in `tileSize` squares. Tiles listed in `solid` become static colliders,
|
|
579
|
+
* greedy-merged into a few rectangles (hundreds of cells → a handful of
|
|
580
|
+
* bodies). Cell (0,0) renders with its TOP-LEFT on this node's origin.
|
|
581
|
+
*/
|
|
582
|
+
declare class TileMap2D extends Node2D {
|
|
583
|
+
static override readonly typeName: string;
|
|
584
|
+
static override readonly props: PropSchema;
|
|
585
|
+
texture: string;
|
|
586
|
+
tileSize: number;
|
|
587
|
+
columns: number;
|
|
588
|
+
private _cells;
|
|
589
|
+
private _legend;
|
|
590
|
+
private _solid;
|
|
591
|
+
/** Rebuild flags — raised when the map-shaping props are REPLACED. */
|
|
592
|
+
private geometryDirty;
|
|
593
|
+
private collidersDirty;
|
|
594
|
+
/** Replace the whole array to change the map (mutations are not watched). */
|
|
595
|
+
get cells(): (string | number[])[];
|
|
596
|
+
set cells(value: (string | number[])[]);
|
|
597
|
+
get legend(): Record<string, number>;
|
|
598
|
+
set legend(value: Record<string, number>);
|
|
599
|
+
get solid(): number[];
|
|
600
|
+
set solid(value: number[]);
|
|
601
|
+
opacity: number;
|
|
602
|
+
private tileMesh;
|
|
603
|
+
private builtColumns;
|
|
604
|
+
private builtRows;
|
|
605
|
+
/** Loader hook: bad cells fail at LOAD (unknown chars), not at render. */
|
|
606
|
+
static validateJson(node: Node): void;
|
|
607
|
+
/** The parsed index grid (test/tooling hook). */
|
|
608
|
+
grid(): number[][];
|
|
609
|
+
override onReady(): void;
|
|
610
|
+
override update(_dt: number): void;
|
|
611
|
+
private rebuildColliders;
|
|
612
|
+
/** @internal The drawable mesh (lazily created under the backing object). */
|
|
613
|
+
_mesh(): Mesh;
|
|
614
|
+
override _syncObject2D(assets: AssetStore2D | null): void;
|
|
615
|
+
/** One quad per visible tile, atlas UVs — a single draw call for the level. */
|
|
616
|
+
private buildGeometry;
|
|
617
|
+
/** Test hook: rendered tile count (quads in the built geometry). */
|
|
618
|
+
get renderedTileCount(): number;
|
|
619
|
+
override free(): void;
|
|
620
|
+
}
|
|
621
|
+
//#endregion
|
|
562
622
|
//#region src/2d/nodes/ui-layer.d.ts
|
|
563
623
|
declare const ANCHORS: readonly ["top-left", "top", "top-right", "left", "center", "right", "bottom-left", "bottom", "bottom-right"];
|
|
564
624
|
type UIAnchor = (typeof ANCHORS)[number];
|
|
@@ -720,4 +780,32 @@ declare function syncTree2D(root: Node, world: Scene, ui: Scene, assets: AssetSt
|
|
|
720
780
|
ignoreStatic?: boolean;
|
|
721
781
|
}): Sync2DResult;
|
|
722
782
|
//#endregion
|
|
723
|
-
|
|
783
|
+
//#region src/2d/tilemap-grid.d.ts
|
|
784
|
+
/**
|
|
785
|
+
* Pure tile-grid logic for TileMap2D — no three, unit-testable in node.
|
|
786
|
+
* Grids are `number[][]` of atlas tile indices, `-1` = empty.
|
|
787
|
+
*/
|
|
788
|
+
interface TileRect {
|
|
789
|
+
/** Cell coords (col, row) of the rect's top-left. */
|
|
790
|
+
x: number;
|
|
791
|
+
y: number;
|
|
792
|
+
/** Size in cells. */
|
|
793
|
+
w: number;
|
|
794
|
+
h: number;
|
|
795
|
+
}
|
|
796
|
+
/**
|
|
797
|
+
* Normalize the `cells` prop into an index grid. Two author formats:
|
|
798
|
+
* - string rows: `"." `/`" "` = empty, digits `0-9` = tile index, anything
|
|
799
|
+
* else must be in `legend` (char → index). Unknown chars HARD-fail.
|
|
800
|
+
* - number rows: passed through (`-1` = empty).
|
|
801
|
+
* Ragged rows are right-padded with empty.
|
|
802
|
+
*/
|
|
803
|
+
declare function parseCells(cells: readonly (string | readonly number[])[], legend: Record<string, number>): number[][];
|
|
804
|
+
/**
|
|
805
|
+
* Greedy rectangle merge over the solid cells: maximal horizontal runs,
|
|
806
|
+
* extended downward while the identical run repeats. A platform level's
|
|
807
|
+
* hundreds of solid tiles collapse to a handful of colliders.
|
|
808
|
+
*/
|
|
809
|
+
declare function mergeSolidRects(grid: readonly (readonly number[])[], solid: Set<number>): TileRect[];
|
|
810
|
+
//#endregion
|
|
811
|
+
export { AnimatedSprite2D, type AnimationDef, Area2D, type AssetStatus, AssetStore2D, Camera2D, CharacterBody2D, CharacterController2D, ColorRect2D, type CreateGame2DOptions, type Game2D, Joint2D, type JointType2D, Label, Node2D, Particles2D, Physics2D, type Physics2DOptions, PhysicsBody2D, Renderer2D, type Renderer2DOptions, type ResolvedSpriteTexture, RigidBody2D, type SheetInfo, Sprite2D, type SpriteFromLibraryResult, StaticBody2D, type Sync2DResult, type TextureLoadCallbacks, TileMap2D, type TileRect, type UIAnchor, UILayer, createGame2D, enablePhysics2D, mergeSolidRects, parseCells, registerNodes2D, spriteFromLibraryMeta, syncTree2D };
|
package/dist/2d.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as IncantoError } from "./errors-BpWbnbb_.js";
|
|
2
|
-
import { a as AssetStore2D, i as syncTree2D, r as Renderer2D, t as createGame2D } from "./create-game-
|
|
3
|
-
import { a as
|
|
4
|
-
import { n as enablePhysics2D, t as Physics2D } from "./physics-2d-
|
|
2
|
+
import { a as AssetStore2D, i as syncTree2D, r as Renderer2D, t as createGame2D } from "./create-game-BNDSbhy-.js";
|
|
3
|
+
import { _ as RigidBody2D, a as parseCells, c as ColorRect2D, d as AnimatedSprite2D, f as Sprite2D, g as PhysicsBody2D, h as CharacterBody2D, i as mergeSolidRects, l as CharacterController2D, m as Area2D, n as UILayer, o as Particles2D, p as Joint2D, r as TileMap2D, s as Label, t as registerNodes2D, u as Camera2D, v as StaticBody2D, y as Node2D } from "./register-Cqjxrfq0.js";
|
|
4
|
+
import { n as enablePhysics2D, t as Physics2D } from "./physics-2d-q2N362ph.js";
|
|
5
5
|
//#region src/2d/library-sprite.ts
|
|
6
6
|
/**
|
|
7
7
|
* Turn a library sprite-animation JSON into a scene-ready spritesheet asset
|
|
@@ -41,4 +41,4 @@ function spriteFromLibraryMeta(meta, opts) {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
//#endregion
|
|
44
|
-
export { AnimatedSprite2D, Area2D, AssetStore2D, Camera2D, CharacterBody2D, CharacterController2D, ColorRect2D, Joint2D, Label, Node2D, Particles2D, Physics2D, PhysicsBody2D, Renderer2D, RigidBody2D, Sprite2D, StaticBody2D, UILayer, createGame2D, enablePhysics2D, registerNodes2D, spriteFromLibraryMeta, syncTree2D };
|
|
44
|
+
export { AnimatedSprite2D, Area2D, AssetStore2D, Camera2D, CharacterBody2D, CharacterController2D, ColorRect2D, Joint2D, Label, Node2D, Particles2D, Physics2D, PhysicsBody2D, Renderer2D, RigidBody2D, Sprite2D, StaticBody2D, TileMap2D, UILayer, createGame2D, enablePhysics2D, mergeSolidRects, parseCells, registerNodes2D, spriteFromLibraryMeta, syncTree2D };
|
package/dist/3d.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { s as JsonObject } from "./schema-CcoWb32N.js";
|
|
2
|
-
import {
|
|
3
|
-
import { t as LoadSceneOptions } from "./loader-
|
|
2
|
+
import { $ as Node, C as RendererStats, S as GameStats, b as Scheduler, l as PropSchema, n as BehaviorCtor, v as Engine, w as Scene$1 } from "./behavior-Bod1AyJS.js";
|
|
3
|
+
import { t as LoadSceneOptions } from "./loader-BcUDfNHn.js";
|
|
4
4
|
import { t as ParticleSim } from "./particle-sim-CwJ5rI_P.js";
|
|
5
|
-
import { r as SpatialPose } from "./audio-player-
|
|
5
|
+
import { r as SpatialPose } from "./audio-player-Dyjg5k92.js";
|
|
6
6
|
import { AnimationClip, BufferGeometry, Color, DirectionalLight, InstancedMesh, MeshPhysicalMaterial, Object3D, PerspectiveCamera, Scene, Vector3, WebGLRenderer } from "three";
|
|
7
7
|
import { VRM } from "@pixiv/three-vrm";
|
|
8
8
|
import { Sky } from "three/examples/jsm/objects/Sky.js";
|
|
@@ -696,6 +696,13 @@ declare class CharacterController3D extends Node3D {
|
|
|
696
696
|
* character facing away from the camera until it first moves).
|
|
697
697
|
*/
|
|
698
698
|
skinYawOffset: number;
|
|
699
|
+
/**
|
|
700
|
+
* Movement-state → animation asset map, applied to the `skinPath` model
|
|
701
|
+
* directly — no CharacterAnimator behavior needed:
|
|
702
|
+
* "animations": { "idle": "$idle", "run": "$run", "fastRun": "$sprint",
|
|
703
|
+
* "walk": "$walk", "airborne": "$jump" }
|
|
704
|
+
*/
|
|
705
|
+
animations: Record<string, string>;
|
|
699
706
|
/** Camera yaw/pitch in radians (mouse look mutates these). */
|
|
700
707
|
yaw: number;
|
|
701
708
|
pitch: number;
|
|
@@ -1547,6 +1554,38 @@ declare class Terrain3D extends Node3D {
|
|
|
1547
1554
|
override free(): void;
|
|
1548
1555
|
}
|
|
1549
1556
|
//#endregion
|
|
1557
|
+
//#region src/3d/nodes/trail-3d.d.ts
|
|
1558
|
+
/**
|
|
1559
|
+
* A fading ribbon behind whatever this node is parented to — wingtip trails,
|
|
1560
|
+
* sword arcs, tyre streaks. Records the node's world position over `seconds`
|
|
1561
|
+
* and renders a camera-facing strip that tapers and fades to the tail.
|
|
1562
|
+
*
|
|
1563
|
+
* { "name": "WingTrail", "type": "Trail3D",
|
|
1564
|
+
* "props": { "width": 0.4, "color": "#dddddd", "seconds": 0.8 } }
|
|
1565
|
+
*
|
|
1566
|
+
* `emitting: false` stops laying new ribbon (the old tail still fades out).
|
|
1567
|
+
*/
|
|
1568
|
+
declare class Trail3D extends Node3D {
|
|
1569
|
+
static override readonly typeName: string;
|
|
1570
|
+
static override readonly props: PropSchema;
|
|
1571
|
+
width: number;
|
|
1572
|
+
color: string;
|
|
1573
|
+
opacity: number;
|
|
1574
|
+
seconds: number;
|
|
1575
|
+
emitting: boolean;
|
|
1576
|
+
additive: boolean;
|
|
1577
|
+
minDistance: number;
|
|
1578
|
+
private readonly points;
|
|
1579
|
+
private clock;
|
|
1580
|
+
private mesh;
|
|
1581
|
+
private lastColor;
|
|
1582
|
+
protected override _createObject3D(): Object3D;
|
|
1583
|
+
override update(dt: number): void;
|
|
1584
|
+
_onRender3D(ctx: RenderContext3D): void;
|
|
1585
|
+
/** Test hook: recorded point count. */
|
|
1586
|
+
get pointCount(): number;
|
|
1587
|
+
}
|
|
1588
|
+
//#endregion
|
|
1550
1589
|
//#region src/3d/vegetation/tree-blueprint.d.ts
|
|
1551
1590
|
/**
|
|
1552
1591
|
* Tree3D construction recipes — the pure half of the procedural trees.
|
|
@@ -2116,4 +2155,4 @@ interface WalkState {
|
|
|
2116
2155
|
ignoreStatic: boolean;
|
|
2117
2156
|
}
|
|
2118
2157
|
//#endregion
|
|
2119
|
-
export { Area3D, AssetStore3D, Billboard3D, type BillboardGroupMode, Camera3D, CharacterBody3D, CharacterController3D, type CreateGame3DOptions, DEFAULT_TERRAIN_TEXTURE_BASE, DirectionalLight3D, Environment3D, type Environment3DConfig, DENSITY_PRESETS as FLOWER_DENSITY_PRESETS, FLOWER_VARIETIES, type FlowerVariety, Flowers3D, type FogEnvironment, Foliage3D, type FoliageKind, type FoliageStyle, type Game3D, type Heightmap, type HeightmapOptions, Joint3D, type JointType3D, LoftMesh3D, type LoftSection, MeshInstance3D, type MeshKind, type MeshMaterialProps, type ModelEntry, ModelInstance3D, Node3D, OmniLight3D, Particles3D, Physics3D, type Physics3DOptions, PhysicsBody3D, QUARTER_PITCH, type RenderContext3D, type RenderHook3D, Renderer3D, type Renderer3DOptions, type RigView, RigidBody3D, type Ripple, type ShadowsEnvironment, type SkyEnvironment, StaticBody3D, type SunConsumer3D, type SyncOptions, type SyncResult, TERRAIN_THEMES, Terrain3D, type TerrainLayer, type TerrainTheme, Tree3D, type TreeTier, type TreeType, VOXEL_PALETTE, type VoxelBlock, VoxelGrid3D, WATER_MAX_RIPPLES, Water3D, buildHeightmap, cameraRelative, createGame3D, enablePhysics3D, horizonColorFromSky, keyboardIntensity, movementState, parseEnvironment3D, registerNodes3D, resolveFlowerDensity, rigPose, splatWeights, sunDirectionFromElevationAzimuth, sunDirectionFromSky, syncTree, terrainThemeLayers };
|
|
2158
|
+
export { Area3D, AssetStore3D, Billboard3D, type BillboardGroupMode, Camera3D, CharacterBody3D, CharacterController3D, type CreateGame3DOptions, DEFAULT_TERRAIN_TEXTURE_BASE, DirectionalLight3D, Environment3D, type Environment3DConfig, DENSITY_PRESETS as FLOWER_DENSITY_PRESETS, FLOWER_VARIETIES, type FlowerVariety, Flowers3D, type FogEnvironment, Foliage3D, type FoliageKind, type FoliageStyle, type Game3D, type Heightmap, type HeightmapOptions, Joint3D, type JointType3D, LoftMesh3D, type LoftSection, MeshInstance3D, type MeshKind, type MeshMaterialProps, type ModelEntry, ModelInstance3D, Node3D, OmniLight3D, Particles3D, Physics3D, type Physics3DOptions, PhysicsBody3D, QUARTER_PITCH, type RenderContext3D, type RenderHook3D, Renderer3D, type Renderer3DOptions, type RigView, RigidBody3D, type Ripple, type ShadowsEnvironment, type SkyEnvironment, StaticBody3D, type SunConsumer3D, type SyncOptions, type SyncResult, TERRAIN_THEMES, Terrain3D, type TerrainLayer, type TerrainTheme, Trail3D, Tree3D, type TreeTier, type TreeType, VOXEL_PALETTE, type VoxelBlock, VoxelGrid3D, WATER_MAX_RIPPLES, Water3D, buildHeightmap, cameraRelative, createGame3D, enablePhysics3D, horizonColorFromSky, keyboardIntensity, movementState, parseEnvironment3D, registerNodes3D, resolveFlowerDensity, rigPose, splatWeights, sunDirectionFromElevationAzimuth, sunDirectionFromSky, syncTree, terrainThemeLayers };
|
package/dist/3d.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as Environment3D, c as sunDirectionFromElevationAzimuth, i as syncTree, l as sunDirectionFromSky, o as horizonColorFromSky, r as Renderer3D, s as parseEnvironment3D, t as createGame3D, u as AssetStore3D } from "./create-game-
|
|
2
|
-
import { A as
|
|
1
|
+
import { a as Environment3D, c as sunDirectionFromElevationAzimuth, i as syncTree, l as sunDirectionFromSky, o as horizonColorFromSky, r as Renderer3D, s as parseEnvironment3D, t as createGame3D, u as AssetStore3D } from "./create-game-66c4iYJE.js";
|
|
2
|
+
import { A as RigidBody3D, C as DEFAULT_TERRAIN_TEXTURE_BASE, D as Area3D, E as Joint3D, F as cameraRelative, I as keyboardIntensity, L as movementState, M as Node3D, O as CharacterBody3D, P as QUARTER_PITCH, R as rigPose, S as Terrain3D, T as terrainThemeLayers, _ as resolveFlowerDensity, a as VoxelGrid3D, b as Camera3D, c as Particles3D, d as MeshInstance3D, f as DirectionalLight3D, g as Flowers3D, h as DENSITY_PRESETS, i as VOXEL_PALETTE, j as StaticBody3D, k as PhysicsBody3D, l as ModelInstance3D, m as Foliage3D, n as Water3D, o as Tree3D, p as OmniLight3D, r as WATER_MAX_RIPPLES, s as Trail3D, t as registerNodes3D, u as LoftMesh3D, v as FLOWER_VARIETIES, w as TERRAIN_THEMES, x as Billboard3D, y as CharacterController3D } from "./register-Cbs7QxoV.js";
|
|
3
3
|
import { n as splatWeights, t as buildHeightmap } from "./heightmap-CroQPEER.js";
|
|
4
|
-
import { n as enablePhysics3D, t as Physics3D } from "./physics-3d-
|
|
5
|
-
export { Area3D, AssetStore3D, Billboard3D, Camera3D, CharacterBody3D, CharacterController3D, DEFAULT_TERRAIN_TEXTURE_BASE, DirectionalLight3D, Environment3D, DENSITY_PRESETS as FLOWER_DENSITY_PRESETS, FLOWER_VARIETIES, Flowers3D, Foliage3D, Joint3D, LoftMesh3D, MeshInstance3D, ModelInstance3D, Node3D, OmniLight3D, Particles3D, Physics3D, PhysicsBody3D, QUARTER_PITCH, Renderer3D, RigidBody3D, StaticBody3D, TERRAIN_THEMES, Terrain3D, Tree3D, VOXEL_PALETTE, VoxelGrid3D, WATER_MAX_RIPPLES, Water3D, buildHeightmap, cameraRelative, createGame3D, enablePhysics3D, horizonColorFromSky, keyboardIntensity, movementState, parseEnvironment3D, registerNodes3D, resolveFlowerDensity, rigPose, splatWeights, sunDirectionFromElevationAzimuth, sunDirectionFromSky, syncTree, terrainThemeLayers };
|
|
4
|
+
import { n as enablePhysics3D, t as Physics3D } from "./physics-3d-CvHr31d4.js";
|
|
5
|
+
export { Area3D, AssetStore3D, Billboard3D, Camera3D, CharacterBody3D, CharacterController3D, DEFAULT_TERRAIN_TEXTURE_BASE, DirectionalLight3D, Environment3D, DENSITY_PRESETS as FLOWER_DENSITY_PRESETS, FLOWER_VARIETIES, Flowers3D, Foliage3D, Joint3D, LoftMesh3D, MeshInstance3D, ModelInstance3D, Node3D, OmniLight3D, Particles3D, Physics3D, PhysicsBody3D, QUARTER_PITCH, Renderer3D, RigidBody3D, StaticBody3D, TERRAIN_THEMES, Terrain3D, Trail3D, Tree3D, VOXEL_PALETTE, VoxelGrid3D, WATER_MAX_RIPPLES, Water3D, buildHeightmap, cameraRelative, createGame3D, enablePhysics3D, horizonColorFromSky, keyboardIntensity, movementState, parseEnvironment3D, registerNodes3D, resolveFlowerDensity, rigPose, splatWeights, sunDirectionFromElevationAzimuth, sunDirectionFromSky, syncTree, terrainThemeLayers };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
//#region src/core/audit.ts
|
|
2
|
+
const ANIMATED_TYPES = new Set([
|
|
3
|
+
"Particles2D",
|
|
4
|
+
"Particles3D",
|
|
5
|
+
"Water3D",
|
|
6
|
+
"AnimatedSprite2D",
|
|
7
|
+
"AnimatedSprite3D",
|
|
8
|
+
"Camera2D",
|
|
9
|
+
"Camera3D"
|
|
10
|
+
]);
|
|
11
|
+
const BODY_TYPES = new Set([
|
|
12
|
+
"StaticBody2D",
|
|
13
|
+
"RigidBody2D",
|
|
14
|
+
"Area2D",
|
|
15
|
+
"CharacterBody2D",
|
|
16
|
+
"StaticBody3D",
|
|
17
|
+
"RigidBody3D",
|
|
18
|
+
"Area3D",
|
|
19
|
+
"CharacterBody3D"
|
|
20
|
+
]);
|
|
21
|
+
const HUD_WIDGETS = new Set([
|
|
22
|
+
"UiText",
|
|
23
|
+
"UiBar",
|
|
24
|
+
"UiBanner",
|
|
25
|
+
"UiButton",
|
|
26
|
+
"UiDialogue"
|
|
27
|
+
]);
|
|
28
|
+
/** Human-readable warnings (empty = clean). Pure JSON walk, no registry. */
|
|
29
|
+
function auditScene(scene) {
|
|
30
|
+
const warnings = [];
|
|
31
|
+
const root = scene.root;
|
|
32
|
+
if (!root) return warnings;
|
|
33
|
+
let currentCameras = 0;
|
|
34
|
+
let cameras = 0;
|
|
35
|
+
const walk = (node, path, insideHud, staticRoot) => {
|
|
36
|
+
const type = node.type ?? "";
|
|
37
|
+
const props = node.props ?? {};
|
|
38
|
+
if (type === "Camera2D" || type === "Camera3D") {
|
|
39
|
+
cameras += 1;
|
|
40
|
+
if (props.current === true) currentCameras += 1;
|
|
41
|
+
}
|
|
42
|
+
if (BODY_TYPES.has(type)) {
|
|
43
|
+
const collider = props.collider;
|
|
44
|
+
if (!collider || collider.shape === void 0) warnings.push(`${path}: ${type} has no collider — physics will skip it (add "collider": { "shape": ... }).`);
|
|
45
|
+
}
|
|
46
|
+
if (HUD_WIDGETS.has(type) && !insideHud) warnings.push(`${path}: ${type} works only as a descendant of a HudLayer — it will not render.`);
|
|
47
|
+
if (staticRoot && ANIMATED_TYPES.has(type)) warnings.push(`${path}: ${type} is frozen inside static subtree '${staticRoot}' — it will not animate/update on screen.`);
|
|
48
|
+
const nextStatic = staticRoot ?? (props.static === true ? node.name ?? path : null);
|
|
49
|
+
const nextHud = insideHud || type === "HudLayer";
|
|
50
|
+
for (const child of node.children ?? []) walk(child, `${path}/${child.name ?? "?"}`, nextHud, nextStatic);
|
|
51
|
+
};
|
|
52
|
+
walk(root, root.name ?? "root", false, root.props?.static === true ? root.name ?? "root" : null);
|
|
53
|
+
if (cameras > 0 && currentCameras === 0) warnings.push("no camera has \"current\": true — the screen renders from a default view, probably not what you framed.");
|
|
54
|
+
if (currentCameras > 1) warnings.push(`${currentCameras} cameras claim "current": true — only the first found wins.`);
|
|
55
|
+
return warnings;
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
export { auditScene as t };
|
|
@@ -437,6 +437,30 @@ declare function spatialGain(distance: number, params: SpatialParams): number;
|
|
|
437
437
|
*/
|
|
438
438
|
declare function spatialPan(sourcePos: Vec3, listener: Listener): number;
|
|
439
439
|
//#endregion
|
|
440
|
+
//#region src/core/audio/voice.d.ts
|
|
441
|
+
/**
|
|
442
|
+
* Continuous parametric voices — the engine hum, wind rush and thruster
|
|
443
|
+
* roar that one-shot SFX can't do (racing-3d hand-built exactly this graph).
|
|
444
|
+
* A voice is a small WebAudio patch you retune every frame:
|
|
445
|
+
*
|
|
446
|
+
* const voice = engine.sfx.startVoice('engine');
|
|
447
|
+
* voice.set({ pitch: rpm / 4000, volume: throttle * 0.6 });
|
|
448
|
+
* voice.stop(); // fades out and frees the graph
|
|
449
|
+
*
|
|
450
|
+
* Headless (no AudioContext) the handle is inert — same call sites, no ifs.
|
|
451
|
+
*/
|
|
452
|
+
type VoicePreset = "engine" | "wind" | "hum" | "noise";
|
|
453
|
+
interface Voice {
|
|
454
|
+
/** Retune live. pitch 1 = the preset's base; volume 0..1. */
|
|
455
|
+
set(params: {
|
|
456
|
+
pitch?: number;
|
|
457
|
+
volume?: number;
|
|
458
|
+
}): void;
|
|
459
|
+
/** Fade out over `seconds` (default 0.15) and free the nodes. */
|
|
460
|
+
stop(seconds?: number): void;
|
|
461
|
+
readonly stopped: boolean;
|
|
462
|
+
}
|
|
463
|
+
//#endregion
|
|
440
464
|
//#region src/core/audio/webaudio-sfx.d.ts
|
|
441
465
|
/** A spatial emitter: where the sound is + where the listener is. */
|
|
442
466
|
interface SpatialPlay {
|
|
@@ -469,6 +493,12 @@ declare class SfxEngine {
|
|
|
469
493
|
/** True once a backend is present (lazily created on first use). */
|
|
470
494
|
get available(): boolean;
|
|
471
495
|
private ensure;
|
|
496
|
+
/**
|
|
497
|
+
* Start a continuous parametric voice (engine hum, wind, thrusters) —
|
|
498
|
+
* retune it per frame with `voice.set({ pitch, volume })`, `stop()` when
|
|
499
|
+
* done. Headless returns an inert handle (same call sites, no ifs).
|
|
500
|
+
*/
|
|
501
|
+
startVoice(preset: VoicePreset, gain?: number): Voice;
|
|
472
502
|
/** Resume a gesture-suspended context (wired to the first user gesture). */
|
|
473
503
|
unlock(): void;
|
|
474
504
|
/**
|
|
@@ -920,4 +950,4 @@ declare function registeredBehaviors(): string[];
|
|
|
920
950
|
/** Test isolation helper. */
|
|
921
951
|
declare function clearBehaviors(): void;
|
|
922
952
|
//#endregion
|
|
923
|
-
export {
|
|
953
|
+
export { Node as $, SfxPlayOptions as A, spatialPan as B, RendererStats as C, LogManager as D, LogLevel as E, ROLLOFF_MODELS as F, SynthOptions as G, SFX_PRESET_NAMES as H, RolloffModel as I, MusicManager as J, synthSfx as K, SpatialParams as L, Voice as M, VoicePreset as N, InputMap as O, Listener as P, BusName as Q, Vec3 as R, GameStats as S, LogEntry as T, SfxParams as U, SFX_PRESETS as V, SfxWave as W, PlayMusicOptions as X, MusicTrack as Y, AudioBuses as Z, registeredTypes as _, registerBehavior as a, Scheduler as b, PropDef as c, createNode as d, NodeLifecycle as et, getNodeSchema as f, registerNode as g, mergeStaticSignals as h, getBehavior as i, isAudioContextAvailable as j, SfxEngine as k, PropSchema as l, getNodeType as m, BehaviorCtor as n, SignalListener as nt, registeredBehaviors as o, getNodeSignals as p, MusicBackend as q, clearBehaviors as r, SceneTree as rt, NodeCtor as s, Behavior as t, Signal as tt, clearRegistry as u, Engine as v, Scene as w, EngineStats as x, EngineOptions as y, spatialGain as z };
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
|
|
2
2
|
import { _ as registerBehavior, n as loadScene } from "./loader-B4OEXDZ8.js";
|
|
3
|
-
import {
|
|
3
|
+
import { l as AudioPlayer, u as Engine } from "./register-DRPIjrKG.js";
|
|
4
4
|
import { t as IncantoError } from "./errors-BpWbnbb_.js";
|
|
5
|
-
import { s as AudioPlayer } from "./register-Dl_ixIJe.js";
|
|
6
5
|
import { i as resolveRendering, n as attachTouchControls } from "./touch-031PxtCR.js";
|
|
7
|
-
import { n as registerGameplayBehaviors } from "./gameplay-
|
|
6
|
+
import { n as registerGameplayBehaviors } from "./gameplay-DPMgZk9W.js";
|
|
8
7
|
import { t as debugSources } from "./debug-draw-CZmOYjL2.js";
|
|
9
|
-
import {
|
|
10
|
-
import { n as enablePhysics3D } from "./physics-3d-
|
|
8
|
+
import { M as Node3D, b as Camera3D, f as DirectionalLight3D, k as PhysicsBody3D, l as ModelInstance3D, t as registerNodes3D } from "./register-Cbs7QxoV.js";
|
|
9
|
+
import { n as enablePhysics3D } from "./physics-3d-CvHr31d4.js";
|
|
11
10
|
import { ACESFilmicToneMapping, AmbientLight, Box3, BufferAttribute, BufferGeometry, Color, DepthTexture, EquirectangularReflectionMapping, FloatType, Fog, HalfFloatType, LineBasicMaterial, LineSegments, Matrix4, Mesh, PCFShadowMap, PMREMGenerator, PerspectiveCamera, PlaneGeometry, Quaternion, Raycaster, Scene, ShaderMaterial, Vector2, Vector3, WebGLRenderTarget, WebGLRenderer } from "three";
|
|
12
11
|
import { VRMLoaderPlugin, VRMUtils } from "@pixiv/three-vrm";
|
|
13
12
|
import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js";
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
|
|
2
2
|
import { _ as registerBehavior, n as loadScene, o as computeViewport, s as resolveViewport } from "./loader-B4OEXDZ8.js";
|
|
3
|
-
import {
|
|
3
|
+
import { l as AudioPlayer, u as Engine } from "./register-DRPIjrKG.js";
|
|
4
4
|
import { t as IncantoError } from "./errors-BpWbnbb_.js";
|
|
5
|
-
import { s as AudioPlayer } from "./register-Dl_ixIJe.js";
|
|
6
5
|
import { i as resolveRendering, n as attachTouchControls } from "./touch-031PxtCR.js";
|
|
7
|
-
import { n as registerGameplayBehaviors } from "./gameplay-
|
|
8
|
-
import { g as
|
|
6
|
+
import { n as registerGameplayBehaviors } from "./gameplay-DPMgZk9W.js";
|
|
7
|
+
import { g as PhysicsBody2D, n as UILayer, t as registerNodes2D, u as Camera2D, y as Node2D } from "./register-Cqjxrfq0.js";
|
|
9
8
|
import { t as debugSources } from "./debug-draw-CZmOYjL2.js";
|
|
10
|
-
import { n as enablePhysics2D } from "./physics-2d-
|
|
9
|
+
import { n as enablePhysics2D } from "./physics-2d-q2N362ph.js";
|
|
11
10
|
import { Box3, BufferAttribute, BufferGeometry, Color, LineBasicMaterial, LineSegments, LinearFilter, NearestFilter, OrthographicCamera, Raycaster, SRGBColorSpace, Scene, TextureLoader, Vector2, Vector3, WebGLRenderer } from "three";
|
|
12
11
|
//#region src/2d/assets.ts
|
|
13
12
|
/**
|
package/dist/debug.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as RendererStats, E as LogLevel, v as Engine } from "./behavior-
|
|
1
|
+
import { C as RendererStats, E as LogLevel, v as Engine } from "./behavior-Bod1AyJS.js";
|
|
2
2
|
|
|
3
3
|
//#region src/debug/panel.d.ts
|
|
4
4
|
/** Minimal document surface the overlay needs (injectable for tests). */
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import { s as JsonObject } from "./schema-CcoWb32N.js";
|
|
2
|
+
|
|
3
|
+
//#region src/core/audit.d.ts
|
|
4
|
+
/** Human-readable warnings (empty = clean). Pure JSON walk, no registry. */
|
|
5
|
+
declare function auditScene(scene: JsonObject): string[];
|
|
6
|
+
//#endregion
|
|
1
7
|
//#region src/core/errors.d.ts
|
|
2
8
|
/**
|
|
3
9
|
* Stable error codes for every hard failure in the engine.
|
|
@@ -30,4 +36,4 @@ declare class IncantoError extends Error {
|
|
|
30
36
|
constructor(code: IncantoErrorCode, message: string, details?: IncantoErrorDetails);
|
|
31
37
|
}
|
|
32
38
|
//#endregion
|
|
33
|
-
export { IncantoErrorCode as n, IncantoErrorDetails as r, IncantoError as t };
|
|
39
|
+
export { auditScene as i, IncantoErrorCode as n, IncantoErrorDetails as r, IncantoError as t };
|
|
@@ -480,6 +480,39 @@ function restartScene(engine) {
|
|
|
480
480
|
engine.setScene(loadScene(jsonClone(source)));
|
|
481
481
|
}
|
|
482
482
|
/**
|
|
483
|
+
* Swap to another scene behind a black fade (title→game→next level).
|
|
484
|
+
* Headless (no DOM) the swap is immediate. Restores timeScale to 1.
|
|
485
|
+
*/
|
|
486
|
+
function goToScene(engine, sceneJson, opts) {
|
|
487
|
+
const fade = opts?.fadeSeconds ?? .4;
|
|
488
|
+
const swap = () => {
|
|
489
|
+
engine.timeScale = 1;
|
|
490
|
+
engine.setScene(loadScene(jsonClone(sceneJson)));
|
|
491
|
+
};
|
|
492
|
+
if (typeof document === "undefined" || fade <= 0) {
|
|
493
|
+
swap();
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
const id = "incanto-scene-fade";
|
|
497
|
+
let el = document.getElementById(id);
|
|
498
|
+
if (!el) {
|
|
499
|
+
el = document.createElement("div");
|
|
500
|
+
el.id = id;
|
|
501
|
+
el.style.cssText = "position:fixed;inset:0;z-index:10001;background:#000;opacity:0;pointer-events:none;";
|
|
502
|
+
document.body.appendChild(el);
|
|
503
|
+
}
|
|
504
|
+
el.style.transition = `opacity ${fade / 2}s`;
|
|
505
|
+
el.style.opacity = "1";
|
|
506
|
+
setTimeout(() => {
|
|
507
|
+
swap();
|
|
508
|
+
const out = document.getElementById(id);
|
|
509
|
+
if (out) {
|
|
510
|
+
out.style.opacity = "0";
|
|
511
|
+
setTimeout(() => out.remove(), fade * 500 + 60);
|
|
512
|
+
}
|
|
513
|
+
}, fade * 500 + 30);
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
483
516
|
* The win/lose/restart state machine 6+ examples hand-rolled as `over`/`win`
|
|
484
517
|
* booleans. Attach to any node (the scene root is natural):
|
|
485
518
|
*
|
|
@@ -531,6 +564,11 @@ var GameFlow = class extends Behavior {
|
|
|
531
564
|
this.thaw();
|
|
532
565
|
restartScene(this.engine);
|
|
533
566
|
}
|
|
567
|
+
/** Fade to another scene (next level, back to title). */
|
|
568
|
+
goToScene(sceneJson, opts) {
|
|
569
|
+
this.thaw();
|
|
570
|
+
goToScene(this.engine, sceneJson, opts);
|
|
571
|
+
}
|
|
534
572
|
transition(state, text, color) {
|
|
535
573
|
if (this.state === "gameover" || this.state === "won") return;
|
|
536
574
|
this.state = state;
|
|
@@ -986,6 +1024,74 @@ var Oscillate = class extends Behavior {
|
|
|
986
1024
|
}
|
|
987
1025
|
};
|
|
988
1026
|
//#endregion
|
|
1027
|
+
//#region src/gameplay/path-follow.ts
|
|
1028
|
+
/**
|
|
1029
|
+
* Walk a list of waypoints at a constant speed, then stop — the delivery
|
|
1030
|
+
* end of `findPath`:
|
|
1031
|
+
*
|
|
1032
|
+
* const cells = findPath(grid, start, goal);
|
|
1033
|
+
* (npc.behavior as PathFollow).setPath(cells.map(([cx, cy]) => [cx * TILE, cy * TILE]));
|
|
1034
|
+
*
|
|
1035
|
+
* Waypoints are world positions in the node's own units (2D px / 3D m; use
|
|
1036
|
+
* [x, y] or [x, y, z] to match the node). Emits `waypointReached(index)`
|
|
1037
|
+
* per point and `arrived()` at the end. `loop: true` patrols the ring.
|
|
1038
|
+
*/
|
|
1039
|
+
var PathFollow = class extends Behavior {
|
|
1040
|
+
static signals = ["waypointReached", "arrived"];
|
|
1041
|
+
static props = {
|
|
1042
|
+
speed: { default: 120 },
|
|
1043
|
+
loop: { default: false }
|
|
1044
|
+
};
|
|
1045
|
+
/** Units per second (px in 2D, meters in 3D). */
|
|
1046
|
+
speed = 120;
|
|
1047
|
+
loop = false;
|
|
1048
|
+
waypoints = [];
|
|
1049
|
+
index = 0;
|
|
1050
|
+
/** True while there is somewhere left to go. */
|
|
1051
|
+
get moving() {
|
|
1052
|
+
return this.index < this.waypoints.length;
|
|
1053
|
+
}
|
|
1054
|
+
setPath(waypoints) {
|
|
1055
|
+
this.waypoints = waypoints.map((w) => [...w]);
|
|
1056
|
+
this.index = 0;
|
|
1057
|
+
}
|
|
1058
|
+
/** Stop in place (keeps the node where it is). */
|
|
1059
|
+
stop() {
|
|
1060
|
+
this.waypoints = [];
|
|
1061
|
+
this.index = 0;
|
|
1062
|
+
}
|
|
1063
|
+
update(dt) {
|
|
1064
|
+
if (!this.moving) return;
|
|
1065
|
+
const node = requirePosition(this);
|
|
1066
|
+
let budget = this.speed * dt;
|
|
1067
|
+
while (budget > 0 && this.index < this.waypoints.length) {
|
|
1068
|
+
const target = this.waypoints[this.index];
|
|
1069
|
+
const step = moveToward(node.position, target, budget);
|
|
1070
|
+
const travelled = distanceBetween(node.position, step.position);
|
|
1071
|
+
node.position = step.position;
|
|
1072
|
+
budget -= travelled;
|
|
1073
|
+
if (step.reached) {
|
|
1074
|
+
this.node.emit("waypointReached", this.index);
|
|
1075
|
+
this.index += 1;
|
|
1076
|
+
if (this.index >= this.waypoints.length) if (this.loop && this.waypoints.length > 1) this.index = 0;
|
|
1077
|
+
else {
|
|
1078
|
+
this.node.emit("arrived");
|
|
1079
|
+
return;
|
|
1080
|
+
}
|
|
1081
|
+
} else return;
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
};
|
|
1085
|
+
function distanceBetween(a, b) {
|
|
1086
|
+
let sum = 0;
|
|
1087
|
+
const n = Math.max(a.length, b.length);
|
|
1088
|
+
for (let i = 0; i < n; i++) {
|
|
1089
|
+
const d = (b[i] ?? 0) - (a[i] ?? 0);
|
|
1090
|
+
sum += d * d;
|
|
1091
|
+
}
|
|
1092
|
+
return Math.sqrt(sum);
|
|
1093
|
+
}
|
|
1094
|
+
//#endregion
|
|
989
1095
|
//#region src/gameplay/patrol.ts
|
|
990
1096
|
/**
|
|
991
1097
|
* Walk the node along a fixed list of waypoints at constant speed — guards,
|
|
@@ -1739,6 +1845,7 @@ var ZombieAI = class extends Behavior {
|
|
|
1739
1845
|
const GAMEPLAY_BEHAVIORS = {
|
|
1740
1846
|
CameraShake,
|
|
1741
1847
|
GameFlow,
|
|
1848
|
+
PathFollow,
|
|
1742
1849
|
Health,
|
|
1743
1850
|
Lifetime,
|
|
1744
1851
|
ScoreKeeper,
|
|
@@ -1767,4 +1874,4 @@ function registerGameplayBehaviors(opts) {
|
|
|
1767
1874
|
for (const [name, ctor] of Object.entries(GAMEPLAY_BEHAVIORS)) registerBehavior(name, ctor, { replace });
|
|
1768
1875
|
}
|
|
1769
1876
|
//#endregion
|
|
1770
|
-
export {
|
|
1877
|
+
export { FollowCamera as C, Chase as D, Collector as E, restartScene as S, Health as T, hitStop as _, Wander as a, GameFlow as b, Projectile as c, PathFollow as d, Oscillate as f, Cooldown as g, CameraShake as h, WaveSpawner as i, Pickup as l, Lifetime as m, registerGameplayBehaviors as n, Spawner as o, MoveTo as p, ZombieAI as r, ScoreKeeper as s, GAMEPLAY_BEHAVIORS as t, Patrol as u, screenFlash as v, DamageOnContact as w, goToScene as x, Interactable as y };
|
package/dist/gameplay.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as JsonValue } from "./schema-CcoWb32N.js";
|
|
2
|
-
import {
|
|
1
|
+
import { c as JsonValue, s as JsonObject } from "./schema-CcoWb32N.js";
|
|
2
|
+
import { $ as Node, l as PropSchema, n as BehaviorCtor, t as Behavior, v as Engine } from "./behavior-Bod1AyJS.js";
|
|
3
3
|
|
|
4
4
|
//#region src/gameplay/chase.d.ts
|
|
5
5
|
/**
|
|
@@ -541,6 +541,13 @@ declare class ZombieAI extends Behavior {
|
|
|
541
541
|
declare function restartScene(engine: Engine): void;
|
|
542
542
|
type GameFlowState = "playing" | "paused" | "gameover" | "won";
|
|
543
543
|
/**
|
|
544
|
+
* Swap to another scene behind a black fade (title→game→next level).
|
|
545
|
+
* Headless (no DOM) the swap is immediate. Restores timeScale to 1.
|
|
546
|
+
*/
|
|
547
|
+
declare function goToScene(engine: Engine, sceneJson: JsonObject, opts?: {
|
|
548
|
+
fadeSeconds?: number;
|
|
549
|
+
}): void;
|
|
550
|
+
/**
|
|
544
551
|
* The win/lose/restart state machine 6+ examples hand-rolled as `over`/`win`
|
|
545
552
|
* booleans. Attach to any node (the scene root is natural):
|
|
546
553
|
*
|
|
@@ -573,6 +580,10 @@ declare class GameFlow extends Behavior {
|
|
|
573
580
|
pause(): void;
|
|
574
581
|
resume(): void;
|
|
575
582
|
restart(): void;
|
|
583
|
+
/** Fade to another scene (next level, back to title). */
|
|
584
|
+
goToScene(sceneJson: JsonObject, opts?: {
|
|
585
|
+
fadeSeconds?: number;
|
|
586
|
+
}): void;
|
|
576
587
|
private transition;
|
|
577
588
|
private freeze;
|
|
578
589
|
private thaw;
|
|
@@ -639,6 +650,36 @@ declare function screenFlash(color?: string, opacity?: number, seconds?: number)
|
|
|
639
650
|
*/
|
|
640
651
|
declare function hitStop(engine: Engine, seconds?: number): void;
|
|
641
652
|
//#endregion
|
|
653
|
+
//#region src/gameplay/path-follow.d.ts
|
|
654
|
+
/**
|
|
655
|
+
* Walk a list of waypoints at a constant speed, then stop — the delivery
|
|
656
|
+
* end of `findPath`:
|
|
657
|
+
*
|
|
658
|
+
* const cells = findPath(grid, start, goal);
|
|
659
|
+
* (npc.behavior as PathFollow).setPath(cells.map(([cx, cy]) => [cx * TILE, cy * TILE]));
|
|
660
|
+
*
|
|
661
|
+
* Waypoints are world positions in the node's own units (2D px / 3D m; use
|
|
662
|
+
* [x, y] or [x, y, z] to match the node). Emits `waypointReached(index)`
|
|
663
|
+
* per point and `arrived()` at the end. `loop: true` patrols the ring.
|
|
664
|
+
*/
|
|
665
|
+
declare class PathFollow extends Behavior {
|
|
666
|
+
static readonly signals: readonly string[];
|
|
667
|
+
static readonly props: Record<string, {
|
|
668
|
+
default: number | boolean;
|
|
669
|
+
}>;
|
|
670
|
+
/** Units per second (px in 2D, meters in 3D). */
|
|
671
|
+
speed: number;
|
|
672
|
+
loop: boolean;
|
|
673
|
+
private waypoints;
|
|
674
|
+
private index;
|
|
675
|
+
/** True while there is somewhere left to go. */
|
|
676
|
+
get moving(): boolean;
|
|
677
|
+
setPath(waypoints: readonly (readonly number[])[]): void;
|
|
678
|
+
/** Stop in place (keeps the node where it is). */
|
|
679
|
+
stop(): void;
|
|
680
|
+
override update(dt: number): void;
|
|
681
|
+
}
|
|
682
|
+
//#endregion
|
|
642
683
|
//#region src/gameplay/index.d.ts
|
|
643
684
|
/** Every built-in gameplay behavior, keyed by its registration name. */
|
|
644
685
|
declare const GAMEPLAY_BEHAVIORS: Readonly<Record<string, BehaviorCtor>>;
|
|
@@ -651,4 +692,4 @@ declare function registerGameplayBehaviors(opts?: {
|
|
|
651
692
|
replace?: boolean;
|
|
652
693
|
}): void;
|
|
653
694
|
//#endregion
|
|
654
|
-
export { CameraShake, Chase, Collector, Cooldown, DamageOnContact, FollowCamera, GAMEPLAY_BEHAVIORS, GameFlow, type GameFlowState, Health, Interactable, Lifetime, MoveTo, Oscillate, Patrol, Pickup, Projectile, ScoreKeeper, Spawner, Wander, WaveSpawner, ZombieAI, hitStop, registerGameplayBehaviors, restartScene, screenFlash };
|
|
695
|
+
export { CameraShake, Chase, Collector, Cooldown, DamageOnContact, FollowCamera, GAMEPLAY_BEHAVIORS, GameFlow, type GameFlowState, Health, Interactable, Lifetime, MoveTo, Oscillate, PathFollow, Patrol, Pickup, Projectile, ScoreKeeper, Spawner, Wander, WaveSpawner, ZombieAI, goToScene, hitStop, registerGameplayBehaviors, restartScene, screenFlash };
|