Update buildRuntimeControlSurface to include scheduler state and handle duplicate actor IDs
This commit is contained in:
@@ -858,6 +858,7 @@ interface RuntimeSceneCollections {
|
|||||||
entities: RuntimeEntityCollection;
|
entities: RuntimeEntityCollection;
|
||||||
localLights: RuntimeLocalLightCollection;
|
localLights: RuntimeLocalLightCollection;
|
||||||
npcDefinitions: RuntimeNpcDefinition[];
|
npcDefinitions: RuntimeNpcDefinition[];
|
||||||
|
scheduler: RuntimeResolvedProjectScheduleState;
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildRuntimeControlSurface(
|
function buildRuntimeControlSurface(
|
||||||
@@ -869,6 +870,20 @@ function buildRuntimeControlSurface(
|
|||||||
const channels: RuntimeControlSurfaceDefinition["channels"] = [];
|
const channels: RuntimeControlSurfaceDefinition["channels"] = [];
|
||||||
const resolved = createEmptyRuntimeResolvedControlState();
|
const resolved = createEmptyRuntimeResolvedControlState();
|
||||||
const defaultSource = createDefaultResolvedControlSource();
|
const defaultSource = createDefaultResolvedControlSource();
|
||||||
|
const seenActorIds = new Set<string>();
|
||||||
|
|
||||||
|
for (const npc of collections.npcDefinitions) {
|
||||||
|
if (seenActorIds.has(npc.actorId)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
seenActorIds.add(npc.actorId);
|
||||||
|
targets.push(
|
||||||
|
createControlTargetDescriptor(createActorControlTargetRef(npc.actorId), [
|
||||||
|
"actorPresence"
|
||||||
|
])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
for (const pointLight of collections.localLights.pointLights) {
|
for (const pointLight of collections.localLights.pointLights) {
|
||||||
const target = createLightControlTargetRef(
|
const target = createLightControlTargetRef(
|
||||||
@@ -1006,7 +1021,10 @@ function buildRuntimeControlSurface(
|
|||||||
return createRuntimeControlSurfaceDefinition({
|
return createRuntimeControlSurfaceDefinition({
|
||||||
targets,
|
targets,
|
||||||
channels,
|
channels,
|
||||||
resolved
|
resolved: applyRuntimeProjectScheduleToControlState(
|
||||||
|
resolved,
|
||||||
|
collections.scheduler
|
||||||
|
)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user