Global refactor
This commit is contained in:
parent
3868af29e3
commit
0589ca4e23
180 changed files with 249 additions and 401 deletions
23
weapons/gun/idle_state.gd
Normal file
23
weapons/gun/idle_state.gd
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
extends WeaponState
|
||||
|
||||
@export var emptyable: bool
|
||||
|
||||
func enter() -> void:
|
||||
machine.animation_player.play(with_morphems("idle"))
|
||||
machine.player.get_node("PlayerInput").reload.connect(init_reload)
|
||||
|
||||
func exit() -> void:
|
||||
machine.player.get_node("PlayerInput").reload.disconnect(init_reload)
|
||||
|
||||
func use_begin() -> void:
|
||||
if machine.ammo > 0:
|
||||
transition.emit("Shoot")
|
||||
|
||||
@rpc("authority","call_local","reliable")
|
||||
func init_reload():
|
||||
if machine.ammo == machine.max_ammo or machine.remaining_ammo <= 0:
|
||||
return
|
||||
transition.emit("Reload")
|
||||
|
||||
func with_morphems(animation):
|
||||
return machine.animation_prefix + ((animation+"_empty") if emptyable and machine.ammo == 0 else animation)
|
||||
1
weapons/gun/idle_state.gd.uid
Normal file
1
weapons/gun/idle_state.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://ofv4e3dsfe8
|
||||
17
weapons/gun/intro_state.gd
Normal file
17
weapons/gun/intro_state.gd
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
extends WeaponState
|
||||
|
||||
@export var emptyable: bool
|
||||
|
||||
func enter() -> void:
|
||||
machine.animation_player.play(with_morphems("intro"))
|
||||
machine.animation_player.animation_finished.connect(on_animation_finished)
|
||||
|
||||
func exit() -> void:
|
||||
machine.animation_player.animation_finished.disconnect(on_animation_finished)
|
||||
|
||||
func on_animation_finished(animation):
|
||||
if animation == with_morphems("intro"):
|
||||
transition.emit("Idle")
|
||||
|
||||
func with_morphems(animation):
|
||||
return machine.animation_prefix + ((animation+"_empty") if emptyable and machine.ammo == 0 else animation)
|
||||
1
weapons/gun/intro_state.gd.uid
Normal file
1
weapons/gun/intro_state.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bmj0bwy2tlian
|
||||
23
weapons/gun/reload_state.gd
Normal file
23
weapons/gun/reload_state.gd
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
extends WeaponState
|
||||
|
||||
@export var emptyable: bool
|
||||
|
||||
func enter() -> void:
|
||||
machine.animation_player.play(with_morphems("reload"))
|
||||
machine.animation_player.animation_finished.connect(on_animation_finished)
|
||||
|
||||
func exit() -> void:
|
||||
machine.animation_player.animation_finished.disconnect(on_animation_finished)
|
||||
|
||||
func on_animation_finished(animation):
|
||||
if animation == with_morphems("reload"):
|
||||
if machine.remaining_ammo > machine.max_ammo:
|
||||
machine.ammo = machine.max_ammo
|
||||
machine.remaining_ammo -= machine.max_ammo
|
||||
else:
|
||||
machine.ammo = machine.remaining_ammo
|
||||
machine.remaining_ammo = 0
|
||||
transition.emit("Idle")
|
||||
|
||||
func with_morphems(animation):
|
||||
return machine.animation_prefix + ((animation+"_empty") if emptyable and machine.ammo == 0 else animation)
|
||||
1
weapons/gun/reload_state.gd.uid
Normal file
1
weapons/gun/reload_state.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://hmekwp8444ao
|
||||
48
weapons/gun/semi_auto_shoot_state.gd
Normal file
48
weapons/gun/semi_auto_shoot_state.gd
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
extends WeaponState
|
||||
|
||||
@export var vertical_curve: Curve
|
||||
@export var horizontal_curve: Curve
|
||||
|
||||
@export var emptyable: bool
|
||||
@export var damage: int
|
||||
@export var shoot_distance: float = 100
|
||||
|
||||
@export var fire_timer: Timer
|
||||
|
||||
var bullets_shot: int = 0
|
||||
|
||||
func enter() -> void:
|
||||
fire()
|
||||
machine.animation_player.animation_finished.connect(on_animation_finished)
|
||||
|
||||
func exit() -> void:
|
||||
bullets_shot = 0
|
||||
machine.animation_player.animation_finished.disconnect(on_animation_finished)
|
||||
|
||||
func on_animation_finished(animation):
|
||||
if animation == with_morphems("shoot"):
|
||||
transition.emit("Idle")
|
||||
|
||||
func use_begin() -> void:
|
||||
if fire_timer.time_left > 0:
|
||||
return
|
||||
fire()
|
||||
|
||||
func fire() -> void:
|
||||
if machine.ammo == 0 or fire_timer.time_left > 0:
|
||||
return
|
||||
machine.ammo -= 1
|
||||
bullets_shot += 1
|
||||
|
||||
machine.animation_player.stop()
|
||||
machine.animation_player.play(with_morphems("shoot"))
|
||||
|
||||
if is_multiplayer_authority():
|
||||
Session.shoot(int(machine.player.name),damage,shoot_distance)
|
||||
machine.player.get_node("ShootAudio").multiplayer_play()
|
||||
|
||||
fire_timer.start()
|
||||
machine.player_camera.recoil(horizontal_curve.sample(bullets_shot),vertical_curve.sample(bullets_shot))
|
||||
|
||||
func with_morphems(animation):
|
||||
return machine.animation_prefix + ((animation+"_empty") if emptyable and machine.ammo == 0 else animation)
|
||||
1
weapons/gun/semi_auto_shoot_state.gd.uid
Normal file
1
weapons/gun/semi_auto_shoot_state.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://vj13r83l3xyq
|
||||
35
weapons/gun/sp/droppable_sp.tscn
Normal file
35
weapons/gun/sp/droppable_sp.tscn
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://dgfqppi21c2u0"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cskgqgkr7pmb0" path="res://systems/weapon_system/dropped_weapon.gd" id="1_jym52"]
|
||||
[ext_resource type="PackedScene" uid="uid://djwjl8xll53vn" path="res://weapons/gun/sp/starting_pistol.tscn" id="2_jym52"]
|
||||
[ext_resource type="PackedScene" uid="uid://d3sjs6efbshpk" path="res://models/weapons/starting_pistol.glb" id="3_jym52"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_hsebh"]
|
||||
size = Vector3(0.24707031, 0.3173828, 0.46972656)
|
||||
|
||||
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_ddvbd"]
|
||||
properties/0/path = NodePath(".:position")
|
||||
properties/0/spawn = true
|
||||
properties/0/replication_mode = 1
|
||||
properties/1/path = NodePath(".:rotation")
|
||||
properties/1/spawn = true
|
||||
properties/1/replication_mode = 1
|
||||
|
||||
[node name="DroppableStartingPistol" type="RigidBody3D" node_paths=PackedStringArray("weapon")]
|
||||
collision_layer = 8
|
||||
collision_mask = 9
|
||||
script = ExtResource("1_jym52")
|
||||
slot = &"secondary"
|
||||
weapon = NodePath("StartingPistol")
|
||||
team = 3
|
||||
|
||||
[node name="StartingPistol" parent="." instance=ExtResource("2_jym52")]
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -3.0517578e-05, 0.0010986328)
|
||||
shape = SubResource("BoxShape3D_hsebh")
|
||||
|
||||
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
|
||||
replication_config = SubResource("SceneReplicationConfig_ddvbd")
|
||||
|
||||
[node name="starting_pistol" parent="." instance=ExtResource("3_jym52")]
|
||||
54
weapons/gun/sp/starting_pistol.tscn
Normal file
54
weapons/gun/sp/starting_pistol.tscn
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
[gd_scene load_steps=8 format=3 uid="uid://djwjl8xll53vn"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://e6lqknfl4ngt" path="res://systems/weapon_system/weapon_substate_machine.gd" id="1_g7s1i"]
|
||||
[ext_resource type="Script" uid="uid://ofv4e3dsfe8" path="res://weapons/gun/idle_state.gd" id="2_cmn6f"]
|
||||
[ext_resource type="Script" uid="uid://vj13r83l3xyq" path="res://weapons/gun/semi_auto_shoot_state.gd" id="3_016ti"]
|
||||
[ext_resource type="Script" uid="uid://hmekwp8444ao" path="res://weapons/gun/reload_state.gd" id="4_hoqxt"]
|
||||
[ext_resource type="Script" uid="uid://bmj0bwy2tlian" path="res://weapons/gun/intro_state.gd" id="5_ud1dr"]
|
||||
|
||||
[sub_resource type="Curve" id="Curve_cmn6f"]
|
||||
_limits = [0.0, 0.1, 0.0, 20.0]
|
||||
_data = [Vector2(0, 0.1), 0.0, 0.0, 0, 0, Vector2(20, 0.1), -2.2834061e-05, 0.0, 0, 0]
|
||||
point_count = 2
|
||||
metadata/_snap_enabled = true
|
||||
metadata/_snap_count = 8
|
||||
|
||||
[sub_resource type="Curve" id="Curve_016ti"]
|
||||
_limits = [-0.02, 0.02, 0.0, 20.0]
|
||||
_data = [Vector2(0, -9.313226e-10), 0.0, 0.0, 0, 0, Vector2(4.959569, 0.0044327714), 0.0, 0.0, 0, 0, Vector2(9.919138, -0.0075840354), 0.0, 0.0, 0, 0, Vector2(15.09434, 0.011533612), 0.0, 0.0, 0, 0, Vector2(20, -0.014684878), 0.0, 0.0, 0, 0]
|
||||
point_count = 5
|
||||
|
||||
[node name="StartingPistol" type="Node" node_paths=PackedStringArray("enter_state")]
|
||||
script = ExtResource("1_g7s1i")
|
||||
animation_prefix = &"baked_sp_"
|
||||
registry_entry = &"sp"
|
||||
visibility_target = &"sp"
|
||||
max_ammo = 20
|
||||
speed_modifier = 0.9
|
||||
slot = &"secondary"
|
||||
enter_state = NodePath("Intro")
|
||||
metadata/_custom_type_script = "uid://e6lqknfl4ngt"
|
||||
|
||||
[node name="Idle" type="Node" parent="."]
|
||||
script = ExtResource("2_cmn6f")
|
||||
emptyable = true
|
||||
|
||||
[node name="Shoot" type="Node" parent="." node_paths=PackedStringArray("fire_timer")]
|
||||
script = ExtResource("3_016ti")
|
||||
vertical_curve = SubResource("Curve_cmn6f")
|
||||
horizontal_curve = SubResource("Curve_016ti")
|
||||
emptyable = true
|
||||
damage = 22
|
||||
fire_timer = NodePath("../FireTimer")
|
||||
|
||||
[node name="Reload" type="Node" parent="."]
|
||||
script = ExtResource("4_hoqxt")
|
||||
emptyable = true
|
||||
|
||||
[node name="Intro" type="Node" parent="."]
|
||||
script = ExtResource("5_ud1dr")
|
||||
emptyable = true
|
||||
|
||||
[node name="FireTimer" type="Timer" parent="."]
|
||||
wait_time = 0.15
|
||||
one_shot = true
|
||||
Loading…
Add table
Add a link
Reference in a new issue