PlayerData and EnemyData reworked for WeaponData

This commit is contained in:
2025-12-17 22:02:54 +03:00
parent 36e6a9bb10
commit d55047239a
19 changed files with 80 additions and 45 deletions
@@ -35,8 +35,8 @@ func _set_enemy_data(data: EnemyData) -> void:
positions.remove_at(0)
for i in range(min(enemy_data.weapon_count, positions.size())):
var weapon := _create_weapon(enemy_data.weapon_id)
_add_weapon(weapon, positions[i])
var weapon : AbstractWeapon = enemy_data.weapon.scene.instantiate()
_add_weapon(weapon, weapon_positions[i])
func _create_weapon(weapon_id : String) -> AbstractWeapon:
+4 -10
View File
@@ -67,21 +67,15 @@ func _set_player_data(new_data: PlayerData) -> void:
player_data = new_data
_weapons.clear()
for i in range(min(player_data.weapon_ids.size(), weapon_positions.size())):
_add_weapon_by_id(player_data.weapon_ids[i], weapon_positions[i])
for i in range(min(player_data.weapons.size(), weapon_positions.size())):
var weapon_scene := player_data.weapons[i].scene
var weapon : AbstractWeapon = weapon_scene.instantiate()
_add_weapon(weapon, weapon_positions[i])
if player_data.hull > 0:
health.hull = min(player_data.hull, health.max_hull)
func _add_weapon_by_id(weapon_id: String, weapon_position: Vector2) -> void:
if weapon_id.is_empty() or not weapon_id in WEAPON_SCENES: return
var weapon_scene : PackedScene = load(WEAPON_SCENES[weapon_id])
var weapon : AbstractWeapon = weapon_scene.instantiate()
_add_weapon(weapon, weapon_position)
func _on_hull_updated(value: int, max_value: int) -> void:
super._on_hull_updated(value, max_value)
@@ -7,5 +7,6 @@
script = ExtResource("1_c34y3")
id = "cannon"
name = "Cannon"
group = "explosion"
scene = ExtResource("3_2dgua")
metadata/_custom_type_script = "uid://870r1efinhqd"
@@ -7,5 +7,6 @@
script = ExtResource("1_bt4k8")
id = "gatling"
name = "Gatling"
group = "kinetic"
scene = ExtResource("3_2rwg6")
metadata/_custom_type_script = "uid://870r1efinhqd"
@@ -7,5 +7,6 @@
script = ExtResource("1_ipxhy")
id = "laser"
name = "Laser"
group = "energy"
scene = ExtResource("1_aey1r")
metadata/_custom_type_script = "uid://870r1efinhqd"
@@ -7,5 +7,6 @@
script = ExtResource("1_tcis2")
id = "launcher"
name = "launcher"
group = "explosion"
scene = ExtResource("1_3oqtq")
metadata/_custom_type_script = "uid://870r1efinhqd"
@@ -7,5 +7,6 @@
script = ExtResource("1_152qt")
id = "minelayer"
name = "Minelayer"
group = "explosion"
scene = ExtResource("1_fh5qv")
metadata/_custom_type_script = "uid://870r1efinhqd"
@@ -7,5 +7,6 @@
script = ExtResource("1_3fasx")
id = "plasma"
name = "Plasma"
group = "energy"
scene = ExtResource("1_rcvob")
metadata/_custom_type_script = "uid://870r1efinhqd"
@@ -7,5 +7,6 @@
script = ExtResource("1_6lcn5")
id = "railgun"
name = "Railgun"
group = "kinetic"
scene = ExtResource("1_cbt0i")
metadata/_custom_type_script = "uid://870r1efinhqd"
@@ -7,5 +7,6 @@
script = ExtResource("1_xds2o")
id = "shrapnel"
name = "Shrapnel"
group = "kinetic"
scene = ExtResource("1_8lpql")
metadata/_custom_type_script = "uid://870r1efinhqd"
@@ -7,5 +7,6 @@
script = ExtResource("1_a16gw")
id = "tesla"
name = "Tesla"
group = "energy"
scene = ExtResource("1_uxb6m")
metadata/_custom_type_script = "uid://870r1efinhqd"