feat(npc): Update NPC talk icon positions and enhance personal space behavior

This commit is contained in:
Z. Cliffe Schreuders
2025-11-10 00:08:02 +00:00
parent 90e33de7f2
commit 9b49e43b79
3 changed files with 21 additions and 3 deletions

View File

@@ -38,7 +38,6 @@
<link rel="stylesheet" href="css/notes.css">
<link rel="stylesheet" href="css/bluetooth-scanner.css">
<link rel="stylesheet" href="css/biometrics-minigame.css">
<link rel="stylesheet" href="css/lockpick-set-minigame.css">
<link rel="stylesheet" href="css/container-minigame.css">
<link rel="stylesheet" href="css/phone-chat-minigame.css">
<link rel="stylesheet" href="css/person-chat-minigame.css">

View File

@@ -66,7 +66,26 @@ function getInteractionDistance(playerSprite, targetX, targetY) {
return dx * dx + dy * dy; // Return squared distance for performance
}
// Update NPC talk icon positions every frame (even when not checking interactions)
function updateNPCTalkIcons() {
// Iterate through all rooms and update icon positions for visible icons
Object.values(rooms).forEach(room => {
if (room.npcSprites) {
room.npcSprites.forEach(sprite => {
if (sprite.interactionIndicator && sprite.interactionIndicator.visible) {
const iconX = Math.round(sprite.x + 5);
const iconY = Math.round(sprite.y - 38);
sprite.interactionIndicator.setPosition(iconX, iconY);
}
});
}
});
}
export function checkObjectInteractions() {
// Update NPC talk icons every frame to follow moving NPCs
updateNPCTalkIcons();
// Skip if not enough time has passed since last check
const currentTime = performance.now();
if (this.lastInteractionCheck &&
@@ -292,7 +311,7 @@ export function checkObjectInteractions() {
sprite.talkIconVisible = false;
}
} else if (sprite.interactionIndicator && sprite.talkIconVisible) {
// Update position even when not highlighted (for smooth following)
// Update position every frame when icon is visible (smooth following)
const iconX = Math.round(sprite.x + 5);
const iconY = Math.round(sprite.y - 38);
sprite.interactionIndicator.setPosition(iconX, iconY);

View File

@@ -109,7 +109,7 @@
"enabled": true,
"distance": 48,
"backAwaySpeed": 60,
"backAwayDistance": 10
"backAwayDistance": 50
}
},
"_comment": "Fast backing: 10px increments instead of 5px"