Compare commits
2 commits
45e56e86d1
...
bb914ca82c
Author | SHA1 | Date | |
---|---|---|---|
bb914ca82c | |||
ec7b08812d |
6 changed files with 100 additions and 124 deletions
|
@ -5,23 +5,6 @@
|
||||||
[ext_resource type="Texture2D" uid="uid://bwfkjfpk4dwx0" path="res://base/assets/guns/placeholder/shoot2.png" id="10_mjqfp"]
|
[ext_resource type="Texture2D" uid="uid://bwfkjfpk4dwx0" path="res://base/assets/guns/placeholder/shoot2.png" id="10_mjqfp"]
|
||||||
[ext_resource type="Texture2D" uid="uid://bp1frp3sm8bic" path="res://base/assets/guns/placeholder/shoot3.png" id="11_0d256"]
|
[ext_resource type="Texture2D" uid="uid://bp1frp3sm8bic" path="res://base/assets/guns/placeholder/shoot3.png" id="11_0d256"]
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_ma1q3"]
|
|
||||||
resource_name = "static"
|
|
||||||
length = 0.001
|
|
||||||
step = 0.0
|
|
||||||
tracks/0/type = "value"
|
|
||||||
tracks/0/imported = false
|
|
||||||
tracks/0/enabled = true
|
|
||||||
tracks/0/path = NodePath(".:texture")
|
|
||||||
tracks/0/interp = 1
|
|
||||||
tracks/0/loop_wrap = true
|
|
||||||
tracks/0/keys = {
|
|
||||||
"times": PackedFloat32Array(0),
|
|
||||||
"transitions": PackedFloat32Array(1),
|
|
||||||
"update": 1,
|
|
||||||
"values": [ExtResource("1_yheqn")]
|
|
||||||
}
|
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_i1xqq"]
|
[sub_resource type="Animation" id="Animation_i1xqq"]
|
||||||
length = 0.001
|
length = 0.001
|
||||||
tracks/0/type = "value"
|
tracks/0/type = "value"
|
||||||
|
@ -54,6 +37,23 @@ tracks/0/keys = {
|
||||||
"values": [ExtResource("1_yheqn"), ExtResource("9_6fi3a"), ExtResource("10_mjqfp"), ExtResource("11_0d256")]
|
"values": [ExtResource("1_yheqn"), ExtResource("9_6fi3a"), ExtResource("10_mjqfp"), ExtResource("11_0d256")]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_ma1q3"]
|
||||||
|
resource_name = "static"
|
||||||
|
length = 0.001
|
||||||
|
step = 0.0
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath(".:texture")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [ExtResource("1_yheqn")]
|
||||||
|
}
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
_data = {
|
_data = {
|
||||||
&"RESET": SubResource("Animation_i1xqq"),
|
&"RESET": SubResource("Animation_i1xqq"),
|
||||||
|
|
|
@ -1,83 +1,10 @@
|
||||||
[gd_scene load_steps=11 format=3 uid="uid://dwx5tcatj35gu"]
|
[gd_scene load_steps=4 format=3 uid="uid://dwx5tcatj35gu"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://dts8lbivkgsmj" path="res://base/scripts/player/player.gd" id="1_1w3ab"]
|
[ext_resource type="Script" uid="uid://dts8lbivkgsmj" path="res://base/scripts/player/player.gd" id="1_1w3ab"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cf7avgppv4kfk" path="res://base/assets/guns/placeholder/static.png" id="1_7s1wv"]
|
[ext_resource type="PackedScene" uid="uid://bb6ovrbusyxpi" path="res://base/scenes/weapons/weapon_base.tscn" id="2_ma1q3"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cfw6p5g680c55" path="res://base/assets/guns/placeholder/shoot1.png" id="2_7ptt8"]
|
|
||||||
[ext_resource type="Texture2D" uid="uid://bwfkjfpk4dwx0" path="res://base/assets/guns/placeholder/shoot2.png" id="3_1w3ab"]
|
|
||||||
[ext_resource type="Texture2D" uid="uid://bp1frp3sm8bic" path="res://base/assets/guns/placeholder/shoot3.png" id="4_gt0rj"]
|
|
||||||
|
|
||||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_jjqxs"]
|
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_jjqxs"]
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_i1xqq"]
|
|
||||||
length = 0.001
|
|
||||||
tracks/0/type = "value"
|
|
||||||
tracks/0/imported = false
|
|
||||||
tracks/0/enabled = true
|
|
||||||
tracks/0/path = NodePath(".:texture")
|
|
||||||
tracks/0/interp = 1
|
|
||||||
tracks/0/loop_wrap = true
|
|
||||||
tracks/0/keys = {
|
|
||||||
"times": PackedFloat32Array(0),
|
|
||||||
"transitions": PackedFloat32Array(1),
|
|
||||||
"update": 1,
|
|
||||||
"values": [null]
|
|
||||||
}
|
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_8sdfx"]
|
|
||||||
resource_name = "shoot"
|
|
||||||
length = 0.30001
|
|
||||||
step = 0.1
|
|
||||||
tracks/0/type = "value"
|
|
||||||
tracks/0/imported = false
|
|
||||||
tracks/0/enabled = true
|
|
||||||
tracks/0/path = NodePath(".:texture")
|
|
||||||
tracks/0/interp = 1
|
|
||||||
tracks/0/loop_wrap = true
|
|
||||||
tracks/0/keys = {
|
|
||||||
"times": PackedFloat32Array(0, 0.1, 0.2),
|
|
||||||
"transitions": PackedFloat32Array(1, 1, 1),
|
|
||||||
"update": 1,
|
|
||||||
"values": [ExtResource("2_7ptt8"), ExtResource("3_1w3ab"), ExtResource("4_gt0rj")]
|
|
||||||
}
|
|
||||||
tracks/1/type = "method"
|
|
||||||
tracks/1/imported = false
|
|
||||||
tracks/1/enabled = true
|
|
||||||
tracks/1/path = NodePath("../..")
|
|
||||||
tracks/1/interp = 1
|
|
||||||
tracks/1/loop_wrap = true
|
|
||||||
tracks/1/keys = {
|
|
||||||
"times": PackedFloat32Array(0.3),
|
|
||||||
"transitions": PackedFloat32Array(1),
|
|
||||||
"values": [{
|
|
||||||
"args": [],
|
|
||||||
"method": &"shoot_animation_ended"
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_ma1q3"]
|
|
||||||
resource_name = "static"
|
|
||||||
length = 0.001
|
|
||||||
step = 0.0
|
|
||||||
tracks/0/type = "value"
|
|
||||||
tracks/0/imported = false
|
|
||||||
tracks/0/enabled = true
|
|
||||||
tracks/0/path = NodePath(".:texture")
|
|
||||||
tracks/0/interp = 1
|
|
||||||
tracks/0/loop_wrap = true
|
|
||||||
tracks/0/keys = {
|
|
||||||
"times": PackedFloat32Array(0),
|
|
||||||
"transitions": PackedFloat32Array(1),
|
|
||||||
"update": 1,
|
|
||||||
"values": [ExtResource("1_7s1wv")]
|
|
||||||
}
|
|
||||||
|
|
||||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_7ptt8"]
|
|
||||||
_data = {
|
|
||||||
&"RESET": SubResource("Animation_i1xqq"),
|
|
||||||
&"shoot": SubResource("Animation_8sdfx"),
|
|
||||||
&"static": SubResource("Animation_ma1q3")
|
|
||||||
}
|
|
||||||
|
|
||||||
[node name="Player" type="CharacterBody3D"]
|
[node name="Player" type="CharacterBody3D"]
|
||||||
collision_layer = 2
|
collision_layer = 2
|
||||||
collision_mask = 3
|
collision_mask = 3
|
||||||
|
@ -104,7 +31,8 @@ size_flags_vertical = 3
|
||||||
stretch_mode = 6
|
stretch_mode = 6
|
||||||
|
|
||||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="HUD/Weapon"]
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="HUD/Weapon"]
|
||||||
libraries = {
|
|
||||||
&"": SubResource("AnimationLibrary_7ptt8")
|
|
||||||
}
|
|
||||||
autoplay = "static"
|
autoplay = "static"
|
||||||
|
|
||||||
|
[node name="WeaponContainer" type="Node3D" parent="."]
|
||||||
|
|
||||||
|
[node name="Weapon" parent="WeaponContainer" instance=ExtResource("2_ma1q3")]
|
||||||
|
|
|
@ -1,13 +1,19 @@
|
||||||
[gd_scene load_steps=4 format=3 uid="uid://bb6ovrbusyxpi"]
|
[gd_scene load_steps=6 format=3 uid="uid://bb6ovrbusyxpi"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://bf0q3xe6oavqa" path="res://base/scripts/weapons/weapon_base.gd" id="1_rwatx"]
|
[ext_resource type="Script" uid="uid://bf0q3xe6oavqa" path="res://base/scripts/weapons/weapon_base.gd" id="1_rwatx"]
|
||||||
|
[ext_resource type="Script" path="res://base/scripts/weapons/fire_mode/single_fire_mode.gd" id="2_bt0tf"]
|
||||||
[ext_resource type="Script" uid="uid://bvurg687pt06s" path="res://base/scripts/weapons/barrel.gd" id="2_n0n7m"]
|
[ext_resource type="Script" uid="uid://bvurg687pt06s" path="res://base/scripts/weapons/barrel.gd" id="2_n0n7m"]
|
||||||
[ext_resource type="AnimationLibrary" uid="uid://cw8bt4hqxpk55" path="res://base/assets/guns/placeholder/placeholder.tres" id="2_p83j3"]
|
[ext_resource type="AnimationLibrary" uid="uid://cw8bt4hqxpk55" path="res://base/assets/guns/placeholder/placeholder.tres" id="2_p83j3"]
|
||||||
|
|
||||||
[node name="Weapon" type="Node3D" node_paths=PackedStringArray("barrel")]
|
[sub_resource type="Resource" id="Resource_ij06d"]
|
||||||
|
script = ExtResource("2_bt0tf")
|
||||||
|
fire_delay = 0.3
|
||||||
|
metadata/_custom_type_script = "uid://ckexgw71dd5jc"
|
||||||
|
|
||||||
|
[node name="Weapon" type="Node3D"]
|
||||||
script = ExtResource("1_rwatx")
|
script = ExtResource("1_rwatx")
|
||||||
barrel = NodePath("Barrel")
|
|
||||||
uses_hands = Array[int]([1])
|
uses_hands = Array[int]([1])
|
||||||
|
fire_mode = SubResource("Resource_ij06d")
|
||||||
animation_library = ExtResource("2_p83j3")
|
animation_library = ExtResource("2_p83j3")
|
||||||
|
|
||||||
[node name="Barrel" type="Node3D" parent="."]
|
[node name="Barrel" type="Node3D" parent="."]
|
||||||
|
|
|
@ -9,17 +9,22 @@ var queue: CommandQueue = CommandQueue.new()
|
||||||
|
|
||||||
@onready var camera: Camera3D = $"Camera"
|
@onready var camera: Camera3D = $"Camera"
|
||||||
@onready var weapon_player: AnimationPlayer = $"HUD/Weapon/AnimationPlayer"
|
@onready var weapon_player: AnimationPlayer = $"HUD/Weapon/AnimationPlayer"
|
||||||
|
@onready var weapons: Node3D = $"WeaponContainer"
|
||||||
|
|
||||||
|
var current_weapon: Weapon
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
queue.command_pushed.connect(on_queue_command_pushed)
|
queue.command_pushed.connect(on_queue_command_pushed)
|
||||||
queue.command_popped.connect(on_queue_command_popped)
|
queue.command_popped.connect(on_queue_command_popped)
|
||||||
weapon_player.play("static")
|
|
||||||
|
current_weapon = weapons.get_child(0) as Weapon
|
||||||
|
|
||||||
|
weapon_player.add_animation_library("current", current_weapon.animation_library)
|
||||||
|
weapon_player.play("current/static")
|
||||||
|
|
||||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||||
|
|
||||||
|
|
||||||
func _process(_delta: float) -> void:
|
func _process(_delta: float) -> void:
|
||||||
# TODO: use proper weapon system, this is just for testing command queue
|
|
||||||
if Input.is_action_pressed("shoot") \
|
if Input.is_action_pressed("shoot") \
|
||||||
and queue.current_command(CommandQueue.Side.RIGHT) \
|
and queue.current_command(CommandQueue.Side.RIGHT) \
|
||||||
== CommandQueue.DEFAULT_COMMAND:
|
== CommandQueue.DEFAULT_COMMAND:
|
||||||
|
@ -30,8 +35,15 @@ func _process(_delta: float) -> void:
|
||||||
CommandQueue.Side.LEFT,
|
CommandQueue.Side.LEFT,
|
||||||
CommandQueue.Side.RIGHT
|
CommandQueue.Side.RIGHT
|
||||||
])
|
])
|
||||||
|
|
||||||
|
for side in CommandQueue.Side.values():
|
||||||
|
var command = queue.current_command(side)
|
||||||
|
match side:
|
||||||
|
CommandQueue.Side.LEFT:
|
||||||
|
handle_current_left_command(command)
|
||||||
|
CommandQueue.Side.RIGHT:
|
||||||
|
handle_current_right_command(command)
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
var direction = Vector3.ZERO
|
var direction = Vector3.ZERO
|
||||||
direction.z = Input.get_axis("move_forward", "move_backward")
|
direction.z = Input.get_axis("move_forward", "move_backward")
|
||||||
|
@ -62,22 +74,6 @@ func on_queue_command_pushed(sides, commands):
|
||||||
CommandQueue.Side.RIGHT:
|
CommandQueue.Side.RIGHT:
|
||||||
handle_new_right_command(commands[i])
|
handle_new_right_command(commands[i])
|
||||||
|
|
||||||
func handle_new_left_command(command: CommandQueue.Command):
|
|
||||||
match command:
|
|
||||||
CommandQueue.Command.NONE:
|
|
||||||
pass
|
|
||||||
_:
|
|
||||||
print('New command %s is not implemented for left hand.' % str(command))
|
|
||||||
|
|
||||||
func handle_new_right_command(command: CommandQueue.Command):
|
|
||||||
match command:
|
|
||||||
CommandQueue.Command.NONE:
|
|
||||||
pass
|
|
||||||
CommandQueue.Command.SHOOT:
|
|
||||||
weapon_player.play('shoot')
|
|
||||||
_:
|
|
||||||
print('New command %s is not implemented for right hand.' % str(command))
|
|
||||||
|
|
||||||
func shoot_animation_ended():
|
func shoot_animation_ended():
|
||||||
queue.pop()
|
queue.pop()
|
||||||
|
|
||||||
|
@ -89,18 +85,46 @@ func on_queue_command_popped(commands):
|
||||||
CommandQueue.Side.RIGHT:
|
CommandQueue.Side.RIGHT:
|
||||||
handle_ended_right_command(commands[i])
|
handle_ended_right_command(commands[i])
|
||||||
|
|
||||||
|
func handle_new_left_command(command: CommandQueue.Command):
|
||||||
|
match command:
|
||||||
|
CommandQueue.Command.NONE:
|
||||||
|
pass
|
||||||
|
_:
|
||||||
|
print('New command %s is not implemented for left hand.' % command)
|
||||||
|
|
||||||
|
func handle_new_right_command(command: CommandQueue.Command):
|
||||||
|
match command:
|
||||||
|
CommandQueue.Command.NONE | CommandQueue.Command.SHOOT:
|
||||||
|
pass
|
||||||
|
_:
|
||||||
|
print('New command %s is not implemented for right hand.' % command)
|
||||||
|
|
||||||
func handle_ended_left_command(command: CommandQueue.Command):
|
func handle_ended_left_command(command: CommandQueue.Command):
|
||||||
match command:
|
match command:
|
||||||
CommandQueue.Command.NONE:
|
CommandQueue.Command.NONE:
|
||||||
pass
|
pass
|
||||||
_:
|
_:
|
||||||
print('Ended command %s is not implemented for left hand.' % str(command))
|
print('Ended command %s is not implemented for left hand.' % command)
|
||||||
|
|
||||||
func handle_ended_right_command(command: CommandQueue.Command):
|
func handle_ended_right_command(command: CommandQueue.Command):
|
||||||
match command:
|
match command:
|
||||||
CommandQueue.Command.NONE:
|
CommandQueue.Command.NONE:
|
||||||
pass
|
pass
|
||||||
CommandQueue.Command.SHOOT:
|
CommandQueue.Command.SHOOT:
|
||||||
weapon_player.play('static')
|
weapon_player.play('current/static')
|
||||||
_:
|
_:
|
||||||
print('Ended command %s is not implemented for right hand.' % str(command))
|
print('Ended command %s is not implemented for right hand.' % command)
|
||||||
|
|
||||||
|
func handle_current_left_command(command: CommandQueue.Command):
|
||||||
|
match command:
|
||||||
|
CommandQueue.Command.NONE:
|
||||||
|
pass
|
||||||
|
_:
|
||||||
|
print('Current command %s is not implemented for left hand.' % command)
|
||||||
|
|
||||||
|
func handle_current_right_command(command: CommandQueue.Command):
|
||||||
|
match command:
|
||||||
|
CommandQueue.Command.NONE:
|
||||||
|
pass
|
||||||
|
_:
|
||||||
|
print('Current command %s is not implemented for right hand.' % command)
|
||||||
|
|
|
@ -18,7 +18,6 @@ func _on_fire_begin(_tree : SceneTree) -> void:
|
||||||
cooldown = false
|
cooldown = false
|
||||||
check_unfinished_timer(cooldown_timer,on_cooldown_timeout)
|
check_unfinished_timer(cooldown_timer,on_cooldown_timeout)
|
||||||
|
|
||||||
|
|
||||||
func _process(tree : SceneTree) -> void:
|
func _process(tree : SceneTree) -> void:
|
||||||
if can_fire() :
|
if can_fire() :
|
||||||
return
|
return
|
||||||
|
|
|
@ -2,7 +2,7 @@ extends Node3D
|
||||||
|
|
||||||
class_name Weapon
|
class_name Weapon
|
||||||
|
|
||||||
@export var barrel: Barrel
|
@onready var barrel = $"Barrel"
|
||||||
@export var uses_hands: Array[CommandQueue.Side]
|
@export var uses_hands: Array[CommandQueue.Side]
|
||||||
|
|
||||||
@export var max_ammo: int = 7
|
@export var max_ammo: int = 7
|
||||||
|
@ -12,3 +12,22 @@ var ammo: int = max_ammo
|
||||||
@export var fire_mode: BaseFireMode
|
@export var fire_mode: BaseFireMode
|
||||||
## Weapon animation library. Should contain "static", "fire", "reload" animations
|
## Weapon animation library. Should contain "static", "fire", "reload" animations
|
||||||
@export var animation_library: AnimationLibrary
|
@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