Custom dialogue node

This commit is contained in:
Marco 2025-10-09 10:20:03 +02:00
commit 74dcd6d90c
3 changed files with 50 additions and 14 deletions

View file

@ -10,21 +10,33 @@ namespace Cirno.Scripts.Activables;
public partial class DialogueActor3D : Area3D, IInteractable
{
[Export] public StringName TimelineName = "";
[Export(PropertyHint.MultilineText)]
public string CustomDialogue = "";
private DialogueTools _dialogueInstance;
public override void _Ready()
{
if (Engine.IsEditorHint()) return;
if (string.IsNullOrWhiteSpace(TimelineName))
if (string.IsNullOrWhiteSpace(TimelineName) && string.IsNullOrWhiteSpace(CustomDialogue))
{
this.RemoveFromGroup("Interactable");
return;
}
_dialogueInstance = new DialogueTools();
_dialogueInstance.Init(this, TimelineName);
if (!string.IsNullOrWhiteSpace(TimelineName))
{
_dialogueInstance.Init(this, TimelineName);
}
else
{
_dialogueInstance.Init(this, CustomDialogue);
}
}
public void _func_godot_apply_properties(Dictionary<string, string> props)
{
TimelineName = props["timeline"];
@ -33,9 +45,9 @@ public partial class DialogueActor3D : Area3D, IInteractable
public bool Activate(ActivationType activationType = ActivationType.Toggle)
{
if (Engine.IsEditorHint()) return false;
if (string.IsNullOrWhiteSpace(TimelineName)) return false;
if (string.IsNullOrWhiteSpace(TimelineName) && string.IsNullOrWhiteSpace(CustomDialogue)) return false;
_dialogueInstance.Start(this);
return true;
}
@ -56,7 +68,7 @@ public partial class DialogueActor3D : Area3D, IInteractable
{
return this.GetGlobalPosition2D();
}
return CameraController3D.Instance.UnprojectPosition(this.GlobalPosition);
}
}