Update tests to include actor control targets and routines
This commit is contained in:
@@ -8,16 +8,20 @@ import {
|
|||||||
} from "../../src/assets/project-assets";
|
} from "../../src/assets/project-assets";
|
||||||
import {
|
import {
|
||||||
createInteractableEntity,
|
createInteractableEntity,
|
||||||
|
createNpcEntity,
|
||||||
createPointLightEntity,
|
createPointLightEntity,
|
||||||
createSoundEmitterEntity,
|
createSoundEmitterEntity,
|
||||||
createTriggerVolumeEntity
|
createTriggerVolumeEntity
|
||||||
} from "../../src/entities/entity-instances";
|
} from "../../src/entities/entity-instances";
|
||||||
import {
|
import {
|
||||||
|
createActorControlTargetRef,
|
||||||
createLightControlTargetRef,
|
createLightControlTargetRef,
|
||||||
|
createSetActorPresenceControlEffect,
|
||||||
createSetLightEnabledControlEffect
|
createSetLightEnabledControlEffect
|
||||||
} from "../../src/controls/control-surface";
|
} from "../../src/controls/control-surface";
|
||||||
import { createEmptySceneDocument } from "../../src/document/scene-document";
|
import { createEmptySceneDocument } from "../../src/document/scene-document";
|
||||||
import { createControlInteractionLink } from "../../src/interactions/interaction-links";
|
import { createControlInteractionLink } from "../../src/interactions/interaction-links";
|
||||||
|
import { createProjectScheduleRoutine } from "../../src/scheduler/project-scheduler";
|
||||||
import { RuntimeInteractionSystem } from "../../src/runtime-three/runtime-interaction-system";
|
import { RuntimeInteractionSystem } from "../../src/runtime-three/runtime-interaction-system";
|
||||||
import { buildRuntimeSceneFromDocument } from "../../src/runtime-three/runtime-scene-build";
|
import { buildRuntimeSceneFromDocument } from "../../src/runtime-three/runtime-scene-build";
|
||||||
|
|
||||||
@@ -36,6 +40,10 @@ describe("runtime control foundation", () => {
|
|||||||
id: "entity-sound-main",
|
id: "entity-sound-main",
|
||||||
audioAssetId: "asset-audio-main"
|
audioAssetId: "asset-audio-main"
|
||||||
});
|
});
|
||||||
|
const npc = createNpcEntity({
|
||||||
|
id: "entity-npc-vendor",
|
||||||
|
actorId: "actor-market-vendor"
|
||||||
|
});
|
||||||
const triggerVolume = createTriggerVolumeEntity({
|
const triggerVolume = createTriggerVolumeEntity({
|
||||||
id: "entity-trigger-main"
|
id: "entity-trigger-main"
|
||||||
});
|
});
|
||||||
@@ -79,8 +87,22 @@ describe("runtime control foundation", () => {
|
|||||||
assetId: modelAsset.id
|
assetId: modelAsset.id
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const document = createEmptySceneDocument();
|
||||||
|
document.scheduler.routines["routine-market-vendor"] =
|
||||||
|
createProjectScheduleRoutine({
|
||||||
|
id: "routine-market-vendor",
|
||||||
|
title: "Market Hours",
|
||||||
|
target: createActorControlTargetRef(npc.actorId),
|
||||||
|
startHour: 9,
|
||||||
|
endHour: 17,
|
||||||
|
effect: createSetActorPresenceControlEffect({
|
||||||
|
target: createActorControlTargetRef(npc.actorId),
|
||||||
|
active: true
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
const runtimeScene = buildRuntimeSceneFromDocument({
|
const runtimeScene = buildRuntimeSceneFromDocument({
|
||||||
...createEmptySceneDocument(),
|
...document,
|
||||||
assets: {
|
assets: {
|
||||||
[modelAsset.id]: modelAsset,
|
[modelAsset.id]: modelAsset,
|
||||||
[audioAsset.id]: audioAsset
|
[audioAsset.id]: audioAsset
|
||||||
@@ -92,12 +114,20 @@ describe("runtime control foundation", () => {
|
|||||||
[pointLight.id]: pointLight,
|
[pointLight.id]: pointLight,
|
||||||
[interactable.id]: interactable,
|
[interactable.id]: interactable,
|
||||||
[soundEmitter.id]: soundEmitter,
|
[soundEmitter.id]: soundEmitter,
|
||||||
|
[npc.id]: npc,
|
||||||
[triggerVolume.id]: triggerVolume
|
[triggerVolume.id]: triggerVolume
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(runtimeScene.control.targets).toEqual(
|
expect(runtimeScene.control.targets).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
|
expect.objectContaining({
|
||||||
|
target: {
|
||||||
|
kind: "actor",
|
||||||
|
actorId: npc.actorId
|
||||||
|
},
|
||||||
|
capabilities: ["actorPresence"]
|
||||||
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
target: {
|
target: {
|
||||||
kind: "entity",
|
kind: "entity",
|
||||||
@@ -145,6 +175,14 @@ describe("runtime control foundation", () => {
|
|||||||
]);
|
]);
|
||||||
expect(runtimeScene.control.resolved.discrete).toEqual(
|
expect(runtimeScene.control.resolved.discrete).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
|
expect.objectContaining({
|
||||||
|
type: "actorPresence",
|
||||||
|
target: {
|
||||||
|
kind: "actor",
|
||||||
|
actorId: npc.actorId
|
||||||
|
},
|
||||||
|
value: true
|
||||||
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
type: "lightEnabled",
|
type: "lightEnabled",
|
||||||
target: {
|
target: {
|
||||||
|
|||||||
Reference in New Issue
Block a user