Added spawn controller; added collision shape to jet; added yaw left to cpu default to test spawnning
This commit is contained in:
@@ -1,17 +1,32 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://cx5ewmp2xcuia"]
|
||||
[gd_scene load_steps=6 format=3 uid="uid://cx5ewmp2xcuia"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bhjfvc7gkrvah" path="res://base_environment.tscn" id="1_80nbo"]
|
||||
[ext_resource type="PackedScene" uid="uid://dk32bn35qku60" path="res://scripts/factories/jet_factory.tscn" id="2_e2o6t"]
|
||||
[ext_resource type="PackedScene" uid="uid://nlwfoq6opqck" path="res://scripts/game_modes/game_mode.tscn" id="3_fc0e3"]
|
||||
[ext_resource type="PackedScene" uid="uid://cuqllmpojcml5" path="res://scripts/controllers/spawn_system/spawn_controller.tscn" id="4_7jktm"]
|
||||
[ext_resource type="PackedScene" uid="uid://bgrku2wvaadgg" path="res://scripts/controllers/spawn_system/spawner.tscn" id="5_ryrav"]
|
||||
|
||||
[node name="game" type="Node3D"]
|
||||
|
||||
[node name="base_environment" parent="." instance=ExtResource("1_80nbo")]
|
||||
|
||||
[node name="camera" type="Camera3D" parent="."]
|
||||
transform = Transform3D(0.15819459, -0.4996306, 0.85167116, 0, 0.8625322, 0.5060022, -0.987408, -0.08004681, 0.13644792, 347.69992, 152.14081, 113.71016)
|
||||
current = true
|
||||
far = 8000.0
|
||||
|
||||
[node name="jet_factory" parent="." instance=ExtResource("2_e2o6t")]
|
||||
|
||||
[node name="game_mode" parent="." node_paths=PackedStringArray("jet_factory") instance=ExtResource("3_fc0e3")]
|
||||
jet_factory = NodePath("../jet_factory")
|
||||
|
||||
[node name="spawn_controller" parent="." node_paths=PackedStringArray("jet_factory") instance=ExtResource("4_7jktm")]
|
||||
jet_factory = NodePath("../jet_factory")
|
||||
|
||||
[node name="spawner" parent="spawn_controller" instance=ExtResource("5_ryrav")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 214.19254, 80.63972, 0)
|
||||
faction = 0
|
||||
|
||||
[node name="spawner2" parent="spawn_controller" instance=ExtResource("5_ryrav")]
|
||||
transform = Transform3D(0.4382143, 0, 0.8988705, 0, 1, 0, -0.8988705, 0, 0.4382143, 0, 100.550575, 0)
|
||||
faction = 1
|
||||
|
||||
+9
-2
@@ -1,13 +1,20 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://mtfp7066molc"]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://mtfp7066molc"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://be64wnjbfhnhh" path="res://scenes/jet.gd" id="1_l0pwp"]
|
||||
[ext_resource type="PackedScene" uid="uid://b5btmjvj2gosl" path="res://scripts/jet_controls/controller.tscn" id="2_t5v3o"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_31fu5"]
|
||||
size = Vector3(3, 2, 18)
|
||||
|
||||
[node name="jet" type="CharacterBody3D"]
|
||||
script = ExtResource("1_l0pwp")
|
||||
|
||||
[node name="camera" type="Camera3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5, 18)
|
||||
current = true
|
||||
far = 10000.0
|
||||
|
||||
[node name="collision" type="CollisionShape3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.17266846, -0.17565918, -1.5986328)
|
||||
shape = SubResource("BoxShape3D_31fu5")
|
||||
|
||||
[node name="controller" parent="." instance=ExtResource("2_t5v3o")]
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
class_name SpawnController extends Node
|
||||
|
||||
|
||||
@export var jet_factory: JetFactory
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
spawn_sides()
|
||||
|
||||
|
||||
func spawn_sides() -> void:
|
||||
spawn_allies_jet()
|
||||
spawn_axis_jet()
|
||||
|
||||
func spawn_neutral_jet():
|
||||
var _jet = spawn_jet(
|
||||
Globals.Faction.NEUTRAL, jet_factory.create_cpu_jet
|
||||
)
|
||||
|
||||
func spawn_allies_jet():
|
||||
var _jet = spawn_jet(
|
||||
Globals.Faction.ALLIES, jet_factory.create_cpu_jet
|
||||
)
|
||||
|
||||
func spawn_axis_jet():
|
||||
var _jet = spawn_jet(
|
||||
Globals.Faction.AXIS, jet_factory.create_cpu_jet
|
||||
)
|
||||
|
||||
func spawn_jet(faction: Globals.Faction, callback: Callable) -> Jet:
|
||||
var jet: Jet = null
|
||||
|
||||
for spawner: Spawner in get_children():
|
||||
if not spawner.faction == faction: continue
|
||||
if not spawner.is_available: continue
|
||||
|
||||
jet = callback.call(faction)
|
||||
spawner.align_to_position.call_deferred(jet)
|
||||
|
||||
return jet
|
||||
@@ -0,0 +1 @@
|
||||
uid://bd8ae65orh663
|
||||
@@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://cuqllmpojcml5"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bd8ae65orh663" path="res://scripts/controllers/spawn_system/spawn_controller.gd" id="1_xcv1c"]
|
||||
|
||||
[node name="spawn_controller" type="Node3D"]
|
||||
script = ExtResource("1_xcv1c")
|
||||
@@ -0,0 +1,36 @@
|
||||
class_name Spawner extends Area3D
|
||||
|
||||
|
||||
@export var faction: Globals.Faction = Globals.Faction.NEUTRAL
|
||||
|
||||
var is_available: bool = true
|
||||
var delay_timer: Timer = null
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
pass
|
||||
|
||||
func _on_area_body_entered(_body: Jet) -> void:
|
||||
if delay_timer:
|
||||
delay_timer.stop()
|
||||
|
||||
delay_timer = null
|
||||
|
||||
func _on_area_body_exited(_body: Jet) -> void:
|
||||
delay_timer = Timer.new()
|
||||
delay_timer.one_shot = true
|
||||
delay_timer.timeout.connect(can_spawn)
|
||||
|
||||
|
||||
func set_can_spawn(availablity: bool = true) -> void:
|
||||
is_available = availablity
|
||||
|
||||
func can_spawn() -> void:
|
||||
is_available = true
|
||||
|
||||
func cannot_spawn() -> void:
|
||||
is_available = false
|
||||
|
||||
func align_to_position(jet: Jet) -> void:
|
||||
jet.global_position = global_position
|
||||
jet.rotation = rotation
|
||||
@@ -0,0 +1 @@
|
||||
uid://2xevacik8ja4
|
||||
@@ -0,0 +1,20 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://bgrku2wvaadgg"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://2xevacik8ja4" path="res://scripts/controllers/spawn_system/spawner.gd" id="1_yd0ab"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_7k17k"]
|
||||
size = Vector3(20, 10, 25)
|
||||
|
||||
[node name="spawner" type="Area3D"]
|
||||
script = ExtResource("1_yd0ab")
|
||||
|
||||
[node name="detector" type="CollisionShape3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.9008179, 0)
|
||||
shape = SubResource("BoxShape3D_7k17k")
|
||||
|
||||
[node name="ray" type="RayCast3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.3711385e-08, -0.99999994, 0, 0.99999994, -4.3711385e-08, 0, 0, -12.65)
|
||||
top_level = true
|
||||
enabled = false
|
||||
hit_back_faces = false
|
||||
collide_with_bodies = false
|
||||
@@ -12,29 +12,31 @@ func _get_jet_type(faction: int) -> Jet:
|
||||
|
||||
if faction == Globals.Faction.ALLIES:
|
||||
jet = create_allies_jet()
|
||||
jet.name = Globals.Faction.keys()[Globals.Faction.ALLIES] + "_JET"
|
||||
elif faction == Globals.Faction.AXIS:
|
||||
jet = create_axis_jet()
|
||||
jet.name = Globals.Faction.keys()[Globals.Faction.AXIS] + "_JET"
|
||||
elif faction == Globals.Faction.NEUTRAL:
|
||||
jet = create_neutral_jet()
|
||||
jet.name = Globals.Faction.keys()[Globals.Faction.NEUTRAL] + "_JET"
|
||||
else:
|
||||
jet = create_neutral_jet()
|
||||
|
||||
get_tree().root.add_child.call_deferred(jet)
|
||||
|
||||
await jet.ready
|
||||
return jet
|
||||
|
||||
|
||||
func create_player_jet(faction: int = 0) -> Jet:
|
||||
var jet: Jet = await _get_jet_type(faction)
|
||||
var jet: Jet = _get_jet_type(faction)
|
||||
|
||||
jet.set_as_player()
|
||||
jet.set_as_player.call_deferred()
|
||||
return jet
|
||||
|
||||
func create_cpu_jet(faction: int = 0) -> Jet:
|
||||
var jet = await _get_jet_type(faction)
|
||||
var jet = _get_jet_type(faction)
|
||||
|
||||
jet.set_as_cpu()
|
||||
jet.set_as_cpu.call_deferred()
|
||||
return jet
|
||||
|
||||
|
||||
|
||||
@@ -16,4 +16,4 @@ const MODES: Dictionary = {
|
||||
|
||||
func _ready() -> void:
|
||||
#MODES[mode].instantiate()
|
||||
jet_factory.create_player_jet(Globals.Faction.ALLIES)
|
||||
pass
|
||||
|
||||
@@ -2,7 +2,7 @@ class_name CPU extends Node
|
||||
|
||||
|
||||
func process(_delta: float) -> Globals.ControllerCommand:
|
||||
return Globals.ControllerCommand.NONE
|
||||
return Globals.ControllerCommand.YAW_LEFT
|
||||
|
||||
func physics_process(_delta: float) -> Globals.ControllerCommand:
|
||||
return Globals.ControllerCommand.NONE
|
||||
|
||||
Reference in New Issue
Block a user