Enhance runtime interaction system to require NPC targetability
This commit is contained in:
@@ -564,6 +564,7 @@ function collectRuntimeInteractionTargetSources(
|
|||||||
options: {
|
options: {
|
||||||
useTargetingReach?: boolean;
|
useTargetingReach?: boolean;
|
||||||
interactionReachMeters?: number;
|
interactionReachMeters?: number;
|
||||||
|
requireNpcTargetable?: boolean;
|
||||||
} = {}
|
} = {}
|
||||||
): RuntimeInteractionTargetSource[] {
|
): RuntimeInteractionTargetSource[] {
|
||||||
const candidates: RuntimeInteractionTargetSource[] = [];
|
const candidates: RuntimeInteractionTargetSource[] = [];
|
||||||
@@ -623,8 +624,13 @@ function collectRuntimeInteractionTargetSources(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const hasClickLinks = hasTriggerLinks(runtimeScene, npc.entityId, "click");
|
const hasClickLinks = hasTriggerLinks(runtimeScene, npc.entityId, "click");
|
||||||
|
const requiresTargetable = options.requireNpcTargetable ?? false;
|
||||||
|
|
||||||
if (!hasClickLinks) {
|
if (requiresTargetable) {
|
||||||
|
if (!npc.targetable) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else if (!hasClickLinks) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -684,7 +690,7 @@ export function resolveRuntimeTargetCandidates(options: {
|
|||||||
for (const source of collectRuntimeInteractionTargetSources(
|
for (const source of collectRuntimeInteractionTargetSources(
|
||||||
options.interactionOrigin,
|
options.interactionOrigin,
|
||||||
options.runtimeScene,
|
options.runtimeScene,
|
||||||
{ useTargetingReach: true }
|
{ useTargetingReach: true, requireNpcTargetable: true }
|
||||||
)) {
|
)) {
|
||||||
const toTarget = subtractVec3(source.center, options.cameraPosition);
|
const toTarget = subtractVec3(source.center, options.cameraPosition);
|
||||||
const cameraDistanceSquared = lengthSquaredVec3(toTarget);
|
const cameraDistanceSquared = lengthSquaredVec3(toTarget);
|
||||||
@@ -776,7 +782,7 @@ export function resolveRuntimeTargetReference(
|
|||||||
if (
|
if (
|
||||||
npc === null ||
|
npc === null ||
|
||||||
!npc.visible ||
|
!npc.visible ||
|
||||||
!hasTriggerLinks(runtimeScene, npc.entityId, "click")
|
!npc.targetable
|
||||||
) {
|
) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user