I'm currently working on the dialogue system in Godot 4 using Dialogue Manager 3. I created a function "checkDialogueFinished" to check whether the dialogue event has ended already. Its supposed to get subscribed to in the "checkInteract" function but it never does. Any help will be appreciated, tyia!
using Godot;
using System;
using DialogueManagerRuntime;
public partial class ObjectInteract : Node {
private Resource dialogue = GD.Load<Resource>("res://Dialogue/Test.dialogue");
private bool isInDialogue = false;
/*
Function Desc: Gets the distance between an object and the player via slope
@param ObjectX -> x-coordinate of the Object
@param ObjectY -> y-coordinate of the Object
@param PlayerX -> x-coordinate of the Player
@param PlayerY -> y-coordinate of the Player
*/
public float getDistanceSlope(float ObjectX, float ObjectY, float PlayerX, float PlayerY){
float dx = ObjectX - PlayerX;
float dy = ObjectY - PlayerY;
float distance = dx * dx + dy * dy;
float trueDistance = (float)Math.Sqrt(distance);
return distance;
}
/*
Function Desc: Checks whether the player is close enough to interact with the object
@param slope -> Distance between object and player
@param objectName -> Name of the object
*/
public void checkInteract(float slope){
if (slope < 850 && Input.IsActionJustPressed("interact") && !isInDialogue){
DialogueManager.ShowExampleDialogueBalloon(dialogue);
isInDialogue = true;
DialogueManager.DialogueEnded += checkDialogueFinished;
GD.Print("Event fired!");
}
}
private void checkDialogueFinished(Resource dialogue) {
GD.Print("Event ended, setting isInDialogue back to false!");
isInDialogue = false;
DialogueManager.DialogueEnded -= checkDialogueFinished;
}
}
I tried checking the DialogueManagerRuntime but still haven't found a solution.