Implement automatic retargeting or clearing of active runtime target
This commit is contained in:
@@ -886,6 +886,8 @@ export class RuntimeHost {
|
|||||||
this.resolveThirdPersonTargetAssist(),
|
this.resolveThirdPersonTargetAssist(),
|
||||||
handleRuntimeTargetLookInput: (input) =>
|
handleRuntimeTargetLookInput: (input) =>
|
||||||
this.handleRuntimeTargetLookInput(input),
|
this.handleRuntimeTargetLookInput(input),
|
||||||
|
handleRuntimeTargetLookBoundaryReached: () =>
|
||||||
|
this.retargetOrClearActiveRuntimeTarget(),
|
||||||
isCameraDrivenExternally: () =>
|
isCameraDrivenExternally: () =>
|
||||||
this.resolveActiveRuntimeCameraRig() !== null ||
|
this.resolveActiveRuntimeCameraRig() !== null ||
|
||||||
this.resolveDialogueAttentionNpc() !== null,
|
this.resolveDialogueAttentionNpc() !== null,
|
||||||
@@ -5851,6 +5853,30 @@ export class RuntimeHost {
|
|||||||
return bestCandidate;
|
return bestCandidate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private retargetOrClearActiveRuntimeTarget(): boolean {
|
||||||
|
if (this.activeRuntimeTargetReference === null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const replacementTarget =
|
||||||
|
this.resolveRuntimeTargetCandidateNearestScreenCenter({
|
||||||
|
exclude: this.activeRuntimeTargetReference,
|
||||||
|
maxDistanceFromPlayer: TARGETING_AUTO_RETARGET_SAFE_DISTANCE
|
||||||
|
});
|
||||||
|
|
||||||
|
if (replacementTarget !== null) {
|
||||||
|
this.setActiveRuntimeTargetReference({
|
||||||
|
kind: replacementTarget.kind,
|
||||||
|
entityId: replacementTarget.entityId
|
||||||
|
});
|
||||||
|
this.proposedRuntimeTarget = replacementTarget;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setActiveRuntimeTargetReference(null);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private updateActiveRuntimeTargetLockState() {
|
private updateActiveRuntimeTargetLockState() {
|
||||||
if (
|
if (
|
||||||
this.activeRuntimeTargetReference === null ||
|
this.activeRuntimeTargetReference === null ||
|
||||||
@@ -5873,22 +5899,7 @@ export class RuntimeHost {
|
|||||||
activeTarget.center
|
activeTarget.center
|
||||||
) > TARGETING_ACTIVE_TARGET_RELEASE_DISTANCE
|
) > TARGETING_ACTIVE_TARGET_RELEASE_DISTANCE
|
||||||
) {
|
) {
|
||||||
const replacementTarget =
|
this.retargetOrClearActiveRuntimeTarget();
|
||||||
this.resolveRuntimeTargetCandidateNearestScreenCenter({
|
|
||||||
exclude: this.activeRuntimeTargetReference,
|
|
||||||
maxDistanceFromPlayer: TARGETING_AUTO_RETARGET_SAFE_DISTANCE
|
|
||||||
});
|
|
||||||
|
|
||||||
if (replacementTarget !== null) {
|
|
||||||
this.setActiveRuntimeTargetReference({
|
|
||||||
kind: replacementTarget.kind,
|
|
||||||
entityId: replacementTarget.entityId
|
|
||||||
});
|
|
||||||
this.proposedRuntimeTarget = replacementTarget;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setActiveRuntimeTargetReference(null);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user