This commit is contained in:
2026-05-30 01:05:14 +02:00
parent 9c7c414bc9
commit f2b3989910
19 changed files with 266 additions and 144 deletions

32
Root.cs
View File

@@ -1,28 +1,18 @@
using System.Linq;
using Godot;
using GodotSharp.SourceGenerators;
using GodotUtilities;
namespace NodeWar;
[Scene]
[SceneTree]
public partial class Root : Node2D
{
[Node]
private Line2D _line2D;
private Nodule a;
private Nodule b;
public override void _Ready()
{
GD.Print(_line2D);
}
private Nodule _a;
private Nodule _b;
public void ConnectNodules(Nodule a, Nodule b)
{
this.a = a;
this.b = b;
_a = a;
_b = b;
GlobalPosition = a.GlobalPosition;
GenerateLinePoints();
@@ -30,7 +20,7 @@ public partial class Root : Node2D
private void GenerateLinePoints()
{
var direction = b.GlobalPosition - a.GlobalPosition;
var direction = _b.GlobalPosition - _a.GlobalPosition;
var sectionLength = direction.Length() / 5;
var points = new Vector2[5];
@@ -47,14 +37,6 @@ public partial class Root : Node2D
};
}
_line2D.Points = points;
}
public override void _Notification(int what)
{
if (what == NotificationSceneInstantiated)
{
WireNodes();
}
_.Line2D.Points = points;
}
}