Add actor animation playback and path assignment controls
This commit is contained in:
@@ -1045,6 +1045,15 @@ export class RuntimeHost {
|
|||||||
case "actorPresence":
|
case "actorPresence":
|
||||||
this.applyActorPresenceControl(state.target.actorId, state.value);
|
this.applyActorPresenceControl(state.target.actorId, state.value);
|
||||||
return;
|
return;
|
||||||
|
case "actorAnimationPlayback":
|
||||||
|
this.applyActorAnimationPlaybackControl(
|
||||||
|
state.target,
|
||||||
|
state.clipName,
|
||||||
|
state.loop
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
case "actorPathAssignment":
|
||||||
|
return;
|
||||||
case "modelVisibility":
|
case "modelVisibility":
|
||||||
this.applyModelInstanceVisibilityControl(state.target, state.value);
|
this.applyModelInstanceVisibilityControl(state.target, state.value);
|
||||||
return;
|
return;
|
||||||
@@ -1358,6 +1367,45 @@ export class RuntimeHost {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private applyActorAnimationPlaybackControl(
|
||||||
|
target: ActorControlTargetRef,
|
||||||
|
clipName: string | null,
|
||||||
|
loop: boolean | undefined
|
||||||
|
) {
|
||||||
|
if (this.runtimeScene !== null) {
|
||||||
|
for (const npc of this.runtimeScene.npcDefinitions) {
|
||||||
|
if (npc.actorId !== target.actorId) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const nextClipName = clipName;
|
||||||
|
|
||||||
|
if (
|
||||||
|
npc.animationClipName === nextClipName &&
|
||||||
|
npc.animationLoop === loop
|
||||||
|
) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
npc.animationClipName = nextClipName;
|
||||||
|
npc.animationLoop = loop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const npcIds =
|
||||||
|
this.runtimeScene?.npcDefinitions
|
||||||
|
.filter((npc) => npc.actorId === target.actorId)
|
||||||
|
.map((npc) => npc.entityId) ?? [];
|
||||||
|
|
||||||
|
for (const npcId of npcIds) {
|
||||||
|
if (clipName === null) {
|
||||||
|
this.applyStopAnimationAction(npcId);
|
||||||
|
} else {
|
||||||
|
this.applyPlayAnimationAction(npcId, clipName, loop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private applySoundVolumeControl(
|
private applySoundVolumeControl(
|
||||||
target: SoundEmitterControlTargetRef,
|
target: SoundEmitterControlTargetRef,
|
||||||
volume: number
|
volume: number
|
||||||
@@ -1449,6 +1497,18 @@ export class RuntimeHost {
|
|||||||
case "setActorPresence":
|
case "setActorPresence":
|
||||||
this.applyActorPresenceControl(effect.target.actorId, effect.active);
|
this.applyActorPresenceControl(effect.target.actorId, effect.active);
|
||||||
break;
|
break;
|
||||||
|
case "playActorAnimation":
|
||||||
|
this.applyActorAnimationPlaybackControl(
|
||||||
|
effect.target,
|
||||||
|
effect.clipName,
|
||||||
|
effect.loop
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case "followActorPath":
|
||||||
|
console.warn(
|
||||||
|
"followActorPath is scheduler-owned in this slice and is ignored when dispatched directly."
|
||||||
|
);
|
||||||
|
break;
|
||||||
case "playModelAnimation":
|
case "playModelAnimation":
|
||||||
this.applyModelAnimationPlaybackControl(
|
this.applyModelAnimationPlaybackControl(
|
||||||
effect.target,
|
effect.target,
|
||||||
|
|||||||
Reference in New Issue
Block a user