33 lines
728 B
GDScript
33 lines
728 B
GDScript
extends Node3D
|
|
|
|
class_name Weapon
|
|
|
|
@onready var barrel = $"Barrel"
|
|
@export var uses_hands: Array[CommandQueue.Side]
|
|
|
|
@export var max_ammo: int = 7
|
|
var ammo: int = max_ammo
|
|
@export var ammo_consumption: int = 1
|
|
|
|
@export var fire_mode: BaseFireMode
|
|
## Weapon animation library. Should contain "static", "fire", "reload" animations
|
|
@export var animation_library: AnimationLibrary
|
|
|
|
var is_firing: bool = false
|
|
|
|
func _ready() -> void:
|
|
fire_mode.barrel = barrel
|
|
|
|
## Begin to fire
|
|
func request_fire() -> void:
|
|
fire_mode.on_fire_begin(get_tree())
|
|
is_firing = true
|
|
|
|
func _process(_dt) -> void:
|
|
if is_firing:
|
|
fire_mode._process(get_tree())
|
|
|
|
## End fire
|
|
func end_fire() -> void:
|
|
fire_mode.on_fire_end(get_tree())
|
|
is_firing = false
|