From 1f632c60bc48d9692eaa010feb85fdf463c8bcbc Mon Sep 17 00:00:00 2001 From: henrisel Date: Fri, 13 Feb 2026 17:01:16 +0200 Subject: [PATCH] shape detection npc speaks from radio, avoid interrupting voicelines --- .../_PROJECT/Scenes/DeltaBuilding_base.unity | 4 ++-- .../ModeGeneration/NPCs/NPCController.cs | 6 +++--- .../ModeGeneration/NPCs/ShapeDetectionNPC.cs | 19 ++++++++++++------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Assets/_PROJECT/Scenes/DeltaBuilding_base.unity b/Assets/_PROJECT/Scenes/DeltaBuilding_base.unity index ef7f94e3..d630c8e7 100644 --- a/Assets/_PROJECT/Scenes/DeltaBuilding_base.unity +++ b/Assets/_PROJECT/Scenes/DeltaBuilding_base.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:43ceb645e43003c3e4d0b51b4772bd99911a40fd534589eef030a85996bdcfef -size 68527037 +oid sha256:3911b0a1f70724389de630cd89e90ef1a7d06711515620db94ffd99ec7fdf2ff +size 68527712 diff --git a/Assets/_PROJECT/Scripts/ModeGeneration/NPCs/NPCController.cs b/Assets/_PROJECT/Scripts/ModeGeneration/NPCs/NPCController.cs index f41f6422..f1712fea 100644 --- a/Assets/_PROJECT/Scripts/ModeGeneration/NPCs/NPCController.cs +++ b/Assets/_PROJECT/Scripts/ModeGeneration/NPCs/NPCController.cs @@ -146,8 +146,7 @@ public abstract class NPCController : MonoBehaviour protected virtual void OnPlayerLeave() {} - - public void SpeakVoiceLine(int voiceLineId) + public void SpeakVoiceLine(int voiceLineId, GameObject emitter = null, float radioAmount = 0f) { if (voiceLineId < 0 || voiceLineId >= voiceLineKeys.Length) { @@ -163,7 +162,8 @@ public abstract class NPCController : MonoBehaviour LoadCurve(key); // load RMS data - currentVoicelineEvent = AudioManager.Instance.PlayDialogue(characterSpecificFolder + "/" + key, gameObject); + emitter = emitter ?? gameObject; + currentVoicelineEvent = AudioManager.Instance.PlayDialogue(characterSpecificFolder + "/" + key, emitter, radioAmount); if (!currentVoicelineEvent.isValid()) { Debug.LogError("Failed to start dialogue event."); diff --git a/Assets/_PROJECT/Scripts/ModeGeneration/NPCs/ShapeDetectionNPC.cs b/Assets/_PROJECT/Scripts/ModeGeneration/NPCs/ShapeDetectionNPC.cs index 4af40f81..c476e070 100644 --- a/Assets/_PROJECT/Scripts/ModeGeneration/NPCs/ShapeDetectionNPC.cs +++ b/Assets/_PROJECT/Scripts/ModeGeneration/NPCs/ShapeDetectionNPC.cs @@ -14,6 +14,7 @@ public class ShapeDetectionNPC : NPCController public Texture2D GeneratedTexture { get; private set; } public Image imageDisplay; public ShapeScanner shapeScanner; + public float radioAmount = 1f; public GameObject GeneratedModel { get; private set; } public Transform modelSpawnPoint; @@ -79,10 +80,14 @@ public class ShapeDetectionNPC : NPCController { if (state == 1) { - SpeakVoiceLine(0); + SpeakVoiceLine(0, radio.gameObject, radioAmount); await Task.Delay(2000); - SpeakVoiceLine(1); - Invoke(nameof(CallPlayer), 4f); + // Has the player maybe picked up the radio during the last 2 seconds? + if (state == 1) + { + SpeakVoiceLine(1, radio.gameObject, radioAmount); + Invoke(nameof(CallPlayer), 4f); + } } } @@ -90,7 +95,7 @@ public class ShapeDetectionNPC : NPCController { if (state == 1) { - SpeakVoiceLine(2); + SpeakVoiceLine(2, radio.gameObject, radioAmount); state = 2; await Task.Delay(5000); questMarker.MoveTo(microphoneStand.transform); @@ -102,7 +107,7 @@ public class ShapeDetectionNPC : NPCController { if (state == 2) { - SpeakVoiceLine(3); + SpeakVoiceLine(3, radio.gameObject, radioAmount); state = 3; questMarker.MoveTo(imageGenerationButton.transform); } @@ -119,7 +124,7 @@ public class ShapeDetectionNPC : NPCController imageGenerationButton.Deactivate(); if (state == 3) { - SpeakVoiceLine(4); + SpeakVoiceLine(4, radio.gameObject, radioAmount); state = 4; questMarker.MoveTo(modelGenerationButton.transform); modelGenerationButton.Deactivate(); @@ -130,7 +135,7 @@ public class ShapeDetectionNPC : NPCController { if (state == 4) { - SpeakVoiceLine(5); + SpeakVoiceLine(5, radio.gameObject, radioAmount); state = 5; questMarker.MoveTo(shapeScanner.transform); }