mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-20 23:43:48 +00:00
Custom dialogue node
This commit is contained in:
parent
7cb5bfb593
commit
74dcd6d90c
3 changed files with 50 additions and 14 deletions
|
|
@ -3446,3 +3446,11 @@ texture = ExtResource("99_dbn2g")
|
||||||
[node name="NavigationRegion3D" type="NavigationRegion3D" parent="."]
|
[node name="NavigationRegion3D" type="NavigationRegion3D" parent="."]
|
||||||
visible = false
|
visible = false
|
||||||
navigation_mesh = SubResource("NavigationMesh_xhmq5")
|
navigation_mesh = SubResource("NavigationMesh_xhmq5")
|
||||||
|
|
||||||
|
[node name="Terminal" parent="." instance=ExtResource("42_isb8p")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.5675659, 1.6668701, 1.8129272)
|
||||||
|
CustomDialogue = "[style name=\"Terminal_Style\"]
|
||||||
|
computer: From\\: J.S.\\
|
||||||
|
Subject\\: Pizza\\
|
||||||
|
Asdfg
|
||||||
|
"
|
||||||
|
|
|
||||||
|
|
@ -10,21 +10,33 @@ namespace Cirno.Scripts.Activables;
|
||||||
public partial class DialogueActor3D : Area3D, IInteractable
|
public partial class DialogueActor3D : Area3D, IInteractable
|
||||||
{
|
{
|
||||||
[Export] public StringName TimelineName = "";
|
[Export] public StringName TimelineName = "";
|
||||||
|
[Export(PropertyHint.MultilineText)]
|
||||||
|
public string CustomDialogue = "";
|
||||||
|
|
||||||
private DialogueTools _dialogueInstance;
|
private DialogueTools _dialogueInstance;
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
if (Engine.IsEditorHint()) return;
|
if (Engine.IsEditorHint()) return;
|
||||||
if (string.IsNullOrWhiteSpace(TimelineName))
|
if (string.IsNullOrWhiteSpace(TimelineName) && string.IsNullOrWhiteSpace(CustomDialogue))
|
||||||
{
|
{
|
||||||
this.RemoveFromGroup("Interactable");
|
this.RemoveFromGroup("Interactable");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_dialogueInstance = new DialogueTools();
|
_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)
|
public void _func_godot_apply_properties(Dictionary<string, string> props)
|
||||||
{
|
{
|
||||||
TimelineName = props["timeline"];
|
TimelineName = props["timeline"];
|
||||||
|
|
@ -33,9 +45,9 @@ public partial class DialogueActor3D : Area3D, IInteractable
|
||||||
public bool Activate(ActivationType activationType = ActivationType.Toggle)
|
public bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||||
{
|
{
|
||||||
if (Engine.IsEditorHint()) return false;
|
if (Engine.IsEditorHint()) return false;
|
||||||
if (string.IsNullOrWhiteSpace(TimelineName)) return false;
|
if (string.IsNullOrWhiteSpace(TimelineName) && string.IsNullOrWhiteSpace(CustomDialogue)) return false;
|
||||||
_dialogueInstance.Start(this);
|
_dialogueInstance.Start(this);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -56,7 +68,7 @@ public partial class DialogueActor3D : Area3D, IInteractable
|
||||||
{
|
{
|
||||||
return this.GetGlobalPosition2D();
|
return this.GetGlobalPosition2D();
|
||||||
}
|
}
|
||||||
|
|
||||||
return CameraController3D.Instance.UnprojectPosition(this.GlobalPosition);
|
return CameraController3D.Instance.UnprojectPosition(this.GlobalPosition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -11,7 +11,9 @@ public partial class DialogueTools : RefCounted
|
||||||
private DialogueSkipListener _listener;
|
private DialogueSkipListener _listener;
|
||||||
|
|
||||||
private StringName TimelineName;
|
private StringName TimelineName;
|
||||||
|
|
||||||
|
private GodotObject _timelineContent;
|
||||||
|
|
||||||
public void Init(Node parent, StringName timelineName)
|
public void Init(Node parent, StringName timelineName)
|
||||||
{
|
{
|
||||||
_dialogic = parent.GetNode("/root/Dialogic");
|
_dialogic = parent.GetNode("/root/Dialogic");
|
||||||
|
|
@ -19,6 +21,21 @@ public partial class DialogueTools : RefCounted
|
||||||
TimelineName = timelineName;
|
TimelineName = timelineName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Init(Node parent, string timelineContent)
|
||||||
|
{
|
||||||
|
_dialogic = parent.GetNode("/root/Dialogic");
|
||||||
|
_dialogic.ProcessMode = Node.ProcessModeEnum.Always;
|
||||||
|
|
||||||
|
var contentArray = timelineContent.Split('\n');
|
||||||
|
|
||||||
|
var timelineScript = GD.Load<GDScript>("res://addons/dialogic/Resources/timeline.gd");
|
||||||
|
var timelineResource = (GodotObject)timelineScript.New();
|
||||||
|
|
||||||
|
timelineResource.Set("events", contentArray);
|
||||||
|
|
||||||
|
_timelineContent = timelineResource;
|
||||||
|
}
|
||||||
|
|
||||||
public void Start(Node parent)
|
public void Start(Node parent)
|
||||||
{
|
{
|
||||||
if (GlobalState.Instance.SessionSettings.SkipDialogues)
|
if (GlobalState.Instance.SessionSettings.SkipDialogues)
|
||||||
|
|
@ -26,18 +43,18 @@ public partial class DialogueTools : RefCounted
|
||||||
DialogueEndAction();
|
DialogueEndAction();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateSkipListener(parent);
|
CreateSkipListener(parent);
|
||||||
|
|
||||||
Hud.Instance?.HideHud();
|
Hud.Instance?.HideHud();
|
||||||
|
|
||||||
_dialogic.Connect("timeline_ended", Callable.From(OnTimelineEnded));
|
_dialogic.Connect("timeline_ended", Callable.From(OnTimelineEnded));
|
||||||
|
|
||||||
var dialogicNode =_dialogic.Call("start", TimelineName.ToString());
|
var dialogicNode = _dialogic.Call("start", string.IsNullOrWhiteSpace(TimelineName) ? _timelineContent : TimelineName.ToString());
|
||||||
((Node)dialogicNode).ProcessMode = Node.ProcessModeEnum.Always;
|
((Node)dialogicNode).ProcessMode = Node.ProcessModeEnum.Always;
|
||||||
ChangeState(GameState.Dialogue);
|
ChangeState(GameState.Dialogue);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ChangeState(GameState state)
|
private void ChangeState(GameState state)
|
||||||
{
|
{
|
||||||
GameStateManager.Instance.ChangeState(state);
|
GameStateManager.Instance.ChangeState(state);
|
||||||
|
|
@ -74,5 +91,4 @@ public partial class DialogueTools : RefCounted
|
||||||
{
|
{
|
||||||
_isComplete = true;
|
_isComplete = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue