Cancel dialogue when player walks away
This commit is contained in:
@@ -17,6 +17,8 @@ public partial class Npc : Node3D
|
|||||||
|
|
||||||
private bool _isInDialogueZone = false;
|
private bool _isInDialogueZone = false;
|
||||||
|
|
||||||
|
private Node _dialogueBalloon;
|
||||||
|
|
||||||
public void OnReady()
|
public void OnReady()
|
||||||
{
|
{
|
||||||
DialogueZone.BodyEntered += DialogueZone_BodyEntered;
|
DialogueZone.BodyEntered += DialogueZone_BodyEntered;
|
||||||
@@ -26,6 +28,8 @@ public partial class Npc : Node3D
|
|||||||
private void DialogueZone_BodyExited(Node3D body)
|
private void DialogueZone_BodyExited(Node3D body)
|
||||||
{
|
{
|
||||||
_isInDialogueZone = false;
|
_isInDialogueZone = false;
|
||||||
|
if (_dialogueBalloon != null)
|
||||||
|
_dialogueBalloon.QueueFree();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DialogueZone_BodyEntered(Node3D body)
|
private void DialogueZone_BodyEntered(Node3D body)
|
||||||
@@ -36,6 +40,6 @@ public partial class Npc : Node3D
|
|||||||
public override void _UnhandledInput(InputEvent @event)
|
public override void _UnhandledInput(InputEvent @event)
|
||||||
{
|
{
|
||||||
if (Input.IsActionJustPressed(GameInputs.Throw) && _isInDialogueZone)
|
if (Input.IsActionJustPressed(GameInputs.Throw) && _isInDialogueZone)
|
||||||
DialogueManager.ShowDialogueBalloonScene(DialogueController.DialogueBalloon, DialogueOptions.First(), "introduction");
|
_dialogueBalloon = DialogueManager.ShowDialogueBalloonScene(DialogueController.DialogueBalloon, DialogueOptions.First(), "introduction");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
[ext_resource type="Resource" uid="uid://cf7ycgdiihyh" path="res://src/npc/rat/ratdialogue.dialogue" id="2_uo38w"]
|
[ext_resource type="Resource" uid="uid://cf7ycgdiihyh" path="res://src/npc/rat/ratdialogue.dialogue" id="2_uo38w"]
|
||||||
|
|
||||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_wfhgc"]
|
[sub_resource type="CylinderShape3D" id="CylinderShape3D_wfhgc"]
|
||||||
radius = 1.5
|
radius = 2.5
|
||||||
|
|
||||||
[node name="NPC" type="Node3D"]
|
[node name="NPC" type="Node3D"]
|
||||||
script = ExtResource("1_cpdf2")
|
script = ExtResource("1_cpdf2")
|
||||||
|
|||||||
Reference in New Issue
Block a user