depleted ammo destruction

This commit is contained in:
Rendo 2025-11-29 00:55:07 +05:00
commit 900502ec8a
12 changed files with 68 additions and 2068 deletions

View file

@ -52,6 +52,7 @@ func add(state: WeaponSubStateMachine, slot: StringName,ignore_parent: bool = fa
state.player_camera = camera
state.player = player
state.request_return.connect(return_to_previous)
state.ammo_depleted.connect(check_for_empty)
if current_state == null:
current_state = state
@ -133,6 +134,13 @@ func pick_up_weapon(data: Variant) -> Node:
return scene
func check_for_empty() -> void:
if is_multiplayer_authority() == false:
return
for child in get_children():
if child is WeaponSubStateMachine and child.ammo == 0 and child.remaining_ammo == 0 and child.destroy_when_empty:
child.queue_free()
func _process(delta: float) -> void:
if current_state == null:
return