2025-06-24 11:06:33 +02:00
|
|
|
|
using Cirno.Scripts.Interactables;
|
|
|
|
|
|
using Cirno.Scripts.Misc;
|
|
|
|
|
|
using Cirno.Scripts.Utils;
|
|
|
|
|
|
using Godot;
|
|
|
|
|
|
using Godot.Collections;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Cirno.Scripts.Activables;
|
|
|
|
|
|
|
|
|
|
|
|
[Tool]
|
2025-06-24 15:00:27 +02:00
|
|
|
|
public partial class DialogueActor3D : Area3D, IInteractable
|
2025-06-24 11:06:33 +02:00
|
|
|
|
{
|
2025-06-24 13:57:18 +02:00
|
|
|
|
[Export] public StringName TimelineName = "";
|
2025-06-24 11:06:33 +02:00
|
|
|
|
private DialogueTools _dialogueInstance;
|
|
|
|
|
|
|
|
|
|
|
|
public override void _Ready()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Engine.IsEditorHint()) return;
|
2025-06-24 13:57:18 +02:00
|
|
|
|
if (string.IsNullOrWhiteSpace(TimelineName))
|
|
|
|
|
|
{
|
|
|
|
|
|
this.RemoveFromGroup("Interactable");
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-06-24 11:06:33 +02:00
|
|
|
|
_dialogueInstance = new DialogueTools();
|
|
|
|
|
|
_dialogueInstance.Init(this, TimelineName);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
2025-06-24 13:57:18 +02:00
|
|
|
|
if (string.IsNullOrWhiteSpace(TimelineName)) return false;
|
2025-06-24 11:06:33 +02:00
|
|
|
|
_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);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|