Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

feat(probe): a driver that lost its goal can ask what the world still holds

esengine5270830ebab2
diff --git a/desktop b/desktop
index 3f7a7374d..7c6767e26 160000
--- a/desktop
+++ b/desktop
@@ -1 +1 @@
-Subproject commit 3f7a7374d29d76ad545d107e0b2f9f8f749d10b4
+Subproject commit 7c6767e26f80f82d4d6b94c91f188be27522e324
diff --git a/examples/third-person-3d/playthrough.json.meta b/examples/third-person-3d/playthrough.json.meta
new file mode 100644
index 000000000..da09423af
--- /dev/null
+++ b/examples/third-person-3d/playthrough.json.meta
@@ -0,0 +1,6 @@
+{
+ "uuid": "56826ef3-cc1a-48d3-a46d-05471a46e633",
+ "version": "2.0",
+ "type": "json",
+ "importer": {}
+}
diff --git a/pipeline/src/runtime/gameHost.ts b/pipeline/src/runtime/gameHost.ts
index 70255fce1..f312611ef 100644
--- a/pipeline/src/runtime/gameHost.ts
+++ b/pipeline/src/runtime/gameHost.ts
@@ -18,7 +18,7 @@ import {
packagedAppOptions, packagedRuntimeInit, Transform, SceneManager, Nav, UINode,
acquireWebGPUDevice, ThirdPersonCamera, CharacterController3D, AnimatorController,
Animator, TPC_SPEED, TPC_GROUNDED, Particle, MeleeAttack, Health,
- Hunter, NavAgent, Perception, AnimatorRootMotion, Playthrough,
+ Hunter, NavAgent, Perception, AnimatorRootMotion, Playthrough, Name,
worldResidencyReport,
} from 'esengine';
import type {
@@ -315,6 +315,27 @@ async function boot(): Promise<void> {
// "the thing I was walking to is gone", which is a lie with a cost.
return { scene: scenes?.getActive() ?? null, transitioning: scenes?.isTransitioning() ?? false, at };
},
+ /**
+ * Who the world still holds, asked once by a driver that lost sight of its
+ * goal. `probe` can only report a name it did not find, and "despawned",
+ * "renamed" and "alive but with no Transform" are three different bugs.
+ */
+ census(limit = 24): {
+ entities: number;
+ named: string[];
+ alive: { name: string; hp: number }[];
+ } {
+ const named: string[] = [];
+ const alive: { name: string; hp: number }[] = [];
+ for (const e of app.world.getEntitiesWithComponents([Name])) {
+ const n = app.world.get(e, Name).value;
+ if (named.length < limit) named.push(n);
+ if (app.world.has(e, Health) && alive.length < limit) {
+ alive.push({ name: n, hp: app.world.get(e, Health).current });
+ }
+ }
+ return { entities: app.world.getAllEntities().length, named, alive };
+ },
/**
* What an autonomous character is doing, and on whose terms. Read-only and
* off the same components the game runs on: a driver that could set the
diff --git a/tools/launchers/play-through.mjs b/tools/launchers/play-through.mjs
index c1f1eacfa..4db43d2dd 100644
--- a/tools/launchers/play-through.mjs
+++ b/tools/launchers/play-through.mjs
@@ -273,6 +273,7 @@ async function main() {
let plan = [];
let replan = 0;
let last = null;
+ let absent = 'nothing was';
// Frames spent waiting for a scene to hand out its entities — disk and decode,
// not walking, and charging the walk for it made one door cost 104 frames on
// one run and 704 on the next. Capped: a door that never opens still fails.
@@ -343,7 +344,10 @@ async function main() {
while (spent < timeout && frames < BUDGET && waited < WAIT_CAP) {
const state = await probe([leg.goal, 'Lyra_Player']);
// Nothing is true about a world that is halfway through being replaced.
- if (state.transitioning) { await exec(stepScript([], STEP, null), 'step'); waited += STEP; frames += STEP; continue; }
+ if (state.transitioning) {
+ absent = `the world stayed mid-replacement in ${state.scene}`;
+ await exec(stepScript([], STEP, null), 'step'); waited += STEP; frames += STEP; continue;
+ }
if (state.scene === leg.area) sawArea = true;
// The leg is over when the area it was aiming for has been left behind:
// walking into a door IS the arrival, and the door is gone by the time
@@ -409,6 +413,10 @@ async function main() {
await exec(stepScript(keys, STEP, leg.swing ? 'Space' : null), 'step');
} else {
// Between areas: the next scene has not handed out its entities yet.
+ // WHICH one is missing decides where to look, and a wait that ends in a
+ // cap said only that something had been.
+ absent = `${me ? `${leg.goal} was` : goal ? 'Lyra_Player was' : 'neither Lyra nor '
+ + `${leg.goal} were`} in ${state.scene}`;
await exec(stepScript([], STEP, null), 'step');
waited += STEP;
frames += STEP;
@@ -419,7 +427,17 @@ async function main() {
}
if (!arrived) {
- failure = `${label} — ${waited >= WAIT_CAP ? 'the scene never handed out its entities'
+ // Once, and only where the wait ran out: which of despawned, renamed or
+ // Transform-less the goal became is three different bugs, and the driver
+ // cannot tell them apart from a name it did not find.
+ if (waited >= WAIT_CAP) {
+ const c = await exec('window.__estellaCooked.census?.() ?? null', 'probe').catch(() => null);
+ if (c) {
+ console.log(` census: ${c.entities} entities, ${c.named.length} named — ${c.named.join(', ')}`);
+ console.log(` with health: ${c.alive.map((a) => `${a.name} ${a.hp}`).join(', ') || 'none'}`);
+ }
+ }
+ failure = `${label} — ${waited >= WAIT_CAP ? `the scene never handed out its entities (${absent})`
: spent >= timeout ? 'ran out of leg budget' : 'ran out of run budget'} after ${spent} frames`
+ (last ? `; last seen ${Math.round(last.me.x)},${Math.round(last.me.y)} with the goal at `
+ `${Math.round(last.goal.x)},${Math.round(last.goal.y)} (${Math.round(last.gap)} away)` : '; never saw both')