mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
33 lines
No EOL
844 B
C#
33 lines
No EOL
844 B
C#
using Godot;
|
|
|
|
[Tool]
|
|
public partial class DoorButtonVisualizer : Node2D
|
|
{
|
|
[Export] public NodePath TargetPath; // Expose the Target NodePath in the editor
|
|
|
|
public override void _Draw()
|
|
{
|
|
if (TargetPath == null || !Engine.IsEditorHint())
|
|
return;
|
|
|
|
// Get the target node
|
|
Node targetNode = GetNodeOrNull(TargetPath);
|
|
if (targetNode == null || !(targetNode is Node2D target))
|
|
return;
|
|
|
|
// Draw a line to the target
|
|
Vector2 start = GlobalPosition;
|
|
Vector2 end = target.GlobalPosition;
|
|
|
|
DrawLine(ToLocal(start), ToLocal(end), Colors.Green, 2);
|
|
}
|
|
|
|
public override void _Process(double delta)
|
|
{
|
|
// Update the visualization in the editor
|
|
if (Engine.IsEditorHint())
|
|
{
|
|
QueueRedraw();
|
|
}
|
|
}
|
|
} |