From 69c941b0e1e6e3598971fdf9984ad624784c41c8 Mon Sep 17 00:00:00 2001 From: Jens Becker Date: Sun, 31 May 2026 14:36:07 +0200 Subject: [PATCH] cleanup --- Autoloads.cs.uid | 1 - BuildManager.cs | 2 +- Main.cs | 9 +-- MyInput.cs.uid | 1 - MyRes.cs.uid | 1 - Nodule.cs | 8 +- {scripts => Scripts}/EventBus.cs | 0 Scripts/EventBus.cs.uid | 1 + {scripts => Scripts}/Extensions.cs | 0 Scripts/Extensions.cs.uid | 1 + {scripts => Scripts}/Faction.cs | 0 Scripts/Faction.cs.uid | 1 + Autoloads.cs => Scripts/Globals/Autoloads.cs | 2 +- Scripts/Globals/Autoloads.cs.uid | 1 + MyInput.cs => Scripts/Globals/MyInput.cs | 2 +- Scripts/Globals/MyInput.cs.uid | 1 + MyRes.cs => Scripts/Globals/MyRes.cs | 2 +- Scripts/Globals/MyRes.cs.uid | 1 + Gui.cs => Scripts/Gui/Gui.cs | 3 +- Gui.cs.uid => Scripts/Gui/Gui.cs.uid | 0 gui.tscn => Scripts/Gui/Gui.tscn | 2 +- {scripts => Scripts}/LinePath2D.cs | 0 Scripts/LinePath2D.cs.uid | 1 + main.tscn | 30 ++++---- pip.tscn | 27 ------- project.godot | 1 + scheppes_x.tscn | 34 --------- scripts/Damager.cs | 22 ------ scripts/Damager.cs.uid | 1 - scripts/EventBus.cs.uid | 1 - scripts/Extensions.cs.uid | 1 - scripts/Faction.cs.uid | 1 - scripts/LinePath2D.cs.uid | 1 - scripts/Pip.cs | 45 ------------ scripts/Pip.cs.uid | 1 - scripts/components/HealthComponent.cs | 77 -------------------- scripts/components/HealthComponent.cs.uid | 1 - scripts/components/SpawnerComponent.cs | 42 ----------- scripts/components/SpawnerComponent.cs.uid | 1 - scripts/components/SpawnerComponent.tscn | 8 -- scripts/components/health_component.tscn | 29 -------- 41 files changed, 39 insertions(+), 324 deletions(-) delete mode 100644 Autoloads.cs.uid delete mode 100644 MyInput.cs.uid delete mode 100644 MyRes.cs.uid rename {scripts => Scripts}/EventBus.cs (100%) create mode 100644 Scripts/EventBus.cs.uid rename {scripts => Scripts}/Extensions.cs (100%) create mode 100644 Scripts/Extensions.cs.uid rename {scripts => Scripts}/Faction.cs (100%) create mode 100644 Scripts/Faction.cs.uid rename Autoloads.cs => Scripts/Globals/Autoloads.cs (64%) create mode 100644 Scripts/Globals/Autoloads.cs.uid rename MyInput.cs => Scripts/Globals/MyInput.cs (65%) create mode 100644 Scripts/Globals/MyInput.cs.uid rename MyRes.cs => Scripts/Globals/MyRes.cs (67%) create mode 100644 Scripts/Globals/MyRes.cs.uid rename Gui.cs => Scripts/Gui/Gui.cs (92%) rename Gui.cs.uid => Scripts/Gui/Gui.cs.uid (100%) rename gui.tscn => Scripts/Gui/Gui.tscn (98%) rename {scripts => Scripts}/LinePath2D.cs (100%) create mode 100644 Scripts/LinePath2D.cs.uid delete mode 100644 pip.tscn delete mode 100644 scheppes_x.tscn delete mode 100644 scripts/Damager.cs delete mode 100644 scripts/Damager.cs.uid delete mode 100644 scripts/EventBus.cs.uid delete mode 100644 scripts/Extensions.cs.uid delete mode 100644 scripts/Faction.cs.uid delete mode 100644 scripts/LinePath2D.cs.uid delete mode 100644 scripts/Pip.cs delete mode 100644 scripts/Pip.cs.uid delete mode 100644 scripts/components/HealthComponent.cs delete mode 100644 scripts/components/HealthComponent.cs.uid delete mode 100644 scripts/components/SpawnerComponent.cs delete mode 100644 scripts/components/SpawnerComponent.cs.uid delete mode 100644 scripts/components/SpawnerComponent.tscn delete mode 100644 scripts/components/health_component.tscn diff --git a/Autoloads.cs.uid b/Autoloads.cs.uid deleted file mode 100644 index 573ceb4..0000000 --- a/Autoloads.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://djrh33q80nek diff --git a/BuildManager.cs b/BuildManager.cs index 07e5f3d..34a2c95 100644 --- a/BuildManager.cs +++ b/BuildManager.cs @@ -20,7 +20,7 @@ public partial class BuildManager : Node public override void _Process(double delta) { - if (Input.IsActionJustPressed(MyInput.Build) && !Building) + if (Input.IsActionJustPressed(Scripts.Globals.MyInput.Build) && !Building) { StartBuilding(); } diff --git a/Main.cs b/Main.cs index ce7e148..0f5c866 100644 --- a/Main.cs +++ b/Main.cs @@ -1,11 +1,8 @@ -using System; using Godot; -using NodeWar; + +namespace NodeWar; public partial class Main : Node2D { - public override void _Ready() - { - var asd = BuildManager.Instance; - } + public override void _Ready() { } } diff --git a/MyInput.cs.uid b/MyInput.cs.uid deleted file mode 100644 index d25e703..0000000 --- a/MyInput.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://qhvdkf6ohu4d diff --git a/MyRes.cs.uid b/MyRes.cs.uid deleted file mode 100644 index 4185800..0000000 --- a/MyRes.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://vqjanihdukjs diff --git a/Nodule.cs b/Nodule.cs index ff0eca5..3591690 100644 --- a/Nodule.cs +++ b/Nodule.cs @@ -71,7 +71,7 @@ public partial class Nodule : Area2D { GlobalPosition = GetGlobalMousePosition(); - if (Input.IsActionJustPressed(MyInput.MouseLeft)) + if (Input.IsActionJustPressed(Scripts.Globals.MyInput.MouseLeft)) { BuildNode(); } @@ -85,7 +85,11 @@ public partial class Nodule : Area2D } else { - if (Input.IsActionJustPressed(MyInput.MouseLeft) && _growAreaInside && !BuildMode) + if ( + Input.IsActionJustPressed(Scripts.Globals.MyInput.MouseLeft) + && _growAreaInside + && !BuildMode + ) { var newNodule = Instantiator.Instantiate(); newNodule.BuildMode = true; diff --git a/scripts/EventBus.cs b/Scripts/EventBus.cs similarity index 100% rename from scripts/EventBus.cs rename to Scripts/EventBus.cs diff --git a/Scripts/EventBus.cs.uid b/Scripts/EventBus.cs.uid new file mode 100644 index 0000000..57bf221 --- /dev/null +++ b/Scripts/EventBus.cs.uid @@ -0,0 +1 @@ +uid://462ni70mp6n1 diff --git a/scripts/Extensions.cs b/Scripts/Extensions.cs similarity index 100% rename from scripts/Extensions.cs rename to Scripts/Extensions.cs diff --git a/Scripts/Extensions.cs.uid b/Scripts/Extensions.cs.uid new file mode 100644 index 0000000..2576b82 --- /dev/null +++ b/Scripts/Extensions.cs.uid @@ -0,0 +1 @@ +uid://be5lfbu6by5ia diff --git a/scripts/Faction.cs b/Scripts/Faction.cs similarity index 100% rename from scripts/Faction.cs rename to Scripts/Faction.cs diff --git a/Scripts/Faction.cs.uid b/Scripts/Faction.cs.uid new file mode 100644 index 0000000..64244c3 --- /dev/null +++ b/Scripts/Faction.cs.uid @@ -0,0 +1 @@ +uid://dqdhwvcshjo6p diff --git a/Autoloads.cs b/Scripts/Globals/Autoloads.cs similarity index 64% rename from Autoloads.cs rename to Scripts/Globals/Autoloads.cs index 93950e2..a63d019 100644 --- a/Autoloads.cs +++ b/Scripts/Globals/Autoloads.cs @@ -1,6 +1,6 @@ using Godot; -namespace NodeWar; +namespace NodeWar.Scripts.Globals; [Autoload] public partial class Autoloads { } diff --git a/Scripts/Globals/Autoloads.cs.uid b/Scripts/Globals/Autoloads.cs.uid new file mode 100644 index 0000000..e439c21 --- /dev/null +++ b/Scripts/Globals/Autoloads.cs.uid @@ -0,0 +1 @@ +uid://qs5yr2w7pldh diff --git a/MyInput.cs b/Scripts/Globals/MyInput.cs similarity index 65% rename from MyInput.cs rename to Scripts/Globals/MyInput.cs index 9db798d..b5c9112 100644 --- a/MyInput.cs +++ b/Scripts/Globals/MyInput.cs @@ -1,6 +1,6 @@ using Godot; -namespace NodeWar; +namespace NodeWar.Scripts.Globals; [InputMap] public static partial class MyInput; diff --git a/Scripts/Globals/MyInput.cs.uid b/Scripts/Globals/MyInput.cs.uid new file mode 100644 index 0000000..f27505f --- /dev/null +++ b/Scripts/Globals/MyInput.cs.uid @@ -0,0 +1 @@ +uid://kd6fd7h745qu diff --git a/MyRes.cs b/Scripts/Globals/MyRes.cs similarity index 67% rename from MyRes.cs rename to Scripts/Globals/MyRes.cs index 7443a63..8ef668b 100644 --- a/MyRes.cs +++ b/Scripts/Globals/MyRes.cs @@ -1,6 +1,6 @@ using Godot; -namespace NodeWar; +namespace NodeWar.Scripts.Globals; [ResourceTree("/")] public static partial class MyRes; diff --git a/Scripts/Globals/MyRes.cs.uid b/Scripts/Globals/MyRes.cs.uid new file mode 100644 index 0000000..53b7e8a --- /dev/null +++ b/Scripts/Globals/MyRes.cs.uid @@ -0,0 +1 @@ +uid://ctul4f2nwmc3f diff --git a/Gui.cs b/Scripts/Gui/Gui.cs similarity index 92% rename from Gui.cs rename to Scripts/Gui/Gui.cs index 6b0e5f0..baab1d6 100644 --- a/Gui.cs +++ b/Scripts/Gui/Gui.cs @@ -1,8 +1,9 @@ using System.Globalization; using Godot; using GodotUtilities; +using NodeWar.Scripts.Globals; -namespace NodeWar; +namespace NodeWar.Scripts.Gui; [Scene] public partial class Gui : Control diff --git a/Gui.cs.uid b/Scripts/Gui/Gui.cs.uid similarity index 100% rename from Gui.cs.uid rename to Scripts/Gui/Gui.cs.uid diff --git a/gui.tscn b/Scripts/Gui/Gui.tscn similarity index 98% rename from gui.tscn rename to Scripts/Gui/Gui.tscn index 1c6cd5b..659ab52 100644 --- a/gui.tscn +++ b/Scripts/Gui/Gui.tscn @@ -1,6 +1,6 @@ [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"] bg_color = Color(0.7245737, 0.5838865, 0, 1) diff --git a/scripts/LinePath2D.cs b/Scripts/LinePath2D.cs similarity index 100% rename from scripts/LinePath2D.cs rename to Scripts/LinePath2D.cs diff --git a/Scripts/LinePath2D.cs.uid b/Scripts/LinePath2D.cs.uid new file mode 100644 index 0000000..b78c3b6 --- /dev/null +++ b/Scripts/LinePath2D.cs.uid @@ -0,0 +1 @@ +uid://u63irakc1xbq diff --git a/main.tscn b/main.tscn index fd1f1be..48ba7a7 100644 --- a/main.tscn +++ b/main.tscn @@ -1,13 +1,13 @@ [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://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://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="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="Script" uid="uid://cmcnly8kwwjia" path="res://Main.cs" id="1_trn2v"] +[ext_resource type="Script" uid="uid://c2ufhsf60fl83" path="res://BuildManager.cs" id="2_03owx"] +[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="4_20pc6"] +[ext_resource type="Script" uid="uid://dlbv4pit17dnu" path="res://addons/curved_lines_2d/scalable_arc.gd" id="5_5vvyt"] +[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://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_j4qnp"] [sub_resource type="Curve2D" id="Curve2D_5vw27"] resource_local_to_scene = true @@ -18,24 +18,24 @@ point_count = 5 [sub_resource type="Resource" id="Resource_kek77"] resource_local_to_scene = true -script = ExtResource("5_272bh") +script = ExtResource("6_c6i3y") [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] -script = ExtResource("2_5vw27") +script = ExtResource("2_03owx") [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 [node name="Stuff" type="Node" parent="." unique_id=1050239390] [node name="Rectangle" type="Node2D" parent="Stuff" unique_id=742624159 node_paths=PackedStringArray("polygon", "line")] visible = false -script = ExtResource("3_lquwl") +script = ExtResource("4_20pc6") polygon = NodePath("Polygon2D") line = NodePath("Stroke") curve = SubResource("Curve2D_5vw27") @@ -57,9 +57,9 @@ metadata/_edit_lock_ = true [node name="StrategyCamera" type="Camera2D" parent="." unique_id=706618209] limit_enabled = false -script = ExtResource("2_0xm2m") +script = ExtResource("7_c2ibq") translation_speed = 300.0 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 diff --git a/pip.tscn b/pip.tscn deleted file mode 100644 index f053086..0000000 --- a/pip.tscn +++ /dev/null @@ -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"] diff --git a/project.godot b/project.godot index 117d92b..e31fc03 100644 --- a/project.godot +++ b/project.godot @@ -39,6 +39,7 @@ enabled=PackedStringArray("res://addons/curved_lines_2d/plugin.cfg", "res://addo [file_customization] folder_colors={ +"res://Scripts/": "purple", "res://scripts/": "yellow" } diff --git a/scheppes_x.tscn b/scheppes_x.tscn deleted file mode 100644 index f429bf1..0000000 --- a/scheppes_x.tscn +++ /dev/null @@ -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 diff --git a/scripts/Damager.cs b/scripts/Damager.cs deleted file mode 100644 index 2dd5ebc..0000000 --- a/scripts/Damager.cs +++ /dev/null @@ -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?.TakeDamage(Damage); - } - - public override void _Process(double delta) { } -} diff --git a/scripts/Damager.cs.uid b/scripts/Damager.cs.uid deleted file mode 100644 index 39d6049..0000000 --- a/scripts/Damager.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://bfi1cm0m4wuk2 diff --git a/scripts/EventBus.cs.uid b/scripts/EventBus.cs.uid deleted file mode 100644 index 70d352b..0000000 --- a/scripts/EventBus.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://bibq3e4nkwiwv diff --git a/scripts/Extensions.cs.uid b/scripts/Extensions.cs.uid deleted file mode 100644 index eff30a9..0000000 --- a/scripts/Extensions.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://dmg4an0s8hjg7 diff --git a/scripts/Faction.cs.uid b/scripts/Faction.cs.uid deleted file mode 100644 index 3865479..0000000 --- a/scripts/Faction.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://o85xjbm0ecxg diff --git a/scripts/LinePath2D.cs.uid b/scripts/LinePath2D.cs.uid deleted file mode 100644 index 32ddb61..0000000 --- a/scripts/LinePath2D.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://dyydou5vpcmmx diff --git a/scripts/Pip.cs b/scripts/Pip.cs deleted file mode 100644 index 59f8b2f..0000000 --- a/scripts/Pip.cs +++ /dev/null @@ -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("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) - { - - } -} diff --git a/scripts/Pip.cs.uid b/scripts/Pip.cs.uid deleted file mode 100644 index d8b33c6..0000000 --- a/scripts/Pip.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://cdbkkb2cpwkn1 diff --git a/scripts/components/HealthComponent.cs b/scripts/components/HealthComponent.cs deleted file mode 100644 index 1d68011..0000000 --- a/scripts/components/HealthComponent.cs +++ /dev/null @@ -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; - } -} diff --git a/scripts/components/HealthComponent.cs.uid b/scripts/components/HealthComponent.cs.uid deleted file mode 100644 index 8476cd0..0000000 --- a/scripts/components/HealthComponent.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://b26j7cq2pgk6q diff --git a/scripts/components/SpawnerComponent.cs b/scripts/components/SpawnerComponent.cs deleted file mode 100644 index d22e41f..0000000 --- a/scripts/components/SpawnerComponent.cs +++ /dev/null @@ -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.Faction = Faction; - pip.Target = Target; - - GetParent().AddChild(pip); - pip.GlobalPosition = GetParent().GlobalPosition; - } - } -} diff --git a/scripts/components/SpawnerComponent.cs.uid b/scripts/components/SpawnerComponent.cs.uid deleted file mode 100644 index ee66b13..0000000 --- a/scripts/components/SpawnerComponent.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://bkjuvw4kmtnq4 diff --git a/scripts/components/SpawnerComponent.tscn b/scripts/components/SpawnerComponent.tscn deleted file mode 100644 index e9d6844..0000000 --- a/scripts/components/SpawnerComponent.tscn +++ /dev/null @@ -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") diff --git a/scripts/components/health_component.tscn b/scripts/components/health_component.tscn deleted file mode 100644 index e429a7e..0000000 --- a/scripts/components/health_component.tscn +++ /dev/null @@ -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")