Deploy and shooting brought back
This commit is contained in:
parent
c1548e5451
commit
b94e4cdf30
10 changed files with 25 additions and 15 deletions
|
|
@ -4,15 +4,10 @@ extends WeaponState
|
|||
|
||||
func enter() -> void:
|
||||
machine.animation_player.play(with_morphems("idle"))
|
||||
machine.player.get_node("PlayerInput").reload.connect(init_reload)
|
||||
|
||||
func exit() -> void:
|
||||
pass
|
||||
|
||||
func state_input(event: InputEvent) -> void:
|
||||
if not machine.is_multiplayer_authority() or Input.mouse_mode != Input.MouseMode.MOUSE_MODE_CAPTURED: return
|
||||
|
||||
if event.is_action_pressed("plr_reload"):
|
||||
init_reload.rpc()
|
||||
machine.player.get_node("PlayerInput").reload.disconnect(init_reload)
|
||||
|
||||
func use_begin() -> void:
|
||||
if machine.ammo > 0:
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ func use_begin() -> void:
|
|||
func fire() -> void:
|
||||
if machine.ammo == 0 or fire_timer.time_left > 0:
|
||||
return
|
||||
machine.player.get_node("ShootAudio").multiplayer_play()
|
||||
machine.ammo -= 1
|
||||
bullets_shot += 1
|
||||
|
||||
|
|
@ -40,6 +39,7 @@ func fire() -> void:
|
|||
|
||||
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))
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ func exit() -> void:
|
|||
@rpc("authority","call_local","reliable")
|
||||
func use_begin() -> void:
|
||||
current_state.use_begin()
|
||||
|
||||
@rpc("authority","call_local","reliable")
|
||||
func use_end() -> void:
|
||||
current_state.use_end()
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ class_name WeaponSystem
|
|||
@export var animation_player: AnimationPlayer
|
||||
@export var camera: PlayerCamera
|
||||
@export var player: Player
|
||||
@export var player_input: PlayerInput
|
||||
|
||||
var current_state: WeaponSubStateMachine
|
||||
var last_slot: StringName
|
||||
|
|
@ -27,6 +28,9 @@ signal ammo_updated(ammo: int, remaining_ammo: int)
|
|||
|
||||
func _ready() -> void:
|
||||
$WeaponSpawner.spawn_function = pick_up_weapon
|
||||
player_input.drop.connect(drop_current)
|
||||
player_input.fire_begin.connect(use_begin)
|
||||
player_input.fire_end.connect(use_end)
|
||||
|
||||
func get_speed_modifier() -> float:
|
||||
if current_state == null:
|
||||
|
|
@ -89,6 +93,8 @@ func drop_current():
|
|||
drop(current_state)
|
||||
|
||||
func drop(weapon: WeaponSubStateMachine) -> void:
|
||||
if not is_multiplayer_authority():
|
||||
return
|
||||
if slots.find_key(weapon) == "knife":
|
||||
return
|
||||
var drop_data: Dictionary = {}
|
||||
|
|
@ -161,3 +167,9 @@ func _physics_process(delta: float) -> void:
|
|||
if current_state == null or disabled:
|
||||
return
|
||||
current_state.physics_update(delta)
|
||||
|
||||
func use_begin() -> void:
|
||||
current_state.use_begin.rpc()
|
||||
|
||||
func use_end() -> void:
|
||||
current_state.use_end.rpc()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue