Fixed bugs regarding switch

This commit is contained in:
Rendo 2025-12-12 14:37:17 +05:00
commit 162dbc13e8
3 changed files with 6 additions and 4 deletions

View file

@ -200,9 +200,10 @@ script = ExtResource("3_6wy0j")
layout_mode = 2 layout_mode = 2
text = "Статус публичного IP:" text = "Статус публичного IP:"
[node name="PublicIP" type="Label" parent="Lobby/HBoxContainer/HostMenu"] [node name="PublicIP" type="LineEdit" parent="Lobby/HBoxContainer/HostMenu"]
unique_name_in_owner = true unique_name_in_owner = true
layout_mode = 2 layout_mode = 2
editable = false
script = ExtResource("3_qy2xc") script = ExtResource("3_qy2xc")
[connection signal="pressed" from="MainMenu/VBoxContainer/HostButton" to="." method="_on_host_button_pressed"] [connection signal="pressed" from="MainMenu/VBoxContainer/HostButton" to="." method="_on_host_button_pressed"]

View file

@ -1,4 +1,4 @@
extends Label extends LineEdit
func on_update_ip(to: StringName): func on_update_ip(to: StringName):
text = to text = to

View file

@ -92,7 +92,8 @@ func switch(to: StringName, exit: bool = true):
if exit: if exit:
current_state._exit() current_state._exit()
if current_state.can_be_previous: if current_state.can_be_previous:
last_slot = slots.find_key(current_state) var found = slots.find_key(current_state)
last_slot = found if found else ""
current_state = slots[to] current_state = slots[to]
current_state._enter() current_state._enter()
@ -119,7 +120,7 @@ func drop(weapon: WeaponSubStateMachine) -> void:
dropped_weapon.weapon.ammo = weapon.ammo dropped_weapon.weapon.ammo = weapon.ammo
dropped_weapon.weapon.remaining_ammo = weapon.remaining_ammo dropped_weapon.weapon.remaining_ammo = weapon.remaining_ammo
dropped_weapon.weapon.slot = weapon.slot dropped_weapon.weapon.slot = weapon.slot
Session.dynamic_objects_parent.add_child(dropped_weapon) Session.dynamic_objects_parent.add_child(dropped_weapon,true)
dropped_weapon.global_position = camera.global_position dropped_weapon.global_position = camera.global_position
dropped_weapon.apply_central_impulse(-camera.global_basis.z * 10 + player.velocity) dropped_weapon.apply_central_impulse(-camera.global_basis.z * 10 + player.velocity)