Gun reload
This commit is contained in:
parent
a3dfc050f1
commit
12cb74ba2c
6 changed files with 118 additions and 44 deletions
|
@ -3,6 +3,7 @@ extends Node3D
|
|||
class_name Weapon
|
||||
|
||||
signal fired()
|
||||
signal fire_failed()
|
||||
|
||||
@onready var barrel = $"Barrel"
|
||||
@export var uses_hands: Array[CommandQueue.Side]
|
||||
|
@ -25,7 +26,10 @@ func _ready() -> void:
|
|||
|
||||
## Begin to fire
|
||||
func request_fire() -> void:
|
||||
fire_mode._on_fire_begin()
|
||||
if not is_firing and ammo >= ammo_consumption:
|
||||
fire_mode._on_fire_begin()
|
||||
elif ammo < ammo_consumption:
|
||||
fire_failed.emit()
|
||||
|
||||
func _process(_dt) -> void:
|
||||
if is_firing:
|
||||
|
@ -39,4 +43,8 @@ func end_fire() -> void:
|
|||
|
||||
func on_barrel_fired() -> void:
|
||||
is_firing = true
|
||||
ammo -= ammo_consumption
|
||||
fired.emit()
|
||||
|
||||
func reload() -> void:
|
||||
ammo = max_ammo
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue