some glue code between player and weapon
This commit is contained in:
parent
39fb87f62d
commit
ec7b08812d
6 changed files with 100 additions and 124 deletions
|
@ -2,7 +2,7 @@ extends Node3D
|
|||
|
||||
class_name Weapon
|
||||
|
||||
@export var barrel: Barrel
|
||||
@onready var barrel = $"Barrel"
|
||||
@export var uses_hands: Array[CommandQueue.Side]
|
||||
|
||||
@export var max_ammo: int = 7
|
||||
|
@ -12,3 +12,22 @@ var ammo: int = max_ammo
|
|||
@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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue