This commit is contained in:
2026-05-31 14:36:07 +02:00
parent b4ac00dcdd
commit 69c941b0e1
41 changed files with 39 additions and 324 deletions

View File

@@ -1 +0,0 @@
uid://djrh33q80nek

View File

@@ -20,7 +20,7 @@ public partial class BuildManager : Node
public override void _Process(double delta) public override void _Process(double delta)
{ {
if (Input.IsActionJustPressed(MyInput.Build) && !Building) if (Input.IsActionJustPressed(Scripts.Globals.MyInput.Build) && !Building)
{ {
StartBuilding(); StartBuilding();
} }

View File

@@ -1,11 +1,8 @@
using System;
using Godot; using Godot;
using NodeWar;
namespace NodeWar;
public partial class Main : Node2D public partial class Main : Node2D
{ {
public override void _Ready() public override void _Ready() { }
{
var asd = BuildManager.Instance;
}
} }

View File

@@ -1 +0,0 @@
uid://qhvdkf6ohu4d

View File

@@ -1 +0,0 @@
uid://vqjanihdukjs

View File

@@ -71,7 +71,7 @@ public partial class Nodule : Area2D
{ {
GlobalPosition = GetGlobalMousePosition(); GlobalPosition = GetGlobalMousePosition();
if (Input.IsActionJustPressed(MyInput.MouseLeft)) if (Input.IsActionJustPressed(Scripts.Globals.MyInput.MouseLeft))
{ {
BuildNode(); BuildNode();
} }
@@ -85,7 +85,11 @@ public partial class Nodule : Area2D
} }
else else
{ {
if (Input.IsActionJustPressed(MyInput.MouseLeft) && _growAreaInside && !BuildMode) if (
Input.IsActionJustPressed(Scripts.Globals.MyInput.MouseLeft)
&& _growAreaInside
&& !BuildMode
)
{ {
var newNodule = Instantiator.Instantiate<Nodule>(); var newNodule = Instantiator.Instantiate<Nodule>();
newNodule.BuildMode = true; newNodule.BuildMode = true;

1
Scripts/EventBus.cs.uid Normal file
View File

@@ -0,0 +1 @@
uid://462ni70mp6n1

View File

@@ -0,0 +1 @@
uid://be5lfbu6by5ia

1
Scripts/Faction.cs.uid Normal file
View File

@@ -0,0 +1 @@
uid://dqdhwvcshjo6p

View File

@@ -1,6 +1,6 @@
using Godot; using Godot;
namespace NodeWar; namespace NodeWar.Scripts.Globals;
[Autoload] [Autoload]
public partial class Autoloads { } public partial class Autoloads { }

View File

@@ -0,0 +1 @@
uid://qs5yr2w7pldh

View File

@@ -1,6 +1,6 @@
using Godot; using Godot;
namespace NodeWar; namespace NodeWar.Scripts.Globals;
[InputMap] [InputMap]
public static partial class MyInput; public static partial class MyInput;

View File

@@ -0,0 +1 @@
uid://kd6fd7h745qu

View File

@@ -1,6 +1,6 @@
using Godot; using Godot;
namespace NodeWar; namespace NodeWar.Scripts.Globals;
[ResourceTree("/")] [ResourceTree("/")]
public static partial class MyRes; public static partial class MyRes;

View File

@@ -0,0 +1 @@
uid://ctul4f2nwmc3f

View File

@@ -1,8 +1,9 @@
using System.Globalization; using System.Globalization;
using Godot; using Godot;
using GodotUtilities; using GodotUtilities;
using NodeWar.Scripts.Globals;
namespace NodeWar; namespace NodeWar.Scripts.Gui;
[Scene] [Scene]
public partial class Gui : Control public partial class Gui : Control

View File

@@ -1,6 +1,6 @@
[gd_scene format=3 uid="uid://b1a13w4ckxnub"] [gd_scene format=3 uid="uid://b1a13w4ckxnub"]
[ext_resource type="Script" uid="uid://7jql2b33svuv" path="res://Gui.cs" id="1_80edf"] [ext_resource type="Script" uid="uid://7jql2b33svuv" path="res://Scripts/Gui/Gui.cs" id="1_80edf"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_80edf"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_80edf"]
bg_color = Color(0.7245737, 0.5838865, 0, 1) bg_color = Color(0.7245737, 0.5838865, 0, 1)

View File

@@ -0,0 +1 @@
uid://u63irakc1xbq

View File

@@ -1,13 +1,13 @@
[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://cmcnly8kwwjia" path="res://Main.cs" id="1_trn2v"]
[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_03owx"]
[ext_resource type="Script" uid="uid://c2ufhsf60fl83" path="res://BuildManager.cs" id="2_5vw27"] [ext_resource type="PackedScene" uid="uid://b1a13w4ckxnub" path="res://Scripts/Gui/Gui.tscn" id="3_wkp8b"]
[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="4_20pc6"]
[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="5_5vvyt"]
[ext_resource type="PackedScene" uid="uid://b1a13w4ckxnub" path="res://gui.tscn" id="4_272bh"] [ext_resource type="Script" uid="uid://dl1t88tthmwts" path="res://addons/curved_lines_2d/scalable_arc_list.gd" id="6_c6i3y"]
[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://rirna2vebukw" path="res://addons/strategy_cam/strategy_camera.gd" id="7_c2ibq"]
[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_j4qnp"]
[sub_resource type="Curve2D" id="Curve2D_5vw27"] [sub_resource type="Curve2D" id="Curve2D_5vw27"]
resource_local_to_scene = true resource_local_to_scene = true
@@ -18,24 +18,24 @@ point_count = 5
[sub_resource type="Resource" id="Resource_kek77"] [sub_resource type="Resource" id="Resource_kek77"]
resource_local_to_scene = true resource_local_to_scene = true
script = ExtResource("5_272bh") script = ExtResource("6_c6i3y")
[node name="Main" type="Node2D" unique_id=866253780] [node name="Main" type="Node2D" unique_id=866253780]
script = ExtResource("1_272bh") script = ExtResource("1_trn2v")
[node name="BuildManager" type="Node" parent="." unique_id=582061924] [node name="BuildManager" type="Node" parent="." unique_id=582061924]
script = ExtResource("2_5vw27") script = ExtResource("2_03owx")
[node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=1010925224] [node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=1010925224]
[node name="GUI" parent="CanvasLayer" unique_id=1209092314 instance=ExtResource("4_272bh")] [node name="GUI" parent="CanvasLayer" unique_id=1209092314 instance=ExtResource("3_wkp8b")]
mouse_filter = 1 mouse_filter = 1
[node name="Stuff" type="Node" parent="." unique_id=1050239390] [node name="Stuff" type="Node" parent="." unique_id=1050239390]
[node name="Rectangle" type="Node2D" parent="Stuff" unique_id=742624159 node_paths=PackedStringArray("polygon", "line")] [node name="Rectangle" type="Node2D" parent="Stuff" unique_id=742624159 node_paths=PackedStringArray("polygon", "line")]
visible = false visible = false
script = ExtResource("3_lquwl") script = ExtResource("4_20pc6")
polygon = NodePath("Polygon2D") polygon = NodePath("Polygon2D")
line = NodePath("Stroke") line = NodePath("Stroke")
curve = SubResource("Curve2D_5vw27") curve = SubResource("Curve2D_5vw27")
@@ -57,9 +57,9 @@ metadata/_edit_lock_ = true
[node name="StrategyCamera" type="Camera2D" parent="." unique_id=706618209] [node name="StrategyCamera" type="Camera2D" parent="." unique_id=706618209]
limit_enabled = false limit_enabled = false
script = ExtResource("2_0xm2m") script = ExtResource("7_c2ibq")
translation_speed = 300.0 translation_speed = 300.0
metadata/_custom_type_script = "uid://rirna2vebukw" metadata/_custom_type_script = "uid://rirna2vebukw"
[node name="Nodule" parent="." unique_id=698496795 instance=ExtResource("8_5vw27")] [node name="Nodule" parent="." unique_id=698496795 instance=ExtResource("8_j4qnp")]
_noduleType = 0 _noduleType = 0

View File

@@ -1,27 +0,0 @@
[gd_scene format=3 uid="uid://4b8osd3h3xbm"]
[ext_resource type="Script" uid="uid://cdbkkb2cpwkn1" path="res://scripts/Pip.cs" id="1_2foya"]
[ext_resource type="Texture2D" uid="uid://dkpk1ubnmbl68" path="res://assets/pip.png" id="2_46jm3"]
[ext_resource type="PackedScene" uid="uid://dn6jqa3wj40ir" path="res://scripts/components/health_component.tscn" id="3_46jm3"]
[node name="Pip" type="Area2D" unique_id=1889156888]
script = ExtResource("1_2foya")
Faction = 1
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="." unique_id=528123989]
polygon = PackedVector2Array(-18.5, -18.5, -18.5, 18.5, 18.5, 18.5, 18.5, -18.5)
[node name="Gfx" type="Sprite2D" parent="." unique_id=1494214084]
texture = ExtResource("2_46jm3")
[node name="HealthComponent" parent="." unique_id=1360050278 node_paths=PackedStringArray("Gfx") instance=ExtResource("3_46jm3")]
offset_left = -35.0
offset_top = -18.0
offset_right = -8.0
offset_bottom = 110.0
scale = Vector2(0.28840518, 0.28840518)
Gfx = NodePath("../Gfx")
Health = 5.0
MaxHealth = 5.0
[connection signal="area_entered" from="." to="." method="_on_area_entered"]

View File

@@ -39,6 +39,7 @@ enabled=PackedStringArray("res://addons/curved_lines_2d/plugin.cfg", "res://addo
[file_customization] [file_customization]
folder_colors={ folder_colors={
"res://Scripts/": "purple",
"res://scripts/": "yellow" "res://scripts/": "yellow"
} }

View File

@@ -1,34 +0,0 @@
[gd_scene format=3 uid="uid://c24a65g4ixikh"]
[ext_resource type="Script" uid="uid://de3jpss66xjfh" path="res://addons/curved_lines_2d/scalable_vector_shape_2d.gd" id="1_ritjc"]
[ext_resource type="Script" uid="uid://dlbv4pit17dnu" path="res://addons/curved_lines_2d/scalable_arc.gd" id="2_31jy3"]
[ext_resource type="Script" uid="uid://dl1t88tthmwts" path="res://addons/curved_lines_2d/scalable_arc_list.gd" id="3_q0qps"]
[sub_resource type="Curve2D" id="Curve2D_nusja"]
resource_local_to_scene = true
_data = {
"points": PackedVector2Array(0, 0, 0, 0, 39.776398, -42.15619, 0, 0, 0, 0, -45.14743, 49.220245, 0, 0, 0, 0, -2.6800537, 3.5144196, 0, 0, 0, 0, -45.14743, -41.986115, 0, 0, 0, 0, 40.02704, 49.35132)
}
point_count = 5
[sub_resource type="Resource" id="Resource_5qe8n"]
resource_local_to_scene = true
script = ExtResource("3_q0qps")
[node name="Path" type="Node2D" unique_id=868654776 node_paths=PackedStringArray("line")]
script = ExtResource("1_ritjc")
begin_cap_mode = 2
end_cap_mode = 2
line_joint_mode = 2
line = NodePath("Stroke")
curve = SubResource("Curve2D_nusja")
update_curve_at_runtime = true
arc_list = SubResource("Resource_5qe8n")
[node name="Stroke" type="Line2D" parent="." unique_id=845910700]
points = PackedVector2Array(39.776398, -42.15619, -45.14743, 49.220245, -2.6800537, 3.5144196, -45.14743, -41.986115, 40.02704, 49.35132)
joint_mode = 2
begin_cap_mode = 2
end_cap_mode = 2
sharp_limit = 90.0
metadata/_edit_lock_ = true

View File

@@ -1,22 +0,0 @@
using System;
using Godot;
using NodeWar.scripts.components;
public partial class Damager : Timer
{
[Export]
public float Damage { get; set; } = 1;
public override void _Ready()
{
Timeout += OnTimeout;
}
private void OnTimeout()
{
var healthComponent = GetParent().GetNode<HealthComponent>("HealthComponent");
healthComponent?.TakeDamage(Damage);
}
public override void _Process(double delta) { }
}

View File

@@ -1 +0,0 @@
uid://bfi1cm0m4wuk2

View File

@@ -1 +0,0 @@
uid://bibq3e4nkwiwv

View File

@@ -1 +0,0 @@
uid://dmg4an0s8hjg7

View File

@@ -1 +0,0 @@
uid://o85xjbm0ecxg

View File

@@ -1 +0,0 @@
uid://dyydou5vpcmmx

View File

@@ -1,45 +0,0 @@
using System;
using Godot;
using NodeWar.scripts;
namespace NodeWar.Scripts;
public partial class Pip : Area2D
{
[Export]
public Faction Faction;
[Export]
public Vector2 Target;
[Export]
public float Speed { get; set; } = 100;
private Sprite2D _gfx;
public override void _Ready()
{
_gfx = GetNode<Sprite2D>("Gfx");
_gfx.Modulate = Faction switch
{
Faction.Neutral => Colors.Gray,
Faction.Player => Colors.DarkGreen,
Faction.Computer => Colors.DarkRed,
_ => throw new ArgumentOutOfRangeException(),
};
AreaEntered += OnAreaEntered;
}
public override void _Process(double delta)
{
var direction = Target - GlobalPosition;
Position += direction.Normalized() * Speed * delta.ToFloat();
}
private void OnAreaEntered(Node2D body)
{
}
}

View File

@@ -1 +0,0 @@
uid://cdbkkb2cpwkn1

View File

@@ -1,77 +0,0 @@
using System;
using System.Threading.Tasks;
using Godot;
namespace NodeWar.scripts.components;
public partial class HealthComponent : ProgressBar
{
private float _health = 100;
[Export]
public Sprite2D Gfx { get; set; }
[Export]
public float Health
{
get => _health;
set
{
if (value >= MaxHealth)
{
_health = MaxHealth;
}
_health = value;
}
}
[Export]
public float MaxHealth { get; set; } = 100;
[Signal]
public delegate float HealthChangedEventHandler(float oldHealth, float newHealth);
public void TakeDamage(float damage)
{
Health -= damage;
EmitSignal(SignalName.HealthChanged, Health + damage, Health);
if (Health <= 0)
{
Die();
return;
}
if (Gfx != null)
{
var originalColor = Gfx.Modulate;
Gfx.Modulate = new Color(10, 10, 10);
GetTree().CreateTimer(0.1f).Timeout += () =>
{
Gfx.Modulate = originalColor;
};
}
}
public void Die()
{
GD.Print("I am dying!");
GetParent().QueueFree();
}
public override void _Ready()
{
Value = Health;
MaxValue = MaxHealth;
}
public override void _Process(double delta)
{
Visible = Math.Abs(Health - MaxHealth) > 0.001f;
Value = Health;
}
}

View File

@@ -1 +0,0 @@
uid://b26j7cq2pgk6q

View File

@@ -1,42 +0,0 @@
using Godot;
using NodeWar.Scripts;
namespace NodeWar.scripts.components;
public partial class SpawnerComponent : Node
{
[Export]
public PackedScene Spawnee;
[Export]
public Faction Faction;
[Export]
public float BuildSpeed = 28;
[Export]
public float BuildProgress = 0;
[Export]
public float MaxBuildProgress = 100;
public Vector2 Target { get; set; }
public override void _Ready() { }
public override void _Process(double delta)
{
BuildProgress += BuildSpeed * delta.ToFloat();
if (BuildProgress >= MaxBuildProgress)
{
BuildProgress = 0;
var pip = Spawnee.Instantiate<Pip>();
pip.Faction = Faction;
pip.Target = Target;
GetParent().AddChild(pip);
pip.GlobalPosition = GetParent<Node2D>().GlobalPosition;
}
}
}

View File

@@ -1 +0,0 @@
uid://bkjuvw4kmtnq4

View File

@@ -1,8 +0,0 @@
[gd_scene format=3 uid="uid://c2blpf56yvidh"]
[ext_resource type="Script" uid="uid://bkjuvw4kmtnq4" path="res://scripts/components/SpawnerComponent.cs" id="1_6hmx4"]
[ext_resource type="PackedScene" uid="uid://4b8osd3h3xbm" path="res://pip.tscn" id="2_x4vwu"]
[node name="SpawnerComponent" type="Node" unique_id=1304757964]
script = ExtResource("1_6hmx4")
Spawnee = ExtResource("2_x4vwu")

View File

@@ -1,29 +0,0 @@
[gd_scene format=3 uid="uid://dn6jqa3wj40ir"]
[ext_resource type="Script" uid="uid://b26j7cq2pgk6q" path="res://scripts/components/HealthComponent.cs" id="1_kkm8u"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_21bcp"]
bg_color = Color(0.4249828, 0.6869066, 0, 1)
corner_radius_top_left = 6
corner_radius_top_right = 6
corner_radius_bottom_right = 6
corner_radius_bottom_left = 6
[node name="HealthComponent" type="ProgressBar" unique_id=1360050278]
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -13.5
offset_top = -64.0
offset_right = 13.5
offset_bottom = 64.0
grow_horizontal = 2
grow_vertical = 2
theme_override_styles/fill = SubResource("StyleBoxFlat_21bcp")
max_value = 10.0
value = 5.36
fill_mode = 3
show_percentage = false
script = ExtResource("1_kkm8u")