Audio system
This commit is contained in:
parent
b0ba8adcd7
commit
de2736c701
38 changed files with 2538 additions and 78 deletions
19
scripts/audio_system/multiplayer_audio_3d.gd
Normal file
19
scripts/audio_system/multiplayer_audio_3d.gd
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
extends AudioStreamPlayer3D
|
||||
|
||||
class_name MultiplayerAudio3D
|
||||
|
||||
func multiplayer_play():
|
||||
play()
|
||||
internal_play.rpc()
|
||||
|
||||
func multiplayer_stop():
|
||||
stop()
|
||||
internal_stop.rpc()
|
||||
|
||||
@rpc
|
||||
func internal_play():
|
||||
play()
|
||||
|
||||
@rpc
|
||||
func internal_stop():
|
||||
play()
|
||||
1
scripts/audio_system/multiplayer_audio_3d.gd.uid
Normal file
1
scripts/audio_system/multiplayer_audio_3d.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://da0xv360va3b3
|
||||
4
scripts/client_settings.gd
Normal file
4
scripts/client_settings.gd
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
extends Node
|
||||
|
||||
|
||||
var SENSITIVITY: float
|
||||
1
scripts/client_settings.gd.uid
Normal file
1
scripts/client_settings.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://d3trljsb8awmr
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
extends Camera3D
|
||||
|
||||
@export var SENSITIVITY = 0.02
|
||||
@export var SPEED = 10.0
|
||||
|
||||
var active: bool
|
||||
|
|
@ -34,4 +33,4 @@ func _input(event: InputEvent) -> void:
|
|||
if active == false or not is_multiplayer_authority():
|
||||
return
|
||||
if event is InputEventMouseMotion:
|
||||
rotate_camera(-event.relative.x * SENSITIVITY,-event.relative.y * SENSITIVITY)
|
||||
rotate_camera(-event.relative.x * ClientSettings.SENSITIVITY,-event.relative.y * ClientSettings.SENSITIVITY)
|
||||
|
|
|
|||
|
|
@ -2,9 +2,6 @@ extends Camera3D
|
|||
|
||||
class_name PlayerCamera
|
||||
|
||||
@export var SENSITIVITY = 0.005
|
||||
|
||||
|
||||
var vertical_compensation : float
|
||||
var compensation_tween: Tween
|
||||
var compensate: bool = false
|
||||
|
|
@ -33,7 +30,7 @@ func _input(event: InputEvent) -> void:
|
|||
if not is_multiplayer_authority() or disabled:
|
||||
return
|
||||
if event is InputEventMouseMotion:
|
||||
rotate_camera(-event.relative.x * SENSITIVITY,-event.relative.y * SENSITIVITY)
|
||||
rotate_camera(-event.relative.x * ClientSettings.SENSITIVITY,-event.relative.y * ClientSettings.SENSITIVITY)
|
||||
|
||||
func rotate_camera(x,y) -> void:
|
||||
get_parent().rotate_y(x)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@ class_name PlayerMovement
|
|||
@export var player: Player
|
||||
var disabled: bool
|
||||
|
||||
func disable() -> void:
|
||||
disabled = true
|
||||
|
||||
func process_movement(max_speed: float,acceleration: float,deceleration: float,delta: float) -> void:
|
||||
if is_multiplayer_authority() == false:
|
||||
return
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
extends Camera3D
|
||||
|
||||
@export var SENSITIVITY = 0.02
|
||||
@export var SPEED = 10.0
|
||||
|
||||
func _enter_tree() -> void:
|
||||
|
|
@ -31,7 +30,7 @@ func _input(event: InputEvent) -> void:
|
|||
if not is_multiplayer_authority():
|
||||
return
|
||||
if event is InputEventMouseMotion:
|
||||
rotate_camera(-event.relative.x * SENSITIVITY,-event.relative.y * SENSITIVITY)
|
||||
rotate_camera(-event.relative.x * ClientSettings.SENSITIVITY,-event.relative.y * ClientSettings.SENSITIVITY)
|
||||
|
||||
@rpc("any_peer","call_local","reliable")
|
||||
func set_after_spawn(start_position: Vector3, _team: int):
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ extends State
|
|||
@export var max_speed: float = 5.0
|
||||
@export var acceleration: float
|
||||
@export var weapon_system: WeaponSystem
|
||||
@export var land_sound: MultiplayerAudio3D
|
||||
|
||||
func enter() -> void:
|
||||
pass
|
||||
|
|
@ -18,6 +19,7 @@ func physics_update(delta: float) -> void:
|
|||
return
|
||||
if player.is_on_floor():
|
||||
transition.emit("Stand")
|
||||
land_sound.multiplayer_play()
|
||||
|
||||
player.velocity += player.get_gravity() * delta
|
||||
|
||||
|
|
|
|||
|
|
@ -7,12 +7,17 @@ extends State
|
|||
@export var player: Player
|
||||
@export var player_movement: PlayerMovement
|
||||
@export var weapon_system: WeaponSystem
|
||||
@export var audio: MultiplayerAudio3D
|
||||
@export var step_delay: float
|
||||
@export var step_speed_curve: Curve
|
||||
|
||||
var step_time: float
|
||||
|
||||
func enter() -> void:
|
||||
pass
|
||||
|
||||
func exit() -> void:
|
||||
pass
|
||||
step_time = 0
|
||||
|
||||
func physics_update(delta: float) -> void:
|
||||
if not is_multiplayer_authority():
|
||||
|
|
@ -26,6 +31,11 @@ func physics_update(delta: float) -> void:
|
|||
transition.emit("Fall")
|
||||
return
|
||||
|
||||
step_time += delta * step_speed_curve.sample((player.velocity * Vector3(1,0,1)).length_squared()/(max_speed*max_speed))
|
||||
if step_time >= step_delay:
|
||||
step_time = 0
|
||||
audio.multiplayer_play()
|
||||
|
||||
player_movement.process_movement(max_speed * weapon_system.get_speed_modifier(),acceleration,deceleration,delta)
|
||||
|
||||
func state_input(event: InputEvent) -> void:
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@ extends Interactible
|
|||
|
||||
var plant: StringName
|
||||
@onready var defuse_timer: Timer = $DefuseTimer
|
||||
@export var bomb_audio: MultiplayerAudio3D
|
||||
@export var tick_curve : Curve
|
||||
var tick_time: float
|
||||
var tick_stop: bool
|
||||
|
||||
func _ready() -> void:
|
||||
super()
|
||||
|
|
@ -9,20 +13,33 @@ func _ready() -> void:
|
|||
Session.bomb_timer.timeout.connect(on_timeout)
|
||||
Session.begin_bomb_stage()
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if tick_stop:
|
||||
return
|
||||
if multiplayer.is_server():
|
||||
tick_time += delta
|
||||
if tick_time >= tick_curve.sample(1-Session.bomb_timer.time_left/Session.bomb_timer.wait_time):
|
||||
bomb_audio.multiplayer_play()
|
||||
|
||||
tick_time = 0
|
||||
|
||||
func on_timeout():
|
||||
if multiplayer.is_server() == false:
|
||||
return
|
||||
|
||||
tick_stop = true
|
||||
$BoomAudio.play()
|
||||
Session.kill_site(plant)
|
||||
|
||||
func on_defuse_timeout():
|
||||
Session.defuse_win()
|
||||
tick_stop = true
|
||||
|
||||
func interaction_start(player_id: int):
|
||||
if Session.player_nodes[player_id].team != Session.TEAMS.DEFENCE:
|
||||
if tick_stop or Session.player_nodes[player_id].team != Session.TEAMS.DEFENCE:
|
||||
return
|
||||
super(player_id)
|
||||
defuse_timer.start()
|
||||
$DefuseAudio.multiplayer_play()
|
||||
Session.player_nodes[player_id].passive.rpc_id(player_id)
|
||||
|
||||
func interaction_end():
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ func enter():
|
|||
machine.animation_player.play(machine.animation_prefix+"plant")
|
||||
machine.animation_player.animation_finished.connect(on_animation_finished)
|
||||
machine.speed_modifier = 0.0
|
||||
machine.player.get_node("PlantAudio").multiplayer_play()
|
||||
|
||||
func exit():
|
||||
machine.animation_player.animation_finished.disconnect(on_animation_finished)
|
||||
|
|
@ -26,3 +27,4 @@ func state_input(event: InputEvent) -> void:
|
|||
return
|
||||
if event.is_action_released("plr_bomb"):
|
||||
transition.emit("Idle")
|
||||
machine.player.get_node("PlantAudio").multiplayer_stop()
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ 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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue