Give item to npc

This commit is contained in:
2025-06-28 18:12:04 -07:00
parent 0880b74695
commit 54d9bcf52d
14 changed files with 69 additions and 43 deletions

View File

@@ -20,45 +20,53 @@ public partial class Npc : Node3D
public void OnReady()
{
SetPhysicsProcess(true);
DialogueZone.BodyEntered += DialogueZone_BodyEntered;
DialogueZone.BodyExited += DialogueZone_BodyExited;
Hitbox.AreaEntered += Hitbox_AreaEntered;
SetPhysicsProcess(true);
DialogueZone.BodyEntered += DialogueZone_BodyEntered;
DialogueZone.BodyExited += DialogueZone_BodyExited;
Hitbox.AreaEntered += Hitbox_AreaEntered;
}
private void Hitbox_AreaEntered(Area3D area)
{
DialogueController.ShowDialogue(Dialogue, "hit");
if (area.GetOwner() is ThrownItem thrownItem)
{
DialogueController.ShowDialogue(Dialogue, "get_item");
thrownItem.QueueFree();
}
else
{
DialogueController.ShowDialogue(Dialogue, "hit");
}
}
private void Hitbox_BodyEntered(Node body)
{
DialogueController.ShowDialogue(Dialogue, "hit");
DialogueController.ShowDialogue(Dialogue, "hit");
}
private void DialogueZone_BodyExited(Node3D body)
{
_isInDialogueZone = false;
DialogueController.Interrupt();
_isInDialogueZone = false;
DialogueController.Interrupt();
}
private void DialogueZone_BodyEntered(Node3D body)
{
_isInDialogueZone = true;
_isInDialogueZone = true;
}
public override void _UnhandledInput(InputEvent @event)
{
if (@event.IsActionPressed(GameInputs.Interact) && _isInDialogueZone)
{
if (_isIntroductionComplete)
DialogueController.ShowDialogue(Dialogue, "general");
else
{
DialogueController.ShowDialogue(Dialogue, "introduction");
_isIntroductionComplete = true;
}
}
if (@event.IsActionPressed(GameInputs.Interact) && _isInDialogueZone)
{
if (_isIntroductionComplete)
DialogueController.ShowDialogue(Dialogue, "general");
else
{
DialogueController.ShowDialogue(Dialogue, "introduction");
_isIntroductionComplete = true;
}
}
}
}