mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-09 14:05:53 +00:00
Custom dialogue node
This commit is contained in:
parent
7cb5bfb593
commit
74dcd6d90c
3 changed files with 50 additions and 14 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue