refactoring command post mini project 3
This commit is contained in:
parent
93c3ee323c
commit
9857bb4c87
|
@ -1,4 +1,4 @@
|
||||||
class_name CommandPostController extends Node3D
|
class_name CommandPostController extends Node
|
||||||
|
|
||||||
|
|
||||||
@export var team: Enums.Faction;
|
@export var team: Enums.Faction;
|
||||||
|
@ -19,16 +19,16 @@ func _on_child_exiting_tree(_cp: CommandPost):
|
||||||
|
|
||||||
|
|
||||||
func do_spawn():
|
func do_spawn():
|
||||||
var spawners = self.get_children()
|
var command_posts = self.get_children()
|
||||||
if spawners.size() == 0: return
|
if command_posts.size() == 0: return
|
||||||
|
|
||||||
var target = null
|
var target_cp = null
|
||||||
for spawn in spawners:
|
for command_post in command_posts:
|
||||||
if spawn.contested:
|
if command_post.contested:
|
||||||
target = spawn
|
target_cp = command_post
|
||||||
|
|
||||||
if not target:
|
if not target_cp:
|
||||||
randomize()
|
randomize()
|
||||||
target = spawners[ randi() % len(spawners) ]
|
target_cp = command_posts[ randi() % len(command_posts) ]
|
||||||
|
|
||||||
target.spawn(spawn_entity)
|
target_cp.spawn(spawn_entity)
|
||||||
|
|
|
@ -3,12 +3,8 @@
|
||||||
[ext_resource type="Script" path="res://scripts/controllers/cp/attacker/CommandPostAttackers.gd" id="1_71i6h"]
|
[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"]
|
[ext_resource type="PackedScene" uid="uid://cc3xcu8ipc6mu" path="res://assets/character/attacker/attacker_character.tscn" id="2_itmdl"]
|
||||||
|
|
||||||
[node name="CommandPostAttackers" type="Node3D"]
|
[node name="CommandPostAttackers" type="Node"]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5, 0)
|
|
||||||
script = ExtResource("1_71i6h")
|
script = ExtResource("1_71i6h")
|
||||||
team = 1
|
team = 1
|
||||||
spawn_entity = ExtResource("2_itmdl")
|
spawn_entity = ExtResource("2_itmdl")
|
||||||
cp_color = Color(0.87451, 0.160784, 0.105882, 1)
|
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"]
|
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/controllers/cp/CommandPostController.gd" id="1_ljrld"]
|
[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")
|
script = ExtResource("1_ljrld")
|
||||||
cp_color = Color(0.766158, 2.56056e-05, 0.553493, 1)
|
cp_color = Color(0.766158, 2.56056e-05, 0.553493, 1)
|
||||||
|
|
|
@ -3,12 +3,8 @@
|
||||||
[ext_resource type="Script" path="res://scripts/controllers/cp/defender/CommandPostDefenders.gd" id="1_t3jlv"]
|
[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"]
|
[ext_resource type="PackedScene" uid="uid://bijsg61uyql4t" path="res://assets/character/defender/defender_character.tscn" id="2_7efxs"]
|
||||||
|
|
||||||
[node name="CommandPostDefenders" type="Node3D"]
|
[node name="CommandPostDefenders" type="Node"]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5, 0)
|
|
||||||
script = ExtResource("1_t3jlv")
|
script = ExtResource("1_t3jlv")
|
||||||
team = 2
|
team = 2
|
||||||
spawn_entity = ExtResource("2_7efxs")
|
spawn_entity = ExtResource("2_7efxs")
|
||||||
cp_color = Color(0.262745, 0.501961, 0.709804, 1)
|
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"]
|
|
||||||
|
|
|
@ -2,10 +2,6 @@
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/controllers/cp/neutral/CommandPostNeutral.gd" id="1_tfbyg"]
|
[ext_resource type="Script" path="res://scripts/controllers/cp/neutral/CommandPostNeutral.gd" id="1_tfbyg"]
|
||||||
|
|
||||||
[node name="CommandPostNeutral" type="Node3D"]
|
[node name="CommandPostNeutral" type="Node"]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5, 0)
|
|
||||||
script = ExtResource("1_tfbyg")
|
script = ExtResource("1_tfbyg")
|
||||||
cp_color = Color(0.454902, 0.454902, 0.454902, 1)
|
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"]
|
|
||||||
|
|
|
@ -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="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"]
|
[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"]
|
[node name="CommandPostNonAligned" type="Node"]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5, 0)
|
|
||||||
script = ExtResource("1_dqg0t")
|
script = ExtResource("1_dqg0t")
|
||||||
team = -1
|
team = -1
|
||||||
spawn_entity = ExtResource("2_txjnm")
|
spawn_entity = ExtResource("2_txjnm")
|
||||||
cp_color = Color(0.662745, 0.423529, 0, 1)
|
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"]
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class_name GameController extends Node3D
|
class_name GameController extends Node
|
||||||
|
|
||||||
|
|
||||||
@export var attacker_spawn_pool: int = 100
|
@export var attacker_spawn_pool: int = 100
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/controllers/game/assault/GameControllerAssault.gd" id="1_3de00"]
|
[ext_resource type="Script" path="res://scripts/controllers/game/assault/GameControllerAssault.gd" id="1_3de00"]
|
||||||
|
|
||||||
[node name="GameControllerAssault" type="Node3D"]
|
[node name="GameControllerAssault" type="Node"]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5, 0)
|
|
||||||
script = ExtResource("1_3de00")
|
script = ExtResource("1_3de00")
|
||||||
attacker_spawn_pool = 32
|
attacker_spawn_pool = 32
|
||||||
defender_spawn_pool = 32
|
defender_spawn_pool = 32
|
||||||
|
|
|
@ -2,6 +2,5 @@
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/controllers/game/ctf/GameControllerCTF.gd" id="1_8hqtg"]
|
[ext_resource type="Script" path="res://scripts/controllers/game/ctf/GameControllerCTF.gd" id="1_8hqtg"]
|
||||||
|
|
||||||
[node name="GameControllerCTF" type="Node3D"]
|
[node name="GameControllerCTF" type="Node"]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5, 0)
|
|
||||||
script = ExtResource("1_8hqtg")
|
script = ExtResource("1_8hqtg")
|
||||||
|
|
|
@ -2,5 +2,5 @@
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/controllers/game/GameController.gd" id="1_fd8es"]
|
[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")
|
script = ExtResource("1_fd8es")
|
||||||
|
|
|
@ -2,6 +2,5 @@
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/controllers/game/heros/GameControllerHeros.gd" id="1_hdicy"]
|
[ext_resource type="Script" path="res://scripts/controllers/game/heros/GameControllerHeros.gd" id="1_hdicy"]
|
||||||
|
|
||||||
[node name="GameControllerHeros" type="Node3D"]
|
[node name="GameControllerHeros" type="Node"]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5, 0)
|
|
||||||
script = ExtResource("1_hdicy")
|
script = ExtResource("1_hdicy")
|
||||||
|
|
|
@ -63,22 +63,22 @@ metadata/_edit_lock_ = true
|
||||||
metadata/_edit_lock_ = true
|
metadata/_edit_lock_ = true
|
||||||
|
|
||||||
[node name="command_post" parent="CommandPostNeutral" instance=ExtResource("1_i3oxs")]
|
[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")]
|
[node name="CommandPostNonAligned" parent="." instance=ExtResource("6_o56jr")]
|
||||||
metadata/_edit_lock_ = true
|
metadata/_edit_lock_ = true
|
||||||
|
|
||||||
[node name="command_post" parent="CommandPostNonAligned" instance=ExtResource("1_i3oxs")]
|
[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")]
|
[node name="CommandPostAttackers" parent="." instance=ExtResource("4_v0ljc")]
|
||||||
metadata/_edit_lock_ = true
|
metadata/_edit_lock_ = true
|
||||||
|
|
||||||
[node name="command_post" parent="CommandPostAttackers" instance=ExtResource("1_i3oxs")]
|
[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")]
|
[node name="CommandPostDefenders" parent="." instance=ExtResource("5_djntp")]
|
||||||
metadata/_edit_lock_ = true
|
metadata/_edit_lock_ = true
|
||||||
|
|
||||||
[node name="command_post" parent="CommandPostDefenders" instance=ExtResource("1_i3oxs")]
|
[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)
|
||||||
|
|
Loading…
Reference in New Issue