asd
This commit is contained in:
@@ -3,58 +3,50 @@ using Godot;
|
|||||||
|
|
||||||
namespace NodeWar;
|
namespace NodeWar;
|
||||||
|
|
||||||
|
[Singleton]
|
||||||
public partial class BuildManager : Node
|
public partial class BuildManager : Node
|
||||||
{
|
{
|
||||||
public bool Building { get; set; } = false;
|
private bool Building { get; set; }
|
||||||
|
|
||||||
public Nodule BuildingNodule { get; set; }
|
private Nodule BuildingNodule { get; set; }
|
||||||
|
|
||||||
public override void _Ready() { }
|
|
||||||
|
|
||||||
[Export]
|
|
||||||
private PackedScene _noduleScene;
|
|
||||||
|
|
||||||
[Export]
|
|
||||||
private PackedScene _rootScene;
|
|
||||||
|
|
||||||
private Dictionary<NoduleConnection, Root> NoduleConnections { get; set; } = new();
|
private Dictionary<NoduleConnection, Root> NoduleConnections { get; set; } = new();
|
||||||
|
|
||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
{
|
{
|
||||||
if (Input.IsActionJustPressed("build") && !Building)
|
if (Input.IsActionJustPressed(MyInput.Build) && !Building)
|
||||||
{
|
{
|
||||||
Building = true;
|
StartBuilding();
|
||||||
BuildingNodule = _noduleScene.Instantiate<Nodule>();
|
|
||||||
BuildingNodule.BuildMode = true;
|
|
||||||
|
|
||||||
BuildingNodule.NoduleBuilt += () =>
|
|
||||||
{
|
|
||||||
Building = false;
|
|
||||||
|
|
||||||
// try connecting built nodule to connected ones
|
|
||||||
foreach (var connectedNodule in BuildingNodule.ConnectedNodules)
|
|
||||||
{
|
|
||||||
RegisterConnection(BuildingNodule, connectedNodule);
|
|
||||||
}
|
|
||||||
|
|
||||||
BuildingNodule = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
BuildingNodule.BuildingCanceled += () =>
|
|
||||||
{
|
|
||||||
Building = false;
|
|
||||||
BuildingNodule = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
GetParent().AddChild(BuildingNodule);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void StartBuilding()
|
||||||
|
{
|
||||||
|
BuildingNodule = Instantiator.Instantiate<Nodule>();
|
||||||
|
|
||||||
|
Building = true;
|
||||||
|
BuildingNodule.BuildMode = true;
|
||||||
|
|
||||||
|
BuildingNodule.NoduleBuilt += () =>
|
||||||
|
{
|
||||||
|
Building = false;
|
||||||
|
BuildingNodule = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
BuildingNodule.BuildingCanceled += () =>
|
||||||
|
{
|
||||||
|
Building = false;
|
||||||
|
BuildingNodule = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
GetParent().AddChild(BuildingNodule);
|
||||||
|
}
|
||||||
|
|
||||||
public void RegisterConnection(Nodule a, Nodule b)
|
public void RegisterConnection(Nodule a, Nodule b)
|
||||||
{
|
{
|
||||||
if (!NoduleConnections.ContainsKey(new NoduleConnection { A = a, B = b }))
|
if (!NoduleConnections.ContainsKey(new NoduleConnection { A = a, B = b }))
|
||||||
{
|
{
|
||||||
var root = _rootScene.Instantiate<Root>();
|
var root = Instantiator.Instantiate<Root>();
|
||||||
GetParent().AddChild(root);
|
GetParent().AddChild(root);
|
||||||
|
|
||||||
root.ConnectNodules(a, b);
|
root.ConnectNodules(a, b);
|
||||||
|
|||||||
69
ConnectionArea.cs
Normal file
69
ConnectionArea.cs
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace NodeWar;
|
||||||
|
|
||||||
|
[SceneTree]
|
||||||
|
public partial class ConnectionArea : Area2D
|
||||||
|
{
|
||||||
|
[Signal]
|
||||||
|
public delegate void NoduleEnteredEventHandler(Nodule nodule);
|
||||||
|
|
||||||
|
[Signal]
|
||||||
|
public delegate void NoduleExitedEventHandler(Nodule nodule);
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
AreaEntered += OnAreaEntered;
|
||||||
|
AreaExited += OnAreaExited;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnAreaEntered(Area2D area)
|
||||||
|
{
|
||||||
|
switch (area)
|
||||||
|
{
|
||||||
|
case Nodule nodule:
|
||||||
|
HandleNoduleEntered(nodule);
|
||||||
|
break;
|
||||||
|
case ConnectionArea connectionArea:
|
||||||
|
HandleNoduleEntered(connectionArea.GetParent() as Nodule);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
void HandleNoduleEntered(Nodule newNodule)
|
||||||
|
{
|
||||||
|
if (newNodule.BuildMode)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
EmitSignalNoduleEntered(newNodule);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnAreaExited(Area2D area)
|
||||||
|
{
|
||||||
|
switch (area)
|
||||||
|
{
|
||||||
|
case Nodule nodule:
|
||||||
|
HandleNoduleExited(nodule);
|
||||||
|
break;
|
||||||
|
case ConnectionArea connectionArea:
|
||||||
|
HandleNoduleExited(connectionArea.GetParent() as Nodule);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
void HandleNoduleExited(Nodule newNodule)
|
||||||
|
{
|
||||||
|
if (newNodule.BuildMode)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
EmitSignalNoduleExited(newNodule);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
1
ConnectionArea.cs.uid
Normal file
1
ConnectionArea.cs.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://w5ba3yo120vc
|
||||||
17
ConnectionArea.tscn
Normal file
17
ConnectionArea.tscn
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
[gd_scene format=3 uid="uid://c4oxc6kyp3muy"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://w5ba3yo120vc" path="res://ConnectionArea.cs" id="1_djo5v"]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_bv6fd"]
|
||||||
|
size = Vector2(150, 150)
|
||||||
|
|
||||||
|
[node name="ConnectionArea" type="Area2D" unique_id=943082837]
|
||||||
|
script = ExtResource("1_djo5v")
|
||||||
|
|
||||||
|
[node name="Collision" type="CollisionShape2D" parent="." unique_id=260055498]
|
||||||
|
rotation = 0.7853982
|
||||||
|
scale = Vector2(0.99999994, 0.99999994)
|
||||||
|
shape = SubResource("RectangleShape2D_bv6fd")
|
||||||
|
|
||||||
|
[node name="Collision2" type="CollisionShape2D" parent="." unique_id=1676208642]
|
||||||
|
shape = SubResource("RectangleShape2D_bv6fd")
|
||||||
11
Main.cs
Normal file
11
Main.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
using System;
|
||||||
|
using Godot;
|
||||||
|
using NodeWar;
|
||||||
|
|
||||||
|
public partial class Main : Node2D
|
||||||
|
{
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
var asd = BuildManager.Instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
1
Main.cs.uid
Normal file
1
Main.cs.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://cmcnly8kwwjia
|
||||||
6
MyInput.cs
Normal file
6
MyInput.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace NodeWar;
|
||||||
|
|
||||||
|
[InputMap]
|
||||||
|
public static partial class MyInput;
|
||||||
1
MyInput.cs.uid
Normal file
1
MyInput.cs.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://qhvdkf6ohu4d
|
||||||
6
MyRes.cs
Normal file
6
MyRes.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace NodeWar;
|
||||||
|
|
||||||
|
[ResourceTree("/")]
|
||||||
|
public static partial class MyRes;
|
||||||
1
MyRes.cs.uid
Normal file
1
MyRes.cs.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://vqjanihdukjs
|
||||||
@@ -1,18 +1,13 @@
|
|||||||
<Project Sdk="Godot.NET.Sdk/4.6.2">
|
<Project Sdk="Godot.NET.Sdk/4.6.3">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net10.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<TargetFramework Condition=" '$(GodotTargetPlatform)' == 'android' "
|
<TargetFramework Condition=" '$(GodotTargetPlatform)' == 'android' ">net9.0</TargetFramework>
|
||||||
>net9.0</TargetFramework
|
|
||||||
>
|
|
||||||
<EnableDynamicLoading>true</EnableDynamicLoading>
|
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||||
<RootNamespace>NodeWar</RootNamespace>
|
<RootNamespace>NodeWar</RootNamespace>
|
||||||
<LangVersion>14</LangVersion>
|
<LangVersion>14</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Firebelley.GodotUtilities" Version="6.2.0" />
|
<PackageReference Include="Firebelley.GodotUtilities" Version="6.2.0" />
|
||||||
<PackageReference
|
<PackageReference Include="GodotSharp.SourceGenerators" Version="2.7.0-260519-1042.Release" />
|
||||||
Include="GodotSharp.SourceGenerators"
|
|
||||||
Version="2.7.0-260519-1042.Release"
|
|
||||||
/>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
18
Node War.csproj.old
Normal file
18
Node War.csproj.old
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<Project Sdk="Godot.NET.Sdk/4.6.2">
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
|
<TargetFramework Condition=" '$(GodotTargetPlatform)' == 'android' "
|
||||||
|
>net9.0</TargetFramework
|
||||||
|
>
|
||||||
|
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||||
|
<RootNamespace>NodeWar</RootNamespace>
|
||||||
|
<LangVersion>14</LangVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Firebelley.GodotUtilities" Version="6.2.0" />
|
||||||
|
<PackageReference
|
||||||
|
Include="GodotSharp.SourceGenerators"
|
||||||
|
Version="2.7.0-260519-1042.Release"
|
||||||
|
/>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
100
Nodule.cs
100
Nodule.cs
@@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Godot;
|
using Godot;
|
||||||
using GodotUtilities;
|
|
||||||
using NodeWar.scripts;
|
using NodeWar.scripts;
|
||||||
|
|
||||||
namespace NodeWar;
|
namespace NodeWar;
|
||||||
@@ -12,7 +11,7 @@ public enum NoduleType
|
|||||||
Connector,
|
Connector,
|
||||||
}
|
}
|
||||||
|
|
||||||
[Scene]
|
[SceneTree]
|
||||||
public partial class Nodule : Area2D
|
public partial class Nodule : Area2D
|
||||||
{
|
{
|
||||||
private const float GrowthFactor = 0.01f;
|
private const float GrowthFactor = 0.01f;
|
||||||
@@ -20,6 +19,8 @@ public partial class Nodule : Area2D
|
|||||||
[Export]
|
[Export]
|
||||||
private NoduleType _noduleType;
|
private NoduleType _noduleType;
|
||||||
|
|
||||||
|
private bool _growAreaInside;
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
public float MaxRadius { get; set; } = 360;
|
public float MaxRadius { get; set; } = 360;
|
||||||
|
|
||||||
@@ -32,7 +33,7 @@ public partial class Nodule : Area2D
|
|||||||
[Export]
|
[Export]
|
||||||
public PackedScene RootScene { get; set; }
|
public PackedScene RootScene { get; set; }
|
||||||
|
|
||||||
public List<Nodule> ConnectedNodules { get; set; } = [];
|
public List<Nodule> ConnectedNodules { get; } = [];
|
||||||
|
|
||||||
[Signal]
|
[Signal]
|
||||||
public delegate void NoduleBuiltEventHandler();
|
public delegate void NoduleBuiltEventHandler();
|
||||||
@@ -40,23 +41,20 @@ public partial class Nodule : Area2D
|
|||||||
[Signal]
|
[Signal]
|
||||||
public delegate void BuildingCanceledEventHandler();
|
public delegate void BuildingCanceledEventHandler();
|
||||||
|
|
||||||
[Node]
|
|
||||||
private Node2D _gfx;
|
|
||||||
|
|
||||||
[Node]
|
|
||||||
private CollisionShape2D _baseCollision;
|
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
AreaEntered += OnAreaEntered;
|
_.ConnectionArea.NoduleEntered += HandleNoduleEntered;
|
||||||
AreaExited += OnAreaExited;
|
_.ConnectionArea.NoduleExited += HandleNoduleExited;
|
||||||
|
|
||||||
switch (_noduleType)
|
switch (_noduleType)
|
||||||
{
|
{
|
||||||
case NoduleType.Base:
|
case NoduleType.Base:
|
||||||
_gfx.Scale = new Vector2(2, 2);
|
|
||||||
Modulate = Colors.Red;
|
Modulate = Colors.Red;
|
||||||
_baseCollision.Disabled = false;
|
|
||||||
|
_.Gfx.Get().Scale = new Vector2(2, 2);
|
||||||
|
_.BaseCollision.Disabled = false;
|
||||||
|
|
||||||
|
BuildNode();
|
||||||
break;
|
break;
|
||||||
case NoduleType.Connector:
|
case NoduleType.Connector:
|
||||||
break;
|
break;
|
||||||
@@ -67,44 +65,15 @@ public partial class Nodule : Area2D
|
|||||||
QueueRedraw();
|
QueueRedraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnAreaEntered(Area2D area)
|
|
||||||
{
|
|
||||||
if (area is Nodule nodule)
|
|
||||||
{
|
|
||||||
if (nodule.BuildMode)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ConnectedNodules.Add(nodule);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnAreaExited(Area2D area)
|
|
||||||
{
|
|
||||||
if (area is Nodule nodule)
|
|
||||||
{
|
|
||||||
if (nodule.BuildMode)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ConnectedNodules.Remove(nodule);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
{
|
{
|
||||||
if (BuildMode)
|
if (BuildMode)
|
||||||
{
|
{
|
||||||
GlobalPosition = GetGlobalMousePosition();
|
GlobalPosition = GetGlobalMousePosition();
|
||||||
|
|
||||||
if (Input.IsMouseButtonPressed(MouseButton.Left))
|
if (Input.IsActionJustPressed(MyInput.MouseLeft))
|
||||||
{
|
{
|
||||||
EmitSignalNoduleBuilt();
|
BuildNode();
|
||||||
BuildMode = false;
|
|
||||||
|
|
||||||
MouseEntered += OnMouseEntered;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Input.IsMouseButtonPressed(MouseButton.Right))
|
if (Input.IsMouseButtonPressed(MouseButton.Right))
|
||||||
@@ -116,6 +85,14 @@ public partial class Nodule : Area2D
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (Input.IsActionJustPressed(MyInput.MouseLeft) && _growAreaInside && !BuildMode)
|
||||||
|
{
|
||||||
|
var newNodule = Instantiator.Instantiate<Nodule>();
|
||||||
|
newNodule.BuildMode = true;
|
||||||
|
GetParent().AddChild(newNodule);
|
||||||
|
newNodule.GlobalPosition = GlobalPosition;
|
||||||
|
}
|
||||||
|
|
||||||
Age += GrowthFactor * delta.ToFloat();
|
Age += GrowthFactor * delta.ToFloat();
|
||||||
Age = MathF.Min(Age, 1);
|
Age = MathF.Min(Age, 1);
|
||||||
|
|
||||||
@@ -126,11 +103,6 @@ public partial class Nodule : Area2D
|
|||||||
QueueRedraw();
|
QueueRedraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnMouseEntered()
|
|
||||||
{
|
|
||||||
GD.Print("Mouse entered");
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void _Draw()
|
public override void _Draw()
|
||||||
{
|
{
|
||||||
foreach (var nodule in ConnectedNodules)
|
foreach (var nodule in ConnectedNodules)
|
||||||
@@ -159,11 +131,35 @@ public partial class Nodule : Area2D
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Notification(int what)
|
private void HandleNoduleEntered(Nodule nodule)
|
||||||
{
|
{
|
||||||
if (what == NotificationSceneInstantiated)
|
ConnectedNodules.Add(nodule);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleNoduleExited(Nodule nodule)
|
||||||
|
{
|
||||||
|
ConnectedNodules.Remove(nodule);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BuildNode()
|
||||||
|
{
|
||||||
|
EmitSignalNoduleBuilt();
|
||||||
|
BuildMode = false;
|
||||||
|
|
||||||
|
// try connecting built nodule to connected ones
|
||||||
|
foreach (var connectedNodule in ConnectedNodules)
|
||||||
{
|
{
|
||||||
WireNodes();
|
BuildManager.Instance.RegisterConnection(this, connectedNodule);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_.GrowArea.Get().MouseEntered += () =>
|
||||||
|
{
|
||||||
|
_growAreaInside = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
_.GrowArea.Get().MouseExited += () =>
|
||||||
|
{
|
||||||
|
_growAreaInside = false;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,13 +7,36 @@ public class NoduleConnection
|
|||||||
public Nodule A { get; set; }
|
public Nodule A { get; set; }
|
||||||
public Nodule B { get; set; }
|
public Nodule B { get; set; }
|
||||||
|
|
||||||
protected bool Equals(NoduleConnection other)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
return Equals(A, other.A) && Equals(B, other.B);
|
if (ReferenceEquals(null, obj))
|
||||||
|
return false;
|
||||||
|
if (ReferenceEquals(this, obj))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return obj.GetType() == GetType() && Equals((NoduleConnection)obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool Equals(NoduleConnection other)
|
||||||
|
{
|
||||||
|
return (Equals(A, other.A) && Equals(B, other.B))
|
||||||
|
|| (Equals(A, other.B) && Equals(B, other.A));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
{
|
{
|
||||||
return HashCode.Combine(A, B);
|
var h1 = A?.GetHashCode() ?? 0;
|
||||||
|
var h2 = B?.GetHashCode() ?? 0;
|
||||||
|
return h1 ^ h2;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public static bool operator ==(NoduleConnection left, NoduleConnection right)
|
||||||
|
{
|
||||||
|
return Equals(left, right);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator !=(NoduleConnection left, NoduleConnection right)
|
||||||
|
{
|
||||||
|
return !Equals(left, right);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
32
Root.cs
32
Root.cs
@@ -1,28 +1,18 @@
|
|||||||
using System.Linq;
|
|
||||||
using Godot;
|
using Godot;
|
||||||
using GodotSharp.SourceGenerators;
|
|
||||||
using GodotUtilities;
|
using GodotUtilities;
|
||||||
|
|
||||||
namespace NodeWar;
|
namespace NodeWar;
|
||||||
|
|
||||||
[Scene]
|
[SceneTree]
|
||||||
public partial class Root : Node2D
|
public partial class Root : Node2D
|
||||||
{
|
{
|
||||||
[Node]
|
private Nodule _a;
|
||||||
private Line2D _line2D;
|
private Nodule _b;
|
||||||
|
|
||||||
private Nodule a;
|
|
||||||
private Nodule b;
|
|
||||||
|
|
||||||
public override void _Ready()
|
|
||||||
{
|
|
||||||
GD.Print(_line2D);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ConnectNodules(Nodule a, Nodule b)
|
public void ConnectNodules(Nodule a, Nodule b)
|
||||||
{
|
{
|
||||||
this.a = a;
|
_a = a;
|
||||||
this.b = b;
|
_b = b;
|
||||||
|
|
||||||
GlobalPosition = a.GlobalPosition;
|
GlobalPosition = a.GlobalPosition;
|
||||||
GenerateLinePoints();
|
GenerateLinePoints();
|
||||||
@@ -30,7 +20,7 @@ public partial class Root : Node2D
|
|||||||
|
|
||||||
private void GenerateLinePoints()
|
private void GenerateLinePoints()
|
||||||
{
|
{
|
||||||
var direction = b.GlobalPosition - a.GlobalPosition;
|
var direction = _b.GlobalPosition - _a.GlobalPosition;
|
||||||
var sectionLength = direction.Length() / 5;
|
var sectionLength = direction.Length() / 5;
|
||||||
var points = new Vector2[5];
|
var points = new Vector2[5];
|
||||||
|
|
||||||
@@ -47,14 +37,6 @@ public partial class Root : Node2D
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
_line2D.Points = points;
|
_.Line2D.Points = points;
|
||||||
}
|
|
||||||
|
|
||||||
public override void _Notification(int what)
|
|
||||||
{
|
|
||||||
if (what == NotificationSceneInstantiated)
|
|
||||||
{
|
|
||||||
WireNodes();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
11
main.tscn
11
main.tscn
@@ -1,13 +1,12 @@
|
|||||||
[gd_scene format=3 uid="uid://bf7croj2rk4q6"]
|
[gd_scene format=3 uid="uid://bf7croj2rk4q6"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://cmcnly8kwwjia" path="res://Main.cs" id="1_272bh"]
|
||||||
[ext_resource type="Script" uid="uid://rirna2vebukw" path="res://addons/strategy_cam/strategy_camera.gd" id="2_0xm2m"]
|
[ext_resource type="Script" uid="uid://rirna2vebukw" path="res://addons/strategy_cam/strategy_camera.gd" id="2_0xm2m"]
|
||||||
[ext_resource type="Script" uid="uid://c2ufhsf60fl83" path="res://BuildManager.cs" id="2_5vw27"]
|
|
||||||
[ext_resource type="Script" uid="uid://de3jpss66xjfh" path="res://addons/curved_lines_2d/scalable_vector_shape_2d.gd" id="3_lquwl"]
|
[ext_resource type="Script" uid="uid://de3jpss66xjfh" path="res://addons/curved_lines_2d/scalable_vector_shape_2d.gd" id="3_lquwl"]
|
||||||
[ext_resource type="Script" uid="uid://dlbv4pit17dnu" path="res://addons/curved_lines_2d/scalable_arc.gd" id="4_7mycd"]
|
[ext_resource type="Script" uid="uid://dlbv4pit17dnu" path="res://addons/curved_lines_2d/scalable_arc.gd" id="4_7mycd"]
|
||||||
[ext_resource type="PackedScene" uid="uid://b1a13w4ckxnub" path="res://gui.tscn" id="4_272bh"]
|
[ext_resource type="PackedScene" uid="uid://b1a13w4ckxnub" path="res://gui.tscn" id="4_272bh"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cd47em5shcnid" path="res://root.tscn" id="4_kek77"]
|
|
||||||
[ext_resource type="Script" uid="uid://dl1t88tthmwts" path="res://addons/curved_lines_2d/scalable_arc_list.gd" id="5_272bh"]
|
[ext_resource type="Script" uid="uid://dl1t88tthmwts" path="res://addons/curved_lines_2d/scalable_arc_list.gd" id="5_272bh"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cb07jvtr8x7i1" path="res://nodule.tscn" id="8_5vw27"]
|
[ext_resource type="PackedScene" uid="uid://cb07jvtr8x7i1" path="res://Nodule.tscn" id="8_5vw27"]
|
||||||
|
|
||||||
[sub_resource type="Curve2D" id="Curve2D_5vw27"]
|
[sub_resource type="Curve2D" id="Curve2D_5vw27"]
|
||||||
resource_local_to_scene = true
|
resource_local_to_scene = true
|
||||||
@@ -21,11 +20,7 @@ resource_local_to_scene = true
|
|||||||
script = ExtResource("5_272bh")
|
script = ExtResource("5_272bh")
|
||||||
|
|
||||||
[node name="Main" type="Node2D" unique_id=866253780]
|
[node name="Main" type="Node2D" unique_id=866253780]
|
||||||
|
script = ExtResource("1_272bh")
|
||||||
[node name="BuildManager" type="Node" parent="." unique_id=288291270]
|
|
||||||
script = ExtResource("2_5vw27")
|
|
||||||
_noduleScene = ExtResource("8_5vw27")
|
|
||||||
_rootScene = ExtResource("4_kek77")
|
|
||||||
|
|
||||||
[node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=1010925224]
|
[node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=1010925224]
|
||||||
|
|
||||||
|
|||||||
24
nodule.tscn
24
nodule.tscn
@@ -2,13 +2,11 @@
|
|||||||
|
|
||||||
[ext_resource type="Script" uid="uid://7em4o0ud8sgj" path="res://Nodule.cs" id="1_beybw"]
|
[ext_resource type="Script" uid="uid://7em4o0ud8sgj" path="res://Nodule.cs" id="1_beybw"]
|
||||||
[ext_resource type="Script" uid="uid://de3jpss66xjfh" path="res://addons/curved_lines_2d/scalable_vector_shape_2d.gd" id="2_cahmm"]
|
[ext_resource type="Script" uid="uid://de3jpss66xjfh" path="res://addons/curved_lines_2d/scalable_vector_shape_2d.gd" id="2_cahmm"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cd47em5shcnid" path="res://root.tscn" id="2_k6tuy"]
|
[ext_resource type="PackedScene" uid="uid://cd47em5shcnid" path="res://Root.tscn" id="2_k6tuy"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://c4oxc6kyp3muy" path="res://ConnectionArea.tscn" id="3_0cigu"]
|
||||||
[ext_resource type="Script" uid="uid://dlbv4pit17dnu" path="res://addons/curved_lines_2d/scalable_arc.gd" id="3_fnyqb"]
|
[ext_resource type="Script" uid="uid://dlbv4pit17dnu" path="res://addons/curved_lines_2d/scalable_arc.gd" id="3_fnyqb"]
|
||||||
[ext_resource type="Script" uid="uid://dl1t88tthmwts" path="res://addons/curved_lines_2d/scalable_arc_list.gd" id="4_qiyup"]
|
[ext_resource type="Script" uid="uid://dl1t88tthmwts" path="res://addons/curved_lines_2d/scalable_arc_list.gd" id="4_qiyup"]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_bv6fd"]
|
|
||||||
size = Vector2(150, 150)
|
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_k6tuy"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_k6tuy"]
|
||||||
radius = 140.0
|
radius = 140.0
|
||||||
|
|
||||||
@@ -23,23 +21,21 @@ point_count = 5
|
|||||||
resource_local_to_scene = true
|
resource_local_to_scene = true
|
||||||
script = ExtResource("4_qiyup")
|
script = ExtResource("4_qiyup")
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_8l2gl"]
|
||||||
|
radius = 18.027756
|
||||||
|
|
||||||
[node name="Nodule" type="Area2D" unique_id=698496795]
|
[node name="Nodule" type="Area2D" unique_id=698496795]
|
||||||
script = ExtResource("1_beybw")
|
script = ExtResource("1_beybw")
|
||||||
_noduleType = 1
|
_noduleType = 1
|
||||||
Age = 0.5
|
Age = 0.5
|
||||||
RootScene = ExtResource("2_k6tuy")
|
RootScene = ExtResource("2_k6tuy")
|
||||||
|
|
||||||
[node name="Collision" type="CollisionShape2D" parent="." unique_id=402084582]
|
|
||||||
rotation = 0.7853982
|
|
||||||
shape = SubResource("RectangleShape2D_bv6fd")
|
|
||||||
|
|
||||||
[node name="Collision2" type="CollisionShape2D" parent="." unique_id=1073775238]
|
|
||||||
shape = SubResource("RectangleShape2D_bv6fd")
|
|
||||||
|
|
||||||
[node name="BaseCollision" type="CollisionShape2D" parent="." unique_id=1607878878]
|
[node name="BaseCollision" type="CollisionShape2D" parent="." unique_id=1607878878]
|
||||||
shape = SubResource("CircleShape2D_k6tuy")
|
shape = SubResource("CircleShape2D_k6tuy")
|
||||||
disabled = true
|
disabled = true
|
||||||
|
|
||||||
|
[node name="ConnectionArea" parent="." unique_id=943082837 instance=ExtResource("3_0cigu")]
|
||||||
|
|
||||||
[node name="Gfx" type="Node2D" parent="." unique_id=1962026750 node_paths=PackedStringArray("polygon", "line")]
|
[node name="Gfx" type="Node2D" parent="." unique_id=1962026750 node_paths=PackedStringArray("polygon", "line")]
|
||||||
z_index = 10
|
z_index = 10
|
||||||
script = ExtResource("2_cahmm")
|
script = ExtResource("2_cahmm")
|
||||||
@@ -67,3 +63,9 @@ width = 4.0
|
|||||||
default_color = Color(0, 0, 0, 1)
|
default_color = Color(0, 0, 0, 1)
|
||||||
sharp_limit = 90.0
|
sharp_limit = 90.0
|
||||||
metadata/_edit_lock_ = true
|
metadata/_edit_lock_ = true
|
||||||
|
|
||||||
|
[node name="GrowArea" type="Area2D" parent="." unique_id=1372859589]
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="GrowArea" unique_id=270303533]
|
||||||
|
shape = SubResource("CircleShape2D_8l2gl")
|
||||||
|
debug_color = Color(0.92081034, 0.076709054, 0.6616314, 0.41960785)
|
||||||
|
|||||||
@@ -88,6 +88,11 @@ build={
|
|||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":66,"key_label":0,"unicode":98,"location":0,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":66,"key_label":0,"unicode":98,"location":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
mouse_left={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"canceled":false,"pressed":false,"double_click":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[physics]
|
[physics]
|
||||||
|
|
||||||
|
|||||||
@@ -12,3 +12,4 @@ script = ExtResource("1_pyidc")
|
|||||||
[node name="Line2D" type="Line2D" parent="." unique_id=388168093]
|
[node name="Line2D" type="Line2D" parent="." unique_id=388168093]
|
||||||
points = PackedVector2Array(16.4, 0, -25, -59, -53, -88, -94, -96, -130, -114, -151, -125, -167, -148, -188, -168, -207, -199, -243.105, -220)
|
points = PackedVector2Array(16.4, 0, -25, -59, -53, -88, -94, -96, -130, -114, -151, -125, -167, -148, -188, -168, -207, -199, -243.105, -220)
|
||||||
width_curve = SubResource("Curve_pq8q7")
|
width_curve = SubResource("Curve_pq8q7")
|
||||||
|
antialiased = true
|
||||||
|
|||||||
Reference in New Issue
Block a user