Merge branch 'master' of ssh://2ndbeam.ru/2ndbeam/red_dragon_pon
This commit is contained in:
commit
81d5c5f0ba
18 changed files with 503 additions and 10 deletions
|
@ -6,10 +6,10 @@ class_name CommandQueue
|
|||
## Commands that can be pushed to queue
|
||||
enum Command {
|
||||
NONE,
|
||||
TAKE_WEAPON,
|
||||
FIRE,
|
||||
STOP_FIRING,
|
||||
RELOAD,
|
||||
DRAW_WEAPON,
|
||||
HOLSTER_WEAPON,
|
||||
TAKE_ZAZA,
|
||||
LIGHT_ZAZA,
|
||||
|
|
|
@ -6,19 +6,23 @@ extends CharacterBody3D
|
|||
@export var horizontal_sensivity = 0.005
|
||||
|
||||
var queue: CommandQueue = CommandQueue.new()
|
||||
var queue_data: Dictionary = {}
|
||||
|
||||
@onready var camera: Camera3D = $"Camera"
|
||||
@onready var weapon_player: AnimationPlayer = $"HUD/Weapon/AnimationPlayer"
|
||||
@onready var movement_player: AnimationPlayer = $"MovementPlayer"
|
||||
@onready var weapons: WeaponContainer = $"WeaponContainer"
|
||||
|
||||
# Placeholder UI
|
||||
@onready var ammo_label: Label = $"HUD/Ammo"
|
||||
|
||||
var current_weapon:Weapon
|
||||
var current_weapon: Weapon
|
||||
|
||||
var slot_actions: Array[StringName] = [ "slot_primary", "slot_secondary", "slot_tertiary" ]
|
||||
|
||||
func _ready() -> void:
|
||||
movement_player.play('static')
|
||||
|
||||
queue.command_pushed.connect(on_queue_command_pushed)
|
||||
queue.command_popped.connect(on_queue_command_popped)
|
||||
queue.command_started.connect(on_queue_command_started)
|
||||
|
@ -54,8 +58,10 @@ func _process(_delta: float) -> void:
|
|||
if Input.is_action_just_pressed(slot_actions[slot]):
|
||||
slot_action = true
|
||||
slot_id = slot
|
||||
if slot_action:
|
||||
weapons.select_slot(slot_id)
|
||||
if slot_action and weapons.slots[slot_id].has_weapon \
|
||||
and weapons.current_slot != weapons.slots[slot_id]:
|
||||
queue_data['slot_id'] = slot_id
|
||||
push_copied_command(CommandQueue.Command.HOLSTER_WEAPON, weapon_sides)
|
||||
|
||||
# Stop firing logic
|
||||
if not current_weapon.fire_mode is SingleFireMode:
|
||||
|
@ -82,6 +88,12 @@ func _physics_process(delta: float) -> void:
|
|||
target_velocity.y -= fall_acceleration * delta
|
||||
|
||||
velocity = target_velocity
|
||||
|
||||
if velocity == Vector3.ZERO and movement_player.current_animation == 'default':
|
||||
movement_player.play('static')
|
||||
elif movement_player.current_animation == 'static':
|
||||
movement_player.play('default')
|
||||
|
||||
move_and_slide()
|
||||
|
||||
func _input(event):
|
||||
|
@ -109,7 +121,8 @@ func on_weapon_slot_selected():
|
|||
current_weapon.fire_allowed.connect(finish_task)
|
||||
|
||||
weapon_player.add_animation_library("current", current_weapon.animation_library)
|
||||
weapon_player.play("current/static")
|
||||
|
||||
push_copied_command(CommandQueue.Command.DRAW_WEAPON, current_weapon.uses_hands)
|
||||
|
||||
update_ammo_label()
|
||||
|
||||
|
@ -192,6 +205,10 @@ func handle_ended_right_command(command: CommandQueue.Command):
|
|||
weapon_player.play('current/static')
|
||||
current_weapon.reload()
|
||||
update_ammo_label()
|
||||
CommandQueue.Command.HOLSTER_WEAPON:
|
||||
weapons.select_slot(queue_data['slot_id'])
|
||||
CommandQueue.Command.DRAW_WEAPON:
|
||||
weapon_player.play('current/static')
|
||||
|
||||
func handle_started_left_command(command: CommandQueue.Command):
|
||||
match command:
|
||||
|
@ -203,6 +220,10 @@ func handle_started_right_command(command: CommandQueue.Command):
|
|||
current_weapon.request_fire()
|
||||
CommandQueue.Command.STOP_FIRING:
|
||||
queue.pop()
|
||||
CommandQueue.Command.DRAW_WEAPON:
|
||||
weapon_player.play('current/draw')
|
||||
CommandQueue.Command.HOLSTER_WEAPON:
|
||||
weapon_player.play('current/holster')
|
||||
|
||||
func handle_current_left_command(command: CommandQueue.Command):
|
||||
match command:
|
||||
|
|
|
@ -15,7 +15,7 @@ var ammo: int
|
|||
|
||||
@export var fire_mode: BaseFireMode
|
||||
|
||||
## Weapon animation library. Should contain "static", "fire", "reload" animations
|
||||
## Weapon animation library. Should contain "static", "fire", "reload", "holster", "draw" animations
|
||||
@export var animation_library: AnimationLibrary
|
||||
|
||||
var is_firing: bool = false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue