cirnogodot/Scripts/Utils/TeleporterLinker.cs
2025-03-31 11:59:45 +02:00

41 lines
No EOL
920 B
C#

using Cirno.Scripts.Activables;
using Godot;
namespace Cirno.Scripts.Utils;
[Tool]
public partial class TeleporterLinker : Node2D
{
private Teleporter _teleporter;
[Export] public Color Color { get; set; } = Colors.Blue;
public override void _Ready()
{
_teleporter = GetParentOrNull<Teleporter>();
}
public override void _Draw()
{
if (!Engine.IsEditorHint())
return;
if (_teleporter is null) return;
if (!_teleporter.IsEnabled) return;
if (_teleporter.Target is null) return;
Vector2 start = _teleporter.GlobalPosition;
Vector2 end = _teleporter.Target.GlobalPosition;
DrawLine(ToLocal(start), ToLocal(end), Color, 2.0f);
}
public override void _Process(double delta)
{
if (Engine.IsEditorHint())
{
QueueRedraw();
}
}
}