asd
This commit is contained in:
32
Root.cs
32
Root.cs
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user