Update tests for Scene Exit entities and interactions
This commit is contained in:
@@ -48,6 +48,7 @@ function createRuntimeSceneFixture(): RuntimeSceneDefinition {
|
|||||||
modelInstances: [],
|
modelInstances: [],
|
||||||
entities: {
|
entities: {
|
||||||
playerStarts: [],
|
playerStarts: [],
|
||||||
|
sceneEntries: [],
|
||||||
soundEmitters: [
|
soundEmitters: [
|
||||||
{
|
{
|
||||||
entityId: "entity-sound-lobby",
|
entityId: "entity-sound-lobby",
|
||||||
@@ -115,7 +116,8 @@ function createRuntimeSceneFixture(): RuntimeSceneDefinition {
|
|||||||
prompt: "Disabled Prompt",
|
prompt: "Disabled Prompt",
|
||||||
enabled: false
|
enabled: false
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
sceneExits: []
|
||||||
},
|
},
|
||||||
interactionLinks: [],
|
interactionLinks: [],
|
||||||
playerStart: null,
|
playerStart: null,
|
||||||
@@ -164,6 +166,7 @@ describe("RuntimeInteractionSystem", () => {
|
|||||||
teleportPlayer: (target, link) => {
|
teleportPlayer: (target, link) => {
|
||||||
dispatches.push(`${link.id}:${target.entityId}:${target.position.x}`);
|
dispatches.push(`${link.id}:${target.entityId}:${target.position.x}`);
|
||||||
},
|
},
|
||||||
|
activateSceneExit: () => {},
|
||||||
toggleBrushVisibility: () => {
|
toggleBrushVisibility: () => {
|
||||||
dispatches.push("toggle");
|
dispatches.push("toggle");
|
||||||
},
|
},
|
||||||
@@ -184,6 +187,7 @@ describe("RuntimeInteractionSystem", () => {
|
|||||||
teleportPlayer: (target, link) => {
|
teleportPlayer: (target, link) => {
|
||||||
dispatches.push(`${link.id}:${target.entityId}:${target.position.x}`);
|
dispatches.push(`${link.id}:${target.entityId}:${target.position.x}`);
|
||||||
},
|
},
|
||||||
|
activateSceneExit: () => {},
|
||||||
toggleBrushVisibility: () => {
|
toggleBrushVisibility: () => {
|
||||||
dispatches.push("toggle");
|
dispatches.push("toggle");
|
||||||
},
|
},
|
||||||
@@ -223,6 +227,9 @@ describe("RuntimeInteractionSystem", () => {
|
|||||||
teleportPlayer: () => {
|
teleportPlayer: () => {
|
||||||
throw new Error("Teleport should not dispatch in this fixture.");
|
throw new Error("Teleport should not dispatch in this fixture.");
|
||||||
},
|
},
|
||||||
|
activateSceneExit: () => {
|
||||||
|
throw new Error("Scene exit should not dispatch in this fixture.");
|
||||||
|
},
|
||||||
toggleBrushVisibility: () => {
|
toggleBrushVisibility: () => {
|
||||||
throw new Error("Visibility should not dispatch in this fixture.");
|
throw new Error("Visibility should not dispatch in this fixture.");
|
||||||
},
|
},
|
||||||
@@ -268,6 +275,9 @@ describe("RuntimeInteractionSystem", () => {
|
|||||||
teleportPlayer: () => {
|
teleportPlayer: () => {
|
||||||
throw new Error("Teleport should not dispatch in this fixture.");
|
throw new Error("Teleport should not dispatch in this fixture.");
|
||||||
},
|
},
|
||||||
|
activateSceneExit: () => {
|
||||||
|
throw new Error("Scene exit should not dispatch in this fixture.");
|
||||||
|
},
|
||||||
toggleBrushVisibility: (brushId, visible) => {
|
toggleBrushVisibility: (brushId, visible) => {
|
||||||
dispatches.push({
|
dispatches.push({
|
||||||
brushId,
|
brushId,
|
||||||
@@ -291,6 +301,9 @@ describe("RuntimeInteractionSystem", () => {
|
|||||||
teleportPlayer: () => {
|
teleportPlayer: () => {
|
||||||
throw new Error("Teleport should not dispatch in this fixture.");
|
throw new Error("Teleport should not dispatch in this fixture.");
|
||||||
},
|
},
|
||||||
|
activateSceneExit: () => {
|
||||||
|
throw new Error("Scene exit should not dispatch in this fixture.");
|
||||||
|
},
|
||||||
toggleBrushVisibility: (brushId, visible) => {
|
toggleBrushVisibility: (brushId, visible) => {
|
||||||
dispatches.push({
|
dispatches.push({
|
||||||
brushId,
|
brushId,
|
||||||
@@ -381,6 +394,9 @@ describe("RuntimeInteractionSystem", () => {
|
|||||||
teleportPlayer: (target, link) => {
|
teleportPlayer: (target, link) => {
|
||||||
dispatches.push(`${link.id}:${target.entityId}:${target.position.x}`);
|
dispatches.push(`${link.id}:${target.entityId}:${target.position.x}`);
|
||||||
},
|
},
|
||||||
|
activateSceneExit: () => {
|
||||||
|
throw new Error("Scene exit should not dispatch for this click fixture.");
|
||||||
|
},
|
||||||
toggleBrushVisibility: () => {
|
toggleBrushVisibility: () => {
|
||||||
throw new Error("Visibility should not dispatch for this click fixture.");
|
throw new Error("Visibility should not dispatch for this click fixture.");
|
||||||
},
|
},
|
||||||
@@ -417,6 +433,9 @@ describe("RuntimeInteractionSystem", () => {
|
|||||||
teleportPlayer: () => {
|
teleportPlayer: () => {
|
||||||
throw new Error("Teleport should not dispatch in this fixture.");
|
throw new Error("Teleport should not dispatch in this fixture.");
|
||||||
},
|
},
|
||||||
|
activateSceneExit: () => {
|
||||||
|
throw new Error("Scene exit should not dispatch in this fixture.");
|
||||||
|
},
|
||||||
toggleBrushVisibility: () => {
|
toggleBrushVisibility: () => {
|
||||||
throw new Error("Visibility should not dispatch in this fixture.");
|
throw new Error("Visibility should not dispatch in this fixture.");
|
||||||
},
|
},
|
||||||
@@ -436,4 +455,90 @@ describe("RuntimeInteractionSystem", () => {
|
|||||||
|
|
||||||
expect(dispatches).toEqual(["link-play-sound:entity-sound-lobby", "link-stop-sound:entity-sound-lobby"]);
|
expect(dispatches).toEqual(["link-play-sound:entity-sound-lobby", "link-stop-sound:entity-sound-lobby"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("shows a click prompt for enabled Scene Exits within range", () => {
|
||||||
|
const runtimeScene = createRuntimeSceneFixture();
|
||||||
|
runtimeScene.entities.sceneExits.push({
|
||||||
|
entityId: "entity-scene-exit-house-door",
|
||||||
|
position: {
|
||||||
|
x: 0,
|
||||||
|
y: 1,
|
||||||
|
z: 1
|
||||||
|
},
|
||||||
|
radius: 2,
|
||||||
|
prompt: "Enter House",
|
||||||
|
enabled: true,
|
||||||
|
targetSceneId: "scene-house",
|
||||||
|
targetEntryEntityId: "entity-scene-entry-house-front"
|
||||||
|
});
|
||||||
|
runtimeScene.entities.interactables = [];
|
||||||
|
|
||||||
|
const interactionSystem = new RuntimeInteractionSystem();
|
||||||
|
|
||||||
|
expect(
|
||||||
|
interactionSystem.resolveClickInteractionPrompt(
|
||||||
|
{
|
||||||
|
x: 0,
|
||||||
|
y: 1.6,
|
||||||
|
z: 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
z: 1
|
||||||
|
},
|
||||||
|
runtimeScene
|
||||||
|
)
|
||||||
|
).toEqual({
|
||||||
|
sourceEntityId: "entity-scene-exit-house-door",
|
||||||
|
prompt: "Enter House",
|
||||||
|
distance: expect.any(Number),
|
||||||
|
range: 2
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("dispatches scene transition requests for Scene Exit click targets", () => {
|
||||||
|
const runtimeScene = createRuntimeSceneFixture();
|
||||||
|
runtimeScene.entities.sceneExits.push({
|
||||||
|
entityId: "entity-scene-exit-house-door",
|
||||||
|
position: {
|
||||||
|
x: 0,
|
||||||
|
y: 1,
|
||||||
|
z: 1
|
||||||
|
},
|
||||||
|
radius: 2,
|
||||||
|
prompt: "Enter House",
|
||||||
|
enabled: true,
|
||||||
|
targetSceneId: "scene-house",
|
||||||
|
targetEntryEntityId: "entity-scene-entry-house-front"
|
||||||
|
});
|
||||||
|
const dispatches: string[] = [];
|
||||||
|
const interactionSystem = new RuntimeInteractionSystem();
|
||||||
|
|
||||||
|
interactionSystem.dispatchClickInteraction(
|
||||||
|
"entity-scene-exit-house-door",
|
||||||
|
runtimeScene,
|
||||||
|
{
|
||||||
|
teleportPlayer: () => {
|
||||||
|
throw new Error("Teleport should not dispatch for a scene exit.");
|
||||||
|
},
|
||||||
|
activateSceneExit: (sceneExit) => {
|
||||||
|
dispatches.push(
|
||||||
|
`${sceneExit.entityId}:${sceneExit.targetSceneId}:${sceneExit.targetEntryEntityId}`
|
||||||
|
);
|
||||||
|
},
|
||||||
|
toggleBrushVisibility: () => {
|
||||||
|
throw new Error("Visibility should not dispatch for a scene exit.");
|
||||||
|
},
|
||||||
|
playAnimation: () => {},
|
||||||
|
stopAnimation: () => {},
|
||||||
|
playSound: () => {},
|
||||||
|
stopSound: () => {}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(dispatches).toEqual([
|
||||||
|
"entity-scene-exit-house-door:scene-house:entity-scene-entry-house-front"
|
||||||
|
]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user