Many fixes

This commit is contained in:
Rendo 2025-12-17 01:59:35 +05:00
commit e758c9f042
11 changed files with 8784 additions and 8739 deletions

View file

@ -65,11 +65,10 @@ func _ready() -> void:
func _enter() -> void:
super()
player.weapon_models[weapon_gid].show()
player.show_weapon(weapon_gid)
func _exit() -> void:
super()
player.weapon_models[weapon_gid].hide()
func use_begin() -> void:
if current_state != null:

View file

@ -97,8 +97,9 @@ func switch(to: StringName, exit: bool = true):
if exit:
current_state._exit()
if current_state.can_be_previous:
var found = slots.find_key(current_state)
last_slot = found if found else ""
last_slot = get_current_slot()
else:
last_slot = ""
current_state = slots[to]
current_state._enter()
@ -107,11 +108,20 @@ func switch(to: StringName, exit: bool = true):
notify_slots_updated()
func return_to_previous(exit: bool = true):
if last_slot == get_current_slot():
last_slot = "knife"
if last_slot != "":
switch(last_slot, exit)
else:
switch("knife", exit)
func get_current_slot() -> StringName:
if current_state == null:
return "knife"
else:
var found = slots.find_key(current_state)
return found if found else ""
func drop_current():
drop(current_state)
@ -180,7 +190,7 @@ func notify_slots_updated():
else:
display_slots[key] = slots[key].weapon_gid
var current_slot: StringName = ""
var found = slots.find_key(current_state)
var found = get_current_slot()
if found:
current_slot = found