From 9857bb4c8763ea5ef482605644f67cbe2dce34f5 Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Mon, 12 Aug 2024 19:32:30 -0500 Subject: [PATCH] refactoring command post mini project 3 --- .../controllers/cp/CommandPostController.gd | 20 +++++++++---------- .../cp/attacker/command_post_attackers.tscn | 6 +----- .../cp/command_post_controller.tscn | 2 +- .../cp/defender/command_post_defenders.tscn | 6 +----- .../cp/neutral/command_post_neutral.tscn | 6 +----- .../nonaligned/command_post_non_aligned.tscn | 6 +----- .../controllers/game/GameController.gd | 2 +- .../game/assault/game_controller_assault.tscn | 3 +-- .../game/ctf/game_controller_ctf.tscn | 3 +-- .../controllers/game/game_controller.tscn | 2 +- .../game/heros/game_controller_heros.tscn | 3 +-- src/projects/Command Post/world.tscn | 8 ++++---- 12 files changed, 24 insertions(+), 43 deletions(-) diff --git a/src/projects/Command Post/scripts/controllers/cp/CommandPostController.gd b/src/projects/Command Post/scripts/controllers/cp/CommandPostController.gd index 8b47ebc..0de1787 100644 --- a/src/projects/Command Post/scripts/controllers/cp/CommandPostController.gd +++ b/src/projects/Command Post/scripts/controllers/cp/CommandPostController.gd @@ -1,4 +1,4 @@ -class_name CommandPostController extends Node3D +class_name CommandPostController extends Node @export var team: Enums.Faction; @@ -19,16 +19,16 @@ func _on_child_exiting_tree(_cp: CommandPost): func do_spawn(): - var spawners = self.get_children() - if spawners.size() == 0: return + var command_posts = self.get_children() + if command_posts.size() == 0: return - var target = null - for spawn in spawners: - if spawn.contested: - target = spawn + var target_cp = null + for command_post in command_posts: + if command_post.contested: + target_cp = command_post - if not target: + if not target_cp: randomize() - target = spawners[ randi() % len(spawners) ] + target_cp = command_posts[ randi() % len(command_posts) ] - target.spawn(spawn_entity) + target_cp.spawn(spawn_entity) diff --git a/src/projects/Command Post/scripts/controllers/cp/attacker/command_post_attackers.tscn b/src/projects/Command Post/scripts/controllers/cp/attacker/command_post_attackers.tscn index 5e29e10..d2acebd 100644 --- a/src/projects/Command Post/scripts/controllers/cp/attacker/command_post_attackers.tscn +++ b/src/projects/Command Post/scripts/controllers/cp/attacker/command_post_attackers.tscn @@ -3,12 +3,8 @@ [ext_resource type="Script" path="res://scripts/controllers/cp/attacker/CommandPostAttackers.gd" id="1_71i6h"] [ext_resource type="PackedScene" uid="uid://cc3xcu8ipc6mu" path="res://assets/character/attacker/attacker_character.tscn" id="2_itmdl"] -[node name="CommandPostAttackers" type="Node3D"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5, 0) +[node name="CommandPostAttackers" type="Node"] script = ExtResource("1_71i6h") team = 1 spawn_entity = ExtResource("2_itmdl") cp_color = Color(0.87451, 0.160784, 0.105882, 1) - -[connection signal="child_entered_tree" from="." to="." method="_on_child_entered_tree"] -[connection signal="child_exiting_tree" from="." to="." method="_on_child_exiting_tree"] diff --git a/src/projects/Command Post/scripts/controllers/cp/command_post_controller.tscn b/src/projects/Command Post/scripts/controllers/cp/command_post_controller.tscn index effa343..0ca0a1c 100644 --- a/src/projects/Command Post/scripts/controllers/cp/command_post_controller.tscn +++ b/src/projects/Command Post/scripts/controllers/cp/command_post_controller.tscn @@ -2,6 +2,6 @@ [ext_resource type="Script" path="res://scripts/controllers/cp/CommandPostController.gd" id="1_ljrld"] -[node name="CommandPostController" type="Node3D"] +[node name="CommandPostController" type="Node"] script = ExtResource("1_ljrld") cp_color = Color(0.766158, 2.56056e-05, 0.553493, 1) diff --git a/src/projects/Command Post/scripts/controllers/cp/defender/command_post_defenders.tscn b/src/projects/Command Post/scripts/controllers/cp/defender/command_post_defenders.tscn index 92a6acf..c920812 100644 --- a/src/projects/Command Post/scripts/controllers/cp/defender/command_post_defenders.tscn +++ b/src/projects/Command Post/scripts/controllers/cp/defender/command_post_defenders.tscn @@ -3,12 +3,8 @@ [ext_resource type="Script" path="res://scripts/controllers/cp/defender/CommandPostDefenders.gd" id="1_t3jlv"] [ext_resource type="PackedScene" uid="uid://bijsg61uyql4t" path="res://assets/character/defender/defender_character.tscn" id="2_7efxs"] -[node name="CommandPostDefenders" type="Node3D"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5, 0) +[node name="CommandPostDefenders" type="Node"] script = ExtResource("1_t3jlv") team = 2 spawn_entity = ExtResource("2_7efxs") cp_color = Color(0.262745, 0.501961, 0.709804, 1) - -[connection signal="child_entered_tree" from="." to="." method="_on_child_entered_tree"] -[connection signal="child_exiting_tree" from="." to="." method="_on_child_exiting_tree"] diff --git a/src/projects/Command Post/scripts/controllers/cp/neutral/command_post_neutral.tscn b/src/projects/Command Post/scripts/controllers/cp/neutral/command_post_neutral.tscn index 9767e7e..2cf5ada 100644 --- a/src/projects/Command Post/scripts/controllers/cp/neutral/command_post_neutral.tscn +++ b/src/projects/Command Post/scripts/controllers/cp/neutral/command_post_neutral.tscn @@ -2,10 +2,6 @@ [ext_resource type="Script" path="res://scripts/controllers/cp/neutral/CommandPostNeutral.gd" id="1_tfbyg"] -[node name="CommandPostNeutral" type="Node3D"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5, 0) +[node name="CommandPostNeutral" type="Node"] script = ExtResource("1_tfbyg") cp_color = Color(0.454902, 0.454902, 0.454902, 1) - -[connection signal="child_entered_tree" from="." to="." method="_on_child_entered_tree"] -[connection signal="child_exiting_tree" from="." to="." method="_on_child_exiting_tree"] diff --git a/src/projects/Command Post/scripts/controllers/cp/nonaligned/command_post_non_aligned.tscn b/src/projects/Command Post/scripts/controllers/cp/nonaligned/command_post_non_aligned.tscn index ce39af7..33033d8 100644 --- a/src/projects/Command Post/scripts/controllers/cp/nonaligned/command_post_non_aligned.tscn +++ b/src/projects/Command Post/scripts/controllers/cp/nonaligned/command_post_non_aligned.tscn @@ -3,12 +3,8 @@ [ext_resource type="Script" path="res://scripts/controllers/cp/nonaligned/command_post_non_aligned.gd" id="1_dqg0t"] [ext_resource type="PackedScene" uid="uid://6ngrwq73dgcn" path="res://assets/character/non_aligned/non_aligned_character.tscn" id="2_txjnm"] -[node name="CommandPostNonAligned" type="Node3D"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5, 0) +[node name="CommandPostNonAligned" type="Node"] script = ExtResource("1_dqg0t") team = -1 spawn_entity = ExtResource("2_txjnm") cp_color = Color(0.662745, 0.423529, 0, 1) - -[connection signal="child_entered_tree" from="." to="." method="_on_child_entered_tree"] -[connection signal="child_exiting_tree" from="." to="." method="_on_child_exiting_tree"] diff --git a/src/projects/Command Post/scripts/controllers/game/GameController.gd b/src/projects/Command Post/scripts/controllers/game/GameController.gd index c78575a..11b9066 100644 --- a/src/projects/Command Post/scripts/controllers/game/GameController.gd +++ b/src/projects/Command Post/scripts/controllers/game/GameController.gd @@ -1,4 +1,4 @@ -class_name GameController extends Node3D +class_name GameController extends Node @export var attacker_spawn_pool: int = 100 diff --git a/src/projects/Command Post/scripts/controllers/game/assault/game_controller_assault.tscn b/src/projects/Command Post/scripts/controllers/game/assault/game_controller_assault.tscn index 613e941..8d28695 100644 --- a/src/projects/Command Post/scripts/controllers/game/assault/game_controller_assault.tscn +++ b/src/projects/Command Post/scripts/controllers/game/assault/game_controller_assault.tscn @@ -2,8 +2,7 @@ [ext_resource type="Script" path="res://scripts/controllers/game/assault/GameControllerAssault.gd" id="1_3de00"] -[node name="GameControllerAssault" type="Node3D"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5, 0) +[node name="GameControllerAssault" type="Node"] script = ExtResource("1_3de00") attacker_spawn_pool = 32 defender_spawn_pool = 32 diff --git a/src/projects/Command Post/scripts/controllers/game/ctf/game_controller_ctf.tscn b/src/projects/Command Post/scripts/controllers/game/ctf/game_controller_ctf.tscn index 612ae53..08aef48 100644 --- a/src/projects/Command Post/scripts/controllers/game/ctf/game_controller_ctf.tscn +++ b/src/projects/Command Post/scripts/controllers/game/ctf/game_controller_ctf.tscn @@ -2,6 +2,5 @@ [ext_resource type="Script" path="res://scripts/controllers/game/ctf/GameControllerCTF.gd" id="1_8hqtg"] -[node name="GameControllerCTF" type="Node3D"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5, 0) +[node name="GameControllerCTF" type="Node"] script = ExtResource("1_8hqtg") diff --git a/src/projects/Command Post/scripts/controllers/game/game_controller.tscn b/src/projects/Command Post/scripts/controllers/game/game_controller.tscn index 510a32a..12d2893 100644 --- a/src/projects/Command Post/scripts/controllers/game/game_controller.tscn +++ b/src/projects/Command Post/scripts/controllers/game/game_controller.tscn @@ -2,5 +2,5 @@ [ext_resource type="Script" path="res://scripts/controllers/game/GameController.gd" id="1_fd8es"] -[node name="game_manager" type="Node3D"] +[node name="game_manager" type="Node"] script = ExtResource("1_fd8es") diff --git a/src/projects/Command Post/scripts/controllers/game/heros/game_controller_heros.tscn b/src/projects/Command Post/scripts/controllers/game/heros/game_controller_heros.tscn index 3e68005..75a1574 100644 --- a/src/projects/Command Post/scripts/controllers/game/heros/game_controller_heros.tscn +++ b/src/projects/Command Post/scripts/controllers/game/heros/game_controller_heros.tscn @@ -2,6 +2,5 @@ [ext_resource type="Script" path="res://scripts/controllers/game/heros/GameControllerHeros.gd" id="1_hdicy"] -[node name="GameControllerHeros" type="Node3D"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5, 0) +[node name="GameControllerHeros" type="Node"] script = ExtResource("1_hdicy") diff --git a/src/projects/Command Post/world.tscn b/src/projects/Command Post/world.tscn index 5e230b6..d35448a 100644 --- a/src/projects/Command Post/world.tscn +++ b/src/projects/Command Post/world.tscn @@ -63,22 +63,22 @@ metadata/_edit_lock_ = true metadata/_edit_lock_ = true [node name="command_post" parent="CommandPostNeutral" instance=ExtResource("1_i3oxs")] -transform = Transform3D(1.19209e-07, 0, -1, 0, 1, 0, 1, 0, 1.19209e-07, 0, -5, 0) +transform = Transform3D(1.19209e-07, 0, -1, 0, 1, 0, 1, 0, 1.19209e-07, 0, 0, 0) [node name="CommandPostNonAligned" parent="." instance=ExtResource("6_o56jr")] metadata/_edit_lock_ = true [node name="command_post" parent="CommandPostNonAligned" instance=ExtResource("1_i3oxs")] -transform = Transform3D(2.98023e-08, 0, -1, 0, 1, 0, 1, 0, 2.98023e-08, -16, -5, 0) +transform = Transform3D(2.98023e-08, 0, -1, 0, 1, 0, 1, 0, 2.98023e-08, -16, 0, 0) [node name="CommandPostAttackers" parent="." instance=ExtResource("4_v0ljc")] metadata/_edit_lock_ = true [node name="command_post" parent="CommandPostAttackers" instance=ExtResource("1_i3oxs")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, -5, 11) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 0, 11) [node name="CommandPostDefenders" parent="." instance=ExtResource("5_djntp")] metadata/_edit_lock_ = true [node name="command_post" parent="CommandPostDefenders" instance=ExtResource("1_i3oxs")] -transform = Transform3D(-0.866025, 0, 0.5, 0, 1, 0, -0.5, 0, -0.866025, 7, -5, -11) +transform = Transform3D(-0.866025, 0, 0.5, 0, 1, 0, -0.5, 0, -0.866025, 7, 0, -11)