drop on death

This commit is contained in:
Rendo 2025-11-30 00:15:42 +05:00
commit 27f1e0c0aa
5 changed files with 36 additions and 14 deletions

View file

@ -96,14 +96,17 @@ func update_remotes(to: StringName,exit: bool):
switched_to.emit(current_state)
func drop():
if slots.find_key(current_state) == "knife":
func drop_current():
drop(current_state)
func drop(weapon: WeaponSubStateMachine) -> void:
if slots.find_key(weapon) == "knife":
return
var drop_data: Dictionary = {}
drop_data.scene = current_state.droppable
drop_data.ammo = current_state.ammo
drop_data.remaining_ammo = current_state.remaining_ammo
drop_data.slot = current_state.slot
drop_data.scene = weapon.droppable
drop_data.ammo = weapon.ammo
drop_data.remaining_ammo = weapon.remaining_ammo
drop_data.slot = weapon.slot
drop_data.position = camera.global_position
drop_data.impulse = -camera.global_basis.z * 10 + player.velocity
@ -111,11 +114,16 @@ func drop():
$"../PickupRange".start_temp_ignore()
slots[slots.find_key(current_state)] = null
slots[slots.find_key(weapon)] = null
slots_updated.emit(slots)
current_state.queue_free()
weapon.queue_free()
return_to_previous(false)
func drop_slot(slot: StringName):
if slots.has(slot) == false or slots[slot] == null:
return
drop(slots[slot])
# Spawn function
# Data should be a dictionary with these keys:
# ammo
@ -198,5 +206,5 @@ func _input(event: InputEvent) -> void:
current_state.switch_mode()
if event.is_action_pressed("plr_drop"):
drop()
drop_current()