Rat dialogue
This commit is contained in:
41
src/npc/Npc.cs
Normal file
41
src/npc/Npc.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using DialogueManagerRuntime;
|
||||
using GameJamDungeon;
|
||||
using Godot;
|
||||
using System.Linq;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class Npc : Node3D
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Node] public Area3D DialogueZone { get; set; } = default!;
|
||||
|
||||
[Export]
|
||||
public Godot.Collections.Array<Resource> DialogueOptions { get; set; } = default!;
|
||||
|
||||
private bool _isInDialogueZone = false;
|
||||
|
||||
public void OnReady()
|
||||
{
|
||||
DialogueZone.BodyEntered += DialogueZone_BodyEntered;
|
||||
DialogueZone.BodyExited += DialogueZone_BodyExited;
|
||||
}
|
||||
|
||||
private void DialogueZone_BodyExited(Node3D body)
|
||||
{
|
||||
_isInDialogueZone = false;
|
||||
}
|
||||
|
||||
private void DialogueZone_BodyEntered(Node3D body)
|
||||
{
|
||||
_isInDialogueZone = true;
|
||||
}
|
||||
|
||||
public override void _UnhandledInput(InputEvent @event)
|
||||
{
|
||||
if (Input.IsActionJustPressed(GameInputs.Throw) && _isInDialogueZone)
|
||||
DialogueManager.ShowDialogueBalloonScene(DialogueController.DialogueBalloon, DialogueOptions.First(), "introduction");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user