mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
74 lines
No EOL
1.9 KiB
C#
74 lines
No EOL
1.9 KiB
C#
using Cirno.Scripts.Interactables;
|
|
using Cirno.Scripts.Misc;
|
|
using Cirno.Scripts.Utils;
|
|
using Godot;
|
|
using Godot.Collections;
|
|
|
|
namespace Cirno.Scripts.Activables;
|
|
|
|
[Tool]
|
|
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) && string.IsNullOrWhiteSpace(CustomDialogue))
|
|
{
|
|
this.RemoveFromGroup("Interactable");
|
|
|
|
return;
|
|
}
|
|
|
|
_dialogueInstance = new DialogueTools();
|
|
|
|
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"];
|
|
}
|
|
|
|
public bool Activate(ActivationType activationType = ActivationType.Toggle)
|
|
{
|
|
if (Engine.IsEditorHint()) return false;
|
|
if (string.IsNullOrWhiteSpace(TimelineName) && string.IsNullOrWhiteSpace(CustomDialogue)) return false;
|
|
_dialogueInstance.Start(this);
|
|
|
|
return true;
|
|
}
|
|
|
|
public bool CanActivate()
|
|
{
|
|
if (Engine.IsEditorHint()) return false;
|
|
return true;
|
|
}
|
|
|
|
public Vector2 GetGlobalPosition2D()
|
|
{
|
|
return new Vector2(this.GlobalPosition.X, this.GlobalPosition.Z);
|
|
}
|
|
|
|
public Vector2 GetScreenPosition()
|
|
{
|
|
if (CameraController3D.Instance is null)
|
|
{
|
|
return this.GetGlobalPosition2D();
|
|
}
|
|
|
|
return CameraController3D.Instance.UnprojectPosition(this.GlobalPosition);
|
|
}
|
|
} |