Script to visualize connections

This commit is contained in:
Marco 2025-01-22 15:09:04 +01:00
commit 0d2302c9fe
9 changed files with 149 additions and 17 deletions

View file

@ -1,14 +1,48 @@
[gd_scene load_steps=3 format=3 uid="uid://byms2dhliyux0"]
[gd_scene load_steps=8 format=3 uid="uid://byms2dhliyux0"]
[ext_resource type="Texture2D" uid="uid://d3e762pxublbt" path="res://Sprites/teleporter.png" id="1_ppqan"]
[ext_resource type="Texture2D" uid="uid://dcrsv00yf6ylk" path="res://Sprites/Teleport_Particles.png" id="2_ggtec"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_uk8yj"]
size = Vector2(16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_ex07d"]
atlas = ExtResource("2_ggtec")
region = Rect2(0, 0, 16, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_1jqq2"]
atlas = ExtResource("2_ggtec")
region = Rect2(16, 0, 16, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_wbhur"]
atlas = ExtResource("2_ggtec")
region = Rect2(32, 0, 16, 32)
[sub_resource type="SpriteFrames" id="SpriteFrames_bt8wx"]
animations = [{
"frames": [],
"loop": true,
"name": &"Idle",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_ex07d")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_1jqq2")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_wbhur")
}],
"loop": true,
"name": &"Teleporting",
"speed": 5.0
}]
[node name="Teleporter" type="Area2D"]
collision_layer = 4
collision_mask = 2
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
visible = false
@ -16,3 +50,8 @@ shape = SubResource("RectangleShape2D_uk8yj")
[node name="Sprite2D" type="Sprite2D" parent="."]
texture = ExtResource("1_ppqan")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
position = Vector2(0, -9)
sprite_frames = SubResource("SpriteFrames_bt8wx")
animation = &"Idle"

File diff suppressed because one or more lines are too long

BIN
Sprites/Teleport_Particles.aseprite (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Sprites/Teleport_Particles.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dcrsv00yf6ylk"
path="res://.godot/imported/Teleport_Particles.png-174aa58c291609f0b5bf9118486e8a13.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/Teleport_Particles.png"
dest_files=["res://.godot/imported/Teleport_Particles.png-174aa58c291609f0b5bf9118486e8a13.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View file

@ -0,0 +1,21 @@
#if TOOLS
using Godot;
using System;
[Tool]
public partial class ButtonLink : EditorPlugin
{
public override void _EnterTree()
{
// Add a custom type for visualizing the link
Script visualizerScript = GD.Load<Script>("res://addons/ButtonLink/DoorButtonVisualizer.cs");
AddCustomType("ButtonDoorVisualizer", "Node2D", visualizerScript, null);
}
public override void _ExitTree()
{
// Remove the custom type when the plugin is disabled
RemoveCustomType("ButtonDoorVisualizer");
}
}
#endif

View file

@ -0,0 +1,33 @@
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();
}
}
}

View file

@ -0,0 +1,6 @@
[plugin]
name="Door Button Link"
author="Your Name"
version="1.0"
description="Draws lines between linked buttons and doors in the editor."
script="ButtonLink.cs"

View file

@ -45,7 +45,7 @@ project/assembly_name="Cirno"
[editor_plugins]
enabled=PackedStringArray("res://addons/DebugGUI/plugin.cfg", "res://addons/smoothing/plugin.cfg")
enabled=PackedStringArray("res://addons/ButtonLink/plugin.cfg", "res://addons/DebugGUI/plugin.cfg", "res://addons/smoothing/plugin.cfg")
[input]