Reworked projectile deletion. Reworked railgun piercing
This commit is contained in:
@@ -10,7 +10,6 @@ const ENEMY_PROJECTILE_LAYER = 16
|
||||
|
||||
@export var damage : AbstractDamage
|
||||
@export_range(0, 1000) var speed : int = 0
|
||||
@export_range(0, 10) var piercing: int = 0
|
||||
|
||||
|
||||
@onready var collision : CollisionShape2D = $CollisionShape2D
|
||||
@@ -72,7 +71,8 @@ func _on_body_entered(body: Node2D) -> void:
|
||||
var health_component : Health = body.find_child("Health")
|
||||
if health_component and health_component.has_method("apply_damage"):
|
||||
health_component.apply_damage(damage)
|
||||
if piercing == 0:
|
||||
queue_free()
|
||||
else:
|
||||
piercing -= 1
|
||||
_process_hit_for_projectile()
|
||||
|
||||
|
||||
func _process_hit_for_projectile() -> void:
|
||||
queue_free()
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
extends AbstractProjectile
|
||||
|
||||
|
||||
@export_range(1, 10) var piercing: int = 1
|
||||
|
||||
|
||||
@onready var sprite_left := $Sprite2D_Left
|
||||
@onready var sprite_right := $Sprite2D_Right
|
||||
|
||||
@@ -19,3 +22,10 @@ func _update_sprite(velocity: Vector2) -> void:
|
||||
else:
|
||||
sprite_left.hide()
|
||||
sprite_right.show()
|
||||
|
||||
|
||||
func _process_hit_for_projectile() -> void:
|
||||
if piercing == 0:
|
||||
queue_free()
|
||||
else:
|
||||
piercing -= 1
|
||||
|
||||
@@ -26,9 +26,9 @@ height = 4.0
|
||||
collision_layer = 0
|
||||
collision_mask = 0
|
||||
script = ExtResource("1_hycpq")
|
||||
piercing = 1
|
||||
damage = SubResource("Resource_u82jm")
|
||||
speed = 900
|
||||
piercing = 1
|
||||
|
||||
[node name="Sprite2D_Left" type="Sprite2D" parent="." index="0"]
|
||||
texture = SubResource("AtlasTexture_u82jm")
|
||||
|
||||
Reference in New Issue
Block a user