2026-04-14 23:15:02 +02:00
|
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
createActorControlTargetRef,
|
|
|
|
|
createLightControlTargetRef,
|
|
|
|
|
createPlaySoundControlEffect,
|
|
|
|
|
createSetActorPresenceControlEffect,
|
|
|
|
|
createSetLightEnabledControlEffect,
|
|
|
|
|
createSoundEmitterControlTargetRef
|
|
|
|
|
} from "../../src/controls/control-surface";
|
|
|
|
|
import {
|
|
|
|
|
createControlInteractionLink,
|
|
|
|
|
createPlaySoundInteractionLink,
|
|
|
|
|
createTeleportPlayerInteractionLink,
|
|
|
|
|
createToggleVisibilityInteractionLink
|
|
|
|
|
} from "../../src/interactions/interaction-links";
|
|
|
|
|
import { createProjectScheduleRoutine } from "../../src/scheduler/project-scheduler";
|
|
|
|
|
import {
|
2026-04-14 23:20:59 +02:00
|
|
|
getInteractionLinkImpulseSteps,
|
2026-04-14 23:15:02 +02:00
|
|
|
getInteractionLinkSequenceSteps,
|
2026-04-14 23:20:59 +02:00
|
|
|
getProjectScheduleRoutineHeldSteps,
|
2026-04-14 23:15:02 +02:00
|
|
|
getProjectScheduleRoutineSequenceSteps
|
|
|
|
|
} from "../../src/sequencer/project-sequence-steps";
|
|
|
|
|
|
|
|
|
|
describe("project sequence steps", () => {
|
|
|
|
|
it("normalizes existing interaction link actions into shared sequence steps", () => {
|
|
|
|
|
const playSoundLink = createPlaySoundInteractionLink({
|
|
|
|
|
id: "link-play-sound",
|
|
|
|
|
sourceEntityId: "entity-trigger-main",
|
|
|
|
|
targetSoundEmitterId: "entity-sound-main"
|
|
|
|
|
});
|
|
|
|
|
const teleportLink = createTeleportPlayerInteractionLink({
|
|
|
|
|
id: "link-teleport",
|
|
|
|
|
sourceEntityId: "entity-trigger-main",
|
|
|
|
|
targetEntityId: "entity-teleport-target"
|
|
|
|
|
});
|
|
|
|
|
const visibilityLink = createToggleVisibilityInteractionLink({
|
|
|
|
|
id: "link-hide-brush",
|
|
|
|
|
sourceEntityId: "entity-trigger-main",
|
|
|
|
|
targetBrushId: "brush-main",
|
|
|
|
|
visible: false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
expect(getInteractionLinkSequenceSteps(playSoundLink)).toEqual([
|
|
|
|
|
{
|
2026-04-14 23:20:59 +02:00
|
|
|
stepClass: "impulse",
|
2026-04-14 23:15:02 +02:00
|
|
|
type: "controlEffect",
|
|
|
|
|
effect: createPlaySoundControlEffect({
|
|
|
|
|
target: createSoundEmitterControlTargetRef("entity-sound-main")
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
]);
|
|
|
|
|
expect(getInteractionLinkSequenceSteps(teleportLink)).toEqual([
|
|
|
|
|
{
|
2026-04-14 23:20:59 +02:00
|
|
|
stepClass: "impulse",
|
2026-04-14 23:15:02 +02:00
|
|
|
type: "teleportPlayer",
|
|
|
|
|
targetEntityId: "entity-teleport-target"
|
|
|
|
|
}
|
|
|
|
|
]);
|
|
|
|
|
expect(getInteractionLinkSequenceSteps(visibilityLink)).toEqual([
|
|
|
|
|
{
|
2026-04-14 23:20:59 +02:00
|
|
|
stepClass: "impulse",
|
2026-04-15 01:43:08 +02:00
|
|
|
type: "setVisibility",
|
|
|
|
|
target: {
|
|
|
|
|
kind: "brush",
|
|
|
|
|
brushId: "brush-main"
|
|
|
|
|
},
|
|
|
|
|
mode: "hide"
|
2026-04-14 23:15:02 +02:00
|
|
|
}
|
|
|
|
|
]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("projects schedule routines into shared sequence steps", () => {
|
|
|
|
|
const actorTarget = createActorControlTargetRef("actor-guard");
|
|
|
|
|
const lightTarget = createLightControlTargetRef(
|
|
|
|
|
"pointLight",
|
|
|
|
|
"entity-point-light-main"
|
|
|
|
|
);
|
|
|
|
|
const actorRoutine = createProjectScheduleRoutine({
|
|
|
|
|
id: "routine-guard",
|
|
|
|
|
title: "Guard Duty",
|
|
|
|
|
target: actorTarget,
|
|
|
|
|
effects: [
|
|
|
|
|
createSetActorPresenceControlEffect({
|
|
|
|
|
target: actorTarget,
|
|
|
|
|
active: true
|
|
|
|
|
})
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
const lightRoutine = createProjectScheduleRoutine({
|
|
|
|
|
id: "routine-light",
|
|
|
|
|
title: "Night Light",
|
|
|
|
|
target: lightTarget,
|
|
|
|
|
effect: createSetLightEnabledControlEffect({
|
|
|
|
|
target: lightTarget,
|
|
|
|
|
enabled: false
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
const directControlLink = createControlInteractionLink({
|
|
|
|
|
id: "link-light-control",
|
|
|
|
|
sourceEntityId: "entity-trigger-main",
|
|
|
|
|
effect: createSetLightEnabledControlEffect({
|
|
|
|
|
target: lightTarget,
|
|
|
|
|
enabled: false
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-14 23:20:59 +02:00
|
|
|
expect(getProjectScheduleRoutineHeldSteps(actorRoutine)).toEqual([
|
2026-04-14 23:15:02 +02:00
|
|
|
{
|
2026-04-14 23:20:59 +02:00
|
|
|
stepClass: "held",
|
2026-04-14 23:15:02 +02:00
|
|
|
type: "controlEffect",
|
|
|
|
|
effect: createSetActorPresenceControlEffect({
|
|
|
|
|
target: actorTarget,
|
|
|
|
|
active: true
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
]);
|
2026-04-14 23:20:59 +02:00
|
|
|
expect(getInteractionLinkImpulseSteps(directControlLink)).toEqual([
|
|
|
|
|
{
|
|
|
|
|
stepClass: "impulse",
|
|
|
|
|
type: "controlEffect",
|
|
|
|
|
effect: createSetLightEnabledControlEffect({
|
|
|
|
|
target: lightTarget,
|
|
|
|
|
enabled: false
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
]);
|
2026-04-14 23:21:05 +02:00
|
|
|
expect(getProjectScheduleRoutineSequenceSteps(lightRoutine)).toEqual([
|
|
|
|
|
{
|
|
|
|
|
stepClass: "held",
|
|
|
|
|
type: "controlEffect",
|
|
|
|
|
effect: createSetLightEnabledControlEffect({
|
|
|
|
|
target: lightTarget,
|
|
|
|
|
enabled: false
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
]);
|
2026-04-14 23:15:02 +02:00
|
|
|
});
|
|
|
|
|
});
|