From 255a47f6da8f930f7dcbefd494c3f5ced5a39cfb Mon Sep 17 00:00:00 2001 From: gotfishmakesticks <80163046+gotfishmakesticks@users.noreply.github.com> Date: Thu, 18 Jan 2024 13:43:03 +0300 Subject: [PATCH] Fixed shield crash and material coloring --- scenes/menus/BaseMenu.tscn | 4 ++++ scenes/shields/npcshield.tscn | 1 + scenes/shields/startershield.tscn | 1 + scripts/misc/BaseMenuOpen.gd | 2 +- scripts/objects/Shield.gd | 1 + scripts/objects/ShipEngine.gd | 11 +---------- scripts/objects/weapon.gd | 2 +- 7 files changed, 10 insertions(+), 12 deletions(-) diff --git a/scenes/menus/BaseMenu.tscn b/scenes/menus/BaseMenu.tscn index 8dc3c17..6c35bcd 100644 --- a/scenes/menus/BaseMenu.tscn +++ b/scenes/menus/BaseMenu.tscn @@ -171,6 +171,7 @@ horizontal_alignment = 1 vertical_alignment = 1 [node name="LabelSell" type="Label" parent="TradingMenu"] +layout_mode = 0 offset_left = 320.0 offset_top = 64.0 offset_right = 640.0 @@ -205,6 +206,7 @@ text = "0" vertical_alignment = 1 [node name="FoodCount" type="Label" parent="TradingMenu"] +layout_mode = 0 offset_left = 201.0 offset_top = 592.0 offset_right = 321.0 @@ -213,6 +215,7 @@ text = "0" vertical_alignment = 1 [node name="MineralsCount" type="Label" parent="TradingMenu"] +layout_mode = 0 offset_left = 361.0 offset_top = 592.0 offset_right = 481.0 @@ -221,6 +224,7 @@ text = "0" vertical_alignment = 1 [node name="WaterCount" type="Label" parent="TradingMenu"] +layout_mode = 0 offset_left = 521.0 offset_top = 592.0 offset_right = 640.0 diff --git a/scenes/shields/npcshield.tscn b/scenes/shields/npcshield.tscn index 4c96733..e5c5931 100644 --- a/scenes/shields/npcshield.tscn +++ b/scenes/shields/npcshield.tscn @@ -3,6 +3,7 @@ [ext_resource type="Script" path="res://scripts/objects/Shield.gd" id="1_3t0v2"] [node name="Shield" type="Node2D" node_paths=PackedStringArray("recharge_timer", "laser_timer")] +use_parent_material = true script = ExtResource("1_3t0v2") max_capacity = 5 recharge_timer = NodePath("Timer") diff --git a/scenes/shields/startershield.tscn b/scenes/shields/startershield.tscn index 7896090..ec88afd 100644 --- a/scenes/shields/startershield.tscn +++ b/scenes/shields/startershield.tscn @@ -3,6 +3,7 @@ [ext_resource type="Script" path="res://scripts/objects/Shield.gd" id="1_6qr86"] [node name="Shield" type="Node2D" node_paths=PackedStringArray("recharge_timer", "laser_timer")] +use_parent_material = true script = ExtResource("1_6qr86") max_capacity = 10 recharge_timer = NodePath("Timer") diff --git a/scripts/misc/BaseMenuOpen.gd b/scripts/misc/BaseMenuOpen.gd index 30bc153..56a303b 100644 --- a/scripts/misc/BaseMenuOpen.gd +++ b/scripts/misc/BaseMenuOpen.gd @@ -19,7 +19,7 @@ func _on_body_entered(body): ship_in_menu = true body.allow_shooting = false menu_inst = menu.instantiate() - menu_inst.modulate = get_parent().modulate + menu_inst.modulate = get_parent().material.get_shader_parameter('color') menu_inst.base = get_parent() body.find_child("GUI").add_child(menu_inst) body.minimap.visible = false diff --git a/scripts/objects/Shield.gd b/scripts/objects/Shield.gd index 83ef209..e249e84 100644 --- a/scripts/objects/Shield.gd +++ b/scripts/objects/Shield.gd @@ -20,6 +20,7 @@ var wave_positions = [Vector2.ZERO,Vector2.ZERO,Vector2.ZERO,Vector2.ZERO,Vector func _ready(): recharge_timer.timeout.connect(recharging_timer_out) laser_timer.timeout.connect(laser_timer_out) + material = ship.material func deal_damage(damage : float,hit_position : Vector2): # Shield wave diff --git a/scripts/objects/ShipEngine.gd b/scripts/objects/ShipEngine.gd index 792c91e..f2036d8 100644 --- a/scripts/objects/ShipEngine.gd +++ b/scripts/objects/ShipEngine.gd @@ -16,19 +16,10 @@ var turbo_enabled = false var alternative_movement = false var destination_angle : float var destination_difference : float -var rdy = false - -func _ready(): - get_tree().create_timer(0.05).timeout.connect(is_rdy) - -func is_rdy(): - rdy = true - hull = ship.hull func _physics_process(delta): - if !rdy: - return hull = ship.hull + modulate = ship.material.get_shader_parameter('color') var turbo_input = Input.get_action_raw_strength("turbo") var acceleration_input = Input.get_axis("deccelerate", "accelerate") if ship is MainShip else 1.0 var rotation_input = Input.get_axis("rotateleft","rotateright") diff --git a/scripts/objects/weapon.gd b/scripts/objects/weapon.gd index 3f6e61f..e9ef596 100644 --- a/scripts/objects/weapon.gd +++ b/scripts/objects/weapon.gd @@ -45,5 +45,5 @@ func shoot(): proj_inst.global_position = spawner.global_position proj_inst.global_rotation = spawner.global_rotation + randf_range(-deviation/2, deviation/2) proj_inst.faction = ship.faction - proj_inst.modulate = ship.modulate + proj_inst.modulate = ship.material.get_shader_parameter('color') weapon_shooted.emit()