HUD and prototype textures

This commit is contained in:
Rendo 2025-11-29 18:48:32 +05:00
commit 03bc73e9ff
45 changed files with 742 additions and 26 deletions

View file

@ -21,6 +21,8 @@ var slots: Dictionary[StringName,WeaponSubStateMachine] = {
}
signal switched_to(state: WeaponSubStateMachine)
signal slots_updated(slots: Dictionary[StringName,WeaponSubStateMachine])
signal ammo_updated(ammo: int, remaining_ammo: int)
func _ready() -> void:
$WeaponSpawner.spawn_function = pick_up_weapon
@ -53,9 +55,12 @@ func add(state: WeaponSubStateMachine, slot: StringName,ignore_parent: bool = fa
state.player = player
state.request_return.connect(return_to_previous)
state.ammo_depleted.connect(check_for_empty)
state.ammo_updated.connect(on_ammo_updated)
slots_updated.emit(slots)
if current_state == null:
current_state = state
ammo_updated.emit(current_state.ammo,current_state.remaining_ammo)
state.enter.call_deferred()
func switch(to: StringName, exit: bool = true):
@ -70,6 +75,7 @@ func switch(to: StringName, exit: bool = true):
current_state = slots[to]
current_state.enter()
ammo_updated.emit(current_state.ammo,current_state.remaining_ammo)
switched_to.emit(current_state)
update_remotes.rpc(to,exit)
@ -105,6 +111,7 @@ func drop():
$"../PickupRange".start_temp_ignore()
slots[slots.find_key(current_state)] = null
slots_updated.emit(slots)
current_state.queue_free()
return_to_previous(false)
@ -141,6 +148,9 @@ func check_for_empty() -> void:
if child is WeaponSubStateMachine and child.ammo == 0 and child.remaining_ammo == 0 and child.destroy_when_empty:
child.queue_free()
func on_ammo_updated() -> void:
ammo_updated.emit(current_state.ammo,current_state.remaining_ammo)
func _process(delta: float) -> void:
if current_state == null:
return