pelican-engine 0.3.6 → 0.3.8
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/AGENTS.md +7 -0
- package/distribution.json +11 -11
- package/docs/STATUS.md +2 -1
- package/docs/api/REFERENCE.md +96 -86
- package/docs/api/index.json +98 -87
- package/docs/npm/GAME-AUTHOR.md +7 -0
- package/engine.manifest.json +1 -1
- package/lib/navigation/index.js +22 -0
- package/lib/sdk/index.d.ts +8 -1
- package/lib/sdk/index.js +1 -1
- package/package.json +1 -1
package/docs/npm/GAME-AUTHOR.md
CHANGED
|
@@ -111,6 +111,13 @@ exhaustion returns `TC_NAVIGATION_CAPACITY`, not an unreachable result. Owners
|
|
|
111
111
|
are explicit strings, not entities. This is a development-stage grid service,
|
|
112
112
|
not continuous-world, flying or underwater navigation.
|
|
113
113
|
|
|
114
|
+
Use `ctx.navigation.setBlockedBatch(id, updates)` to change multiple cells in
|
|
115
|
+
one grid. Each update has `{ cell: { x, y }, blocked: boolean }`. The service
|
|
116
|
+
validates every entry before changing the grid; a bad entry rejects the whole
|
|
117
|
+
batch, and the last update wins if a cell appears more than once. Entity and
|
|
118
|
+
transform changes are separate from this grid-only batch. This API is new and
|
|
119
|
+
has not been runtime or browser validated under the current project policy.
|
|
120
|
+
|
|
114
121
|
Keyboard bindings use the browser's `KeyboardEvent.key` values, not physical
|
|
115
122
|
`KeyboardEvent.code` values. For example, use `input: { up: ["w", "W", "ArrowUp"],
|
|
116
123
|
restart: ["r", "R"] }`, not `"KeyW"` or `"KeyR"`. Letter case depends on the
|
package/engine.manifest.json
CHANGED
package/lib/navigation/index.js
CHANGED
|
@@ -91,6 +91,28 @@ export const createNavigationPlugin = () => {
|
|
|
91
91
|
else if (!blocked && exists)
|
|
92
92
|
grid.blocked.splice(lower, 1);
|
|
93
93
|
},
|
|
94
|
+
setBlockedBatch(id, updates) {
|
|
95
|
+
const grid = get(id);
|
|
96
|
+
if (!Array.isArray(updates))
|
|
97
|
+
fail("BLOCKED", `Updates for grid '${id}' must be an array of cells and boolean blocked values.`);
|
|
98
|
+
if (updates.length === 0)
|
|
99
|
+
return;
|
|
100
|
+
// Validate every entry before modifying the grid. Repeated cells use the last value.
|
|
101
|
+
const changes = new Map();
|
|
102
|
+
for (const update of updates) {
|
|
103
|
+
if (!update || typeof update !== "object" || typeof update.blocked !== "boolean")
|
|
104
|
+
fail("BLOCKED", `Each update for grid '${id}' requires a cell and a boolean blocked value.`);
|
|
105
|
+
changes.set(cell(grid, update.cell), update.blocked);
|
|
106
|
+
}
|
|
107
|
+
const blocked = new Set(grid.blocked);
|
|
108
|
+
for (const [index, value] of changes) {
|
|
109
|
+
if (value)
|
|
110
|
+
blocked.add(index);
|
|
111
|
+
else
|
|
112
|
+
blocked.delete(index);
|
|
113
|
+
}
|
|
114
|
+
grid.blocked = [...blocked].sort((a, b) => a - b);
|
|
115
|
+
},
|
|
94
116
|
findPath(id, start, end) {
|
|
95
117
|
const grid = get(id), from = cell(grid, start), to = cell(grid, end);
|
|
96
118
|
const blocked = new Set(grid.blocked);
|
package/lib/sdk/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Pelican Engine public API. No renderer or GPU implementation types escape this module. */
|
|
2
|
-
export declare const SDK_VERSION = "0.3.
|
|
2
|
+
export declare const SDK_VERSION = "0.3.8";
|
|
3
3
|
export type Vec2 = readonly [number, number];
|
|
4
4
|
export type Vec3 = readonly [number, number, number];
|
|
5
5
|
export type Vec4 = readonly [number, number, number, number];
|
|
@@ -109,6 +109,11 @@ export interface NavigationCell {
|
|
|
109
109
|
readonly x: number;
|
|
110
110
|
readonly y: number;
|
|
111
111
|
}
|
|
112
|
+
/** One obstacle change for an orthogonal navigation grid. */
|
|
113
|
+
export interface NavigationObstacleUpdate {
|
|
114
|
+
readonly cell: NavigationCell;
|
|
115
|
+
readonly blocked: boolean;
|
|
116
|
+
}
|
|
112
117
|
export interface NavigationGrid {
|
|
113
118
|
readonly id: string;
|
|
114
119
|
readonly owner: string;
|
|
@@ -124,6 +129,8 @@ export interface NavigationService {
|
|
|
124
129
|
getGrid(id: string): NavigationGrid;
|
|
125
130
|
isBlocked(id: string, cell: NavigationCell): boolean;
|
|
126
131
|
setBlocked(id: string, cell: NavigationCell, blocked: boolean): void;
|
|
132
|
+
/** Validates the entire batch before committing; the last change for a repeated cell wins. */
|
|
133
|
+
setBlockedBatch(id: string, updates: readonly NavigationObstacleUpdate[]): void;
|
|
127
134
|
findPath(id: string, start: NavigationCell, end: NavigationCell): readonly NavigationCell[];
|
|
128
135
|
destroyGrid(id: string): void;
|
|
129
136
|
destroyOwner(owner: string): void;
|
package/lib/sdk/index.js
CHANGED