(maybe) broken resource loader for the sounds
added a dloading screen, currently only used to load sounds in automatically (you can cahnge the sounds in the assets and it will work automatically since this autoload will load it in on game start ready)
This commit is contained in:
parent
6231073ad6
commit
3367698d10
26 changed files with 356 additions and 252 deletions
Binary file not shown.
|
|
@ -1,24 +0,0 @@
|
||||||
[remap]
|
|
||||||
|
|
||||||
importer="wav"
|
|
||||||
type="AudioStreamWAV"
|
|
||||||
uid="uid://cavikqmjpj7q7"
|
|
||||||
path="res://.godot/imported/slow-flashlight-click-004.wav-f5b2cc6fde25baf986c638e50999f286.sample"
|
|
||||||
|
|
||||||
[deps]
|
|
||||||
|
|
||||||
source_file="res://assets/sounds/flashlight/slow-flashlight-click-004.wav"
|
|
||||||
dest_files=["res://.godot/imported/slow-flashlight-click-004.wav-f5b2cc6fde25baf986c638e50999f286.sample"]
|
|
||||||
|
|
||||||
[params]
|
|
||||||
|
|
||||||
force/8_bit=false
|
|
||||||
force/mono=false
|
|
||||||
force/max_rate=false
|
|
||||||
force/max_rate_hz=44100
|
|
||||||
edit/trim=false
|
|
||||||
edit/normalize=false
|
|
||||||
edit/loop_mode=0
|
|
||||||
edit/loop_begin=0
|
|
||||||
edit/loop_end=-1
|
|
||||||
compress/mode=2
|
|
||||||
Binary file not shown.
|
|
@ -1,24 +0,0 @@
|
||||||
[remap]
|
|
||||||
|
|
||||||
importer="wav"
|
|
||||||
type="AudioStreamWAV"
|
|
||||||
uid="uid://dkohmdwjt02e1"
|
|
||||||
path="res://.godot/imported/slow-flashlight-click-007.wav-02b94a537c0abddc73c0484b27e2bd1c.sample"
|
|
||||||
|
|
||||||
[deps]
|
|
||||||
|
|
||||||
source_file="res://assets/sounds/flashlight/slow-flashlight-click-007.wav"
|
|
||||||
dest_files=["res://.godot/imported/slow-flashlight-click-007.wav-02b94a537c0abddc73c0484b27e2bd1c.sample"]
|
|
||||||
|
|
||||||
[params]
|
|
||||||
|
|
||||||
force/8_bit=false
|
|
||||||
force/mono=false
|
|
||||||
force/max_rate=false
|
|
||||||
force/max_rate_hz=44100
|
|
||||||
edit/trim=false
|
|
||||||
edit/normalize=false
|
|
||||||
edit/loop_mode=0
|
|
||||||
edit/loop_begin=0
|
|
||||||
edit/loop_end=-1
|
|
||||||
compress/mode=2
|
|
||||||
Binary file not shown.
|
|
@ -1,24 +0,0 @@
|
||||||
[remap]
|
|
||||||
|
|
||||||
importer="wav"
|
|
||||||
type="AudioStreamWAV"
|
|
||||||
uid="uid://cce08jas6m53y"
|
|
||||||
path="res://.godot/imported/slow-flashlight-click-008.wav-05434edc3f95e0ae2600f2292b76eae0.sample"
|
|
||||||
|
|
||||||
[deps]
|
|
||||||
|
|
||||||
source_file="res://assets/sounds/flashlight/slow-flashlight-click-008.wav"
|
|
||||||
dest_files=["res://.godot/imported/slow-flashlight-click-008.wav-05434edc3f95e0ae2600f2292b76eae0.sample"]
|
|
||||||
|
|
||||||
[params]
|
|
||||||
|
|
||||||
force/8_bit=false
|
|
||||||
force/mono=false
|
|
||||||
force/max_rate=false
|
|
||||||
force/max_rate_hz=44100
|
|
||||||
edit/trim=false
|
|
||||||
edit/normalize=false
|
|
||||||
edit/loop_mode=0
|
|
||||||
edit/loop_begin=0
|
|
||||||
edit/loop_end=-1
|
|
||||||
compress/mode=2
|
|
||||||
Binary file not shown.
|
|
@ -1,24 +0,0 @@
|
||||||
[remap]
|
|
||||||
|
|
||||||
importer="wav"
|
|
||||||
type="AudioStreamWAV"
|
|
||||||
uid="uid://cdlud3hmjtl2u"
|
|
||||||
path="res://.godot/imported/slow-flashlight-click-010.wav-8c079b850bbf8f78650607416fa4177e.sample"
|
|
||||||
|
|
||||||
[deps]
|
|
||||||
|
|
||||||
source_file="res://assets/sounds/flashlight/slow-flashlight-click-010.wav"
|
|
||||||
dest_files=["res://.godot/imported/slow-flashlight-click-010.wav-8c079b850bbf8f78650607416fa4177e.sample"]
|
|
||||||
|
|
||||||
[params]
|
|
||||||
|
|
||||||
force/8_bit=false
|
|
||||||
force/mono=false
|
|
||||||
force/max_rate=false
|
|
||||||
force/max_rate_hz=44100
|
|
||||||
edit/trim=false
|
|
||||||
edit/normalize=false
|
|
||||||
edit/loop_mode=0
|
|
||||||
edit/loop_begin=0
|
|
||||||
edit/loop_end=-1
|
|
||||||
compress/mode=2
|
|
||||||
Binary file not shown.
|
|
@ -1,24 +0,0 @@
|
||||||
[remap]
|
|
||||||
|
|
||||||
importer="wav"
|
|
||||||
type="AudioStreamWAV"
|
|
||||||
uid="uid://bwsw5nf0jv0j4"
|
|
||||||
path="res://.godot/imported/slow-flashlight-click-013.wav-044f9d7ecdd6083c3daaa9d45925f79d.sample"
|
|
||||||
|
|
||||||
[deps]
|
|
||||||
|
|
||||||
source_file="res://assets/sounds/flashlight/slow-flashlight-click-013.wav"
|
|
||||||
dest_files=["res://.godot/imported/slow-flashlight-click-013.wav-044f9d7ecdd6083c3daaa9d45925f79d.sample"]
|
|
||||||
|
|
||||||
[params]
|
|
||||||
|
|
||||||
force/8_bit=false
|
|
||||||
force/mono=false
|
|
||||||
force/max_rate=false
|
|
||||||
force/max_rate_hz=44100
|
|
||||||
edit/trim=false
|
|
||||||
edit/normalize=false
|
|
||||||
edit/loop_mode=0
|
|
||||||
edit/loop_begin=0
|
|
||||||
edit/loop_end=-1
|
|
||||||
compress/mode=2
|
|
||||||
|
|
@ -26,7 +26,9 @@ buses/default_bus_layout="uid://bfh2c7jnwhac0"
|
||||||
[autoload]
|
[autoload]
|
||||||
|
|
||||||
Console="*uid://bojihx1fwf426"
|
Console="*uid://bojihx1fwf426"
|
||||||
PlayerProperties="*uid://l2rc674shj03"
|
PlayerConsts="*uid://l2rc674shj03"
|
||||||
|
Sounds="*uid://c4vhdhbi2yu8i"
|
||||||
|
LoadingScreen="*uid://br8pa51piwxuy"
|
||||||
|
|
||||||
[display]
|
[display]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,5 @@
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
@export_category("Grabbing")
|
|
||||||
@export var GRAB_POWER: float = 15.0 ##how fast the grabbed object snaps to the hold position
|
|
||||||
@export var GRAB_ROTATION_POWER: float = 15.0 ##how fast the object rotates towards the player
|
|
||||||
@export var GRAB_PANEL: PackedScene ##panel that goes over the grabbable object to show its grabbable
|
|
||||||
|
|
||||||
@onready var ui_handler: Node = %UiHandler
|
@onready var ui_handler: Node = %UiHandler
|
||||||
@onready var player_state: Node = %PlayerState
|
@onready var player_state: Node = %PlayerState
|
||||||
@onready var flashlight: SpotLight3D = %Flashlight
|
@onready var flashlight: SpotLight3D = %Flashlight
|
||||||
|
|
@ -79,14 +74,14 @@ func _input(event):
|
||||||
held_object = null
|
held_object = null
|
||||||
popup_panels.visible = true
|
popup_panels.visible = true
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(_delta: float) -> void:
|
||||||
#handle grabbed object
|
#handle grabbed object
|
||||||
if held_object != null:
|
if held_object != null:
|
||||||
var target_pos = hold_position.global_position
|
var target_pos = hold_position.global_position
|
||||||
var current_pos = held_object.global_position
|
var current_pos = held_object.global_position
|
||||||
var direction = target_pos - current_pos
|
var direction = target_pos - current_pos
|
||||||
|
|
||||||
held_object.linear_velocity = direction * GRAB_POWER
|
held_object.linear_velocity = direction * PlayerConsts.GRAB_POWER
|
||||||
|
|
||||||
var current_quat = held_object.global_transform.basis.get_rotation_quaternion()
|
var current_quat = held_object.global_transform.basis.get_rotation_quaternion()
|
||||||
var target_quat = hold_position.global_transform.basis.get_rotation_quaternion()
|
var target_quat = hold_position.global_transform.basis.get_rotation_quaternion()
|
||||||
|
|
@ -98,12 +93,12 @@ func _physics_process(delta: float) -> void:
|
||||||
if angle > PI:
|
if angle > PI:
|
||||||
angle -= TAU
|
angle -= TAU
|
||||||
|
|
||||||
held_object.angular_velocity = axis * angle * GRAB_ROTATION_POWER
|
held_object.angular_velocity = axis * angle * PlayerConsts.GRAB_ROTATION_POWER
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
mouse_motion.y = clamp(mouse_motion.y, -1560, 1560)
|
mouse_motion.y = clamp(mouse_motion.y, -1560, 1560)
|
||||||
player.transform.basis = Basis.from_euler(Vector3(0, mouse_motion.x * -0.001 * procedural_camera_mover.LOOK_SENSITIVITY, 0))
|
player.transform.basis = Basis.from_euler(Vector3(0, mouse_motion.x * -0.001 * PlayerConsts.LOOK_SENSITIVITY, 0))
|
||||||
camera.transform.basis = lerp(camera.transform.basis, Basis.from_euler(Vector3(mouse_motion.y * -0.001 * procedural_camera_mover.LOOK_SENSITIVITY, 0, 0)), delta * 10)
|
camera.transform.basis = lerp(camera.transform.basis, Basis.from_euler(Vector3(mouse_motion.y * -0.001 * PlayerConsts.LOOK_SENSITIVITY, 0, 0)), delta * 10)
|
||||||
|
|
||||||
if not Console.toggled:
|
if not Console.toggled:
|
||||||
if Input.is_action_just_pressed("next_item"):
|
if Input.is_action_just_pressed("next_item"):
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,5 @@
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
@export_category("Movement")
|
|
||||||
@export var SPEED = 5.0 ##base walking speed
|
|
||||||
@export var SPRINT_MULTIPLIER = 1.5 ##how much faster should you move, when sprinting
|
|
||||||
@export var SPRINT_STAMINA_COST = 10.0 ##how much stamina should be consumed each frame while sprinting (delta * SPRINT_STAMINA_COST)
|
|
||||||
@export var CROUCH_SPEED_MULTIPLIER = .5 ##how much slower you should be going while crouching
|
|
||||||
|
|
||||||
@export_category("Jump")
|
|
||||||
@export var JUMP_VELOCITY = 4.5 ##how high you can jump
|
|
||||||
@export var JUMP_STAMINA_COST = 10 ##how much stamina each jump consumes
|
|
||||||
|
|
||||||
@export_category("Camera")
|
|
||||||
@export var LOOK_SENSITIVITY = 1.0 ##camera sensitivity
|
|
||||||
@export var CAMERA_VELOCITY_MULTIPLIER = 1.5 ##how heavy should the UI movement feel
|
|
||||||
|
|
||||||
@onready var camera_pivot: Node3D = %CameraPivot
|
@onready var camera_pivot: Node3D = %CameraPivot
|
||||||
@onready var player_camera: Camera3D = %PlayerCamera
|
@onready var player_camera: Camera3D = %PlayerCamera
|
||||||
@onready var player: CharacterBody3D = $"../.."
|
@onready var player: CharacterBody3D = $"../.."
|
||||||
|
|
@ -33,9 +19,9 @@ func _physics_process(delta: float) -> void:
|
||||||
player.velocity += player.get_gravity() * delta
|
player.velocity += player.get_gravity() * delta
|
||||||
|
|
||||||
if not player_state.in_menu and not Console.toggled:
|
if not player_state.in_menu and not Console.toggled:
|
||||||
if Input.is_action_just_pressed("jump") and player.is_on_floor() and player_manager.stamina > JUMP_STAMINA_COST:
|
if Input.is_action_just_pressed("jump") and player.is_on_floor() and player_manager.stamina > PlayerConsts.JUMP_STAMINA_COST:
|
||||||
player.velocity.y = JUMP_VELOCITY
|
player.velocity.y = PlayerConsts.JUMP_VELOCITY
|
||||||
player_manager.stamina -= JUMP_STAMINA_COST
|
player_manager.stamina -= PlayerConsts.JUMP_STAMINA_COST
|
||||||
player_manager.stamina_recharge_off()
|
player_manager.stamina_recharge_off()
|
||||||
|
|
||||||
var input_dir = Input.get_vector("left", "right", "forward", "backward")
|
var input_dir = Input.get_vector("left", "right", "forward", "backward")
|
||||||
|
|
@ -49,21 +35,21 @@ func _physics_process(delta: float) -> void:
|
||||||
camera_pivot.rotation.z = lerpf(camera_pivot.rotation.z, 0, delta*10)
|
camera_pivot.rotation.z = lerpf(camera_pivot.rotation.z, 0, delta*10)
|
||||||
camera_pivot.position.x = lerpf(camera_pivot.position.x, 0, delta * 7)
|
camera_pivot.position.x = lerpf(camera_pivot.position.x, 0, delta * 7)
|
||||||
|
|
||||||
var target_speed = SPEED
|
var target_speed = PlayerConsts.SPEED
|
||||||
var is_moving = input_dir != Vector2.ZERO
|
var is_moving = input_dir != Vector2.ZERO
|
||||||
|
|
||||||
if Input.is_action_pressed("crouch"):
|
if Input.is_action_pressed("crouch"):
|
||||||
player_hit_box.shape.height = lerpf(player_hit_box.shape.height, .5, delta * 5)
|
player_hit_box.shape.height = lerpf(player_hit_box.shape.height, .5, delta * 5)
|
||||||
target_speed *= CROUCH_SPEED_MULTIPLIER
|
target_speed *= PlayerConsts.CROUCH_SPEED_MULTIPLIER
|
||||||
player_state.is_crouched(true)
|
player_state.is_crouched(true)
|
||||||
else:
|
else:
|
||||||
player_hit_box.shape.height = lerpf(player_hit_box.shape.height, 2, delta * 10)
|
player_hit_box.shape.height = lerpf(player_hit_box.shape.height, 2, delta * 10)
|
||||||
player_state.is_crouched(false)
|
player_state.is_crouched(false)
|
||||||
|
|
||||||
if Input.is_action_pressed("sprint") and player_manager.stamina > 0:
|
if Input.is_action_pressed("sprint") and player_manager.stamina > 0:
|
||||||
target_speed *= SPRINT_MULTIPLIER
|
target_speed *= PlayerConsts.SPRINT_MULTIPLIER
|
||||||
player_state.is_running(true)
|
player_state.is_running(true)
|
||||||
player_manager.stamina -= delta * SPRINT_STAMINA_COST
|
player_manager.stamina -= delta * PlayerConsts.SPRINT_STAMINA_COST
|
||||||
player_manager.stamina_recharge_off()
|
player_manager.stamina_recharge_off()
|
||||||
else:
|
else:
|
||||||
player_state.is_running(false)
|
player_state.is_running(false)
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,5 @@
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
@export_category("Inventory")
|
|
||||||
@export var INVENTORY_MAX = 3 ##max number of items that can be in the player's inventory
|
|
||||||
@export var INVENTORY_ITEMS: Array = [] ##the items in the player's inventory
|
|
||||||
|
|
||||||
var stamina: float = 100.0
|
var stamina: float = 100.0
|
||||||
var flashlight_power: float = 100.0
|
var flashlight_power: float = 100.0
|
||||||
var selected_item: int = 0
|
var selected_item: int = 0
|
||||||
|
|
@ -41,9 +37,9 @@ func _on_stamina_reset_timeout() -> void:
|
||||||
stamina_recharge = true
|
stamina_recharge = true
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
await get_tree().create_timer(0.1).timeout.connect(func (): select_item(0))
|
get_tree().create_timer(0.1).timeout.connect(func (): select_item(0))
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(_delta: float) -> void:
|
||||||
if stamina_recharge:
|
if stamina_recharge:
|
||||||
stamina = move_toward(stamina, 100, .5)
|
stamina = move_toward(stamina, 100, .5)
|
||||||
if flashlight.visible:
|
if flashlight.visible:
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,5 @@
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
@export_category("Camera")
|
|
||||||
@export var LOOK_SENSITIVITY = 1.0 ##camera sensitivity
|
|
||||||
@export var CAMERA_VELOCITY_MULTIPLIER = 1.5 ##how heavy should the UI movement feel
|
|
||||||
@export var CAMERA_BOB_FREQUENCY = 2.4 ##how quick the camera bobs whilst moving
|
|
||||||
@export var CAMERA_BOB_AMPLITUDE = 0.08 ##how hard the camera bobs whilst moving
|
|
||||||
@export var CAMERA_BOB_MULTIPLIER = 200.0 ##how much the ui reacts to head bobbing
|
|
||||||
@export var CAMERA_SIDEWAYS_BOB_AMPLITUDE = 0.03 ## how many degrees does the camera bob sideways
|
|
||||||
|
|
||||||
@export_category("UI")
|
|
||||||
@export var UI_SCALE: float = 1 ##rational scale of the ui
|
|
||||||
@export var UI_MOVEMENT_SENSITIVITY = 0.5 ##how much the UI moves when you move the camera
|
|
||||||
@export var UI_MOVEMENT_SPEED = 15.0 ##how fast the UI moves when you move the camera
|
|
||||||
@export var UI_MOVEMENT_VELOCITY_MULTIPLIER = 2.0 ##how much the ui leans when walking or strafing
|
|
||||||
|
|
||||||
@onready var player: CharacterBody3D = $"../.."
|
@onready var player: CharacterBody3D = $"../.."
|
||||||
@onready var sound_controller: Node = %SoundController
|
@onready var sound_controller: Node = %SoundController
|
||||||
@onready var camera: Camera3D = %PlayerCamera
|
@onready var camera: Camera3D = %PlayerCamera
|
||||||
|
|
@ -24,12 +10,12 @@ extends Node
|
||||||
@onready var player_state: Node = %PlayerState
|
@onready var player_state: Node = %PlayerState
|
||||||
@onready var input_controller: Node = %InputController
|
@onready var input_controller: Node = %InputController
|
||||||
|
|
||||||
|
|
||||||
var t_bob: float = 0.0
|
var t_bob: float = 0.0
|
||||||
var last_bob_y: float = 0.0
|
var last_bob_y: float = 0.0
|
||||||
var t_breath: float = 0.0
|
var t_breath: float = 0.0
|
||||||
var last_breath_y: float = 0.0
|
var last_breath_y: float = 0.0
|
||||||
|
|
||||||
var _camera_original_position: Vector3 = Vector3(0,.75,0)
|
|
||||||
var _last_camera_global_position: Vector3 = Vector3.ZERO
|
var _last_camera_global_position: Vector3 = Vector3.ZERO
|
||||||
var _breathing: bool = true
|
var _breathing: bool = true
|
||||||
|
|
||||||
|
|
@ -46,7 +32,7 @@ func _process(delta: float) -> void:
|
||||||
breathing_sound()
|
breathing_sound()
|
||||||
|
|
||||||
func do(delta):
|
func do(delta):
|
||||||
ui.offset_transform_scale *= UI_SCALE
|
ui.offset_transform_scale *= PlayerConsts.UI_SCALE
|
||||||
ui_movement_handling(delta)
|
ui_movement_handling(delta)
|
||||||
|
|
||||||
var horizontal_speed = Vector3(player.velocity.x, player.velocity.y, player.velocity.z).length()
|
var horizontal_speed = Vector3(player.velocity.x, player.velocity.y, player.velocity.z).length()
|
||||||
|
|
@ -73,7 +59,7 @@ func do(delta):
|
||||||
camera.transform.basis = camera.transform.basis.slerp(target_basis, delta * 5)
|
camera.transform.basis = camera.transform.basis.slerp(target_basis, delta * 5)
|
||||||
|
|
||||||
func ui_movement_handling(delta: float):
|
func ui_movement_handling(delta: float):
|
||||||
var mouse_offset = -input_controller.mouse_motion_delta * UI_MOVEMENT_SENSITIVITY
|
var mouse_offset = -input_controller.mouse_motion_delta * PlayerConsts.UI_MOVEMENT_SENSITIVITY
|
||||||
|
|
||||||
var current_camera_global_position = camera.global_position
|
var current_camera_global_position = camera.global_position
|
||||||
var camera_global_velocity = (current_camera_global_position - _last_camera_global_position) / delta
|
var camera_global_velocity = (current_camera_global_position - _last_camera_global_position) / delta
|
||||||
|
|
@ -83,22 +69,22 @@ func ui_movement_handling(delta: float):
|
||||||
var inertia_offset = Vector2(
|
var inertia_offset = Vector2(
|
||||||
-cam_local_vel.x,
|
-cam_local_vel.x,
|
||||||
cam_local_vel.y - (cam_local_vel.z * 0.25)
|
cam_local_vel.y - (cam_local_vel.z * 0.25)
|
||||||
) * CAMERA_VELOCITY_MULTIPLIER
|
) * PlayerConsts.CAMERA_VELOCITY_MULTIPLIER
|
||||||
|
|
||||||
var target_offset = mouse_offset + inertia_offset
|
var target_offset = mouse_offset + inertia_offset
|
||||||
ui.position = ui.position.lerp(ui_base_position + target_offset, delta * UI_MOVEMENT_SPEED)
|
ui.position = ui.position.lerp(ui_base_position + target_offset, delta * PlayerConsts.UI_MOVEMENT_SPEED)
|
||||||
|
|
||||||
_last_camera_global_position = current_camera_global_position
|
_last_camera_global_position = current_camera_global_position
|
||||||
|
|
||||||
var ui_scaling_target = Vector2(-cam_local_vel.z * UI_MOVEMENT_SENSITIVITY * .002 + 1, -cam_local_vel.z * UI_MOVEMENT_SENSITIVITY * .002 + 1)
|
var ui_scaling_target = Vector2(-cam_local_vel.z * PlayerConsts.UI_MOVEMENT_SENSITIVITY * .002 + 1, -cam_local_vel.z * PlayerConsts.UI_MOVEMENT_SENSITIVITY * .002 + 1)
|
||||||
ui.offset_transform_scale = ui.offset_transform_scale.lerp(ui_scaling_target, delta * UI_MOVEMENT_SPEED)
|
ui.offset_transform_scale = ui.offset_transform_scale.lerp(ui_scaling_target, delta * PlayerConsts.UI_MOVEMENT_SPEED)
|
||||||
|
|
||||||
var ui_rotation_target = -inertia_offset.x - mouse_offset.x * 0.25
|
var ui_rotation_target = -inertia_offset.x - mouse_offset.x * 0.25
|
||||||
ui.offset_transform_rotation = lerpf(ui.offset_transform_rotation, ui_rotation_target * UI_MOVEMENT_SENSITIVITY * 0.003, delta * UI_MOVEMENT_SPEED)
|
ui.offset_transform_rotation = lerpf(ui.offset_transform_rotation, ui_rotation_target * PlayerConsts.UI_MOVEMENT_SENSITIVITY * 0.003, delta * PlayerConsts.UI_MOVEMENT_SPEED)
|
||||||
|
|
||||||
|
|
||||||
func footstep_sound():
|
func footstep_sound():
|
||||||
var current_sin_pos = sin(t_bob * CAMERA_BOB_FREQUENCY)
|
var current_sin_pos = sin(t_bob * PlayerConsts.CAMERA_BOB_FREQUENCY)
|
||||||
|
|
||||||
if last_bob_y >= -.95 and current_sin_pos < -.95:
|
if last_bob_y >= -.95 and current_sin_pos < -.95:
|
||||||
sound_controller.play_footstep_sound()
|
sound_controller.play_footstep_sound()
|
||||||
|
|
@ -107,7 +93,7 @@ func footstep_sound():
|
||||||
|
|
||||||
func breathing_sound():
|
func breathing_sound():
|
||||||
if _breathing:
|
if _breathing:
|
||||||
var current_sin_pos = sin(t_breath * CAMERA_BOB_FREQUENCY)
|
var current_sin_pos = sin(t_breath * PlayerConsts.CAMERA_BOB_FREQUENCY)
|
||||||
|
|
||||||
if last_breath_y <= -.60 and current_sin_pos > -.60:
|
if last_breath_y <= -.60 and current_sin_pos > -.60:
|
||||||
sound_controller.play_breath_sound(true)
|
sound_controller.play_breath_sound(true)
|
||||||
|
|
@ -118,13 +104,13 @@ func breathing_sound():
|
||||||
last_breath_y = current_sin_pos
|
last_breath_y = current_sin_pos
|
||||||
|
|
||||||
func get_breathing_bob_offset_pos() -> Vector3:
|
func get_breathing_bob_offset_pos() -> Vector3:
|
||||||
return Vector3(0, sin(t_breath * CAMERA_BOB_FREQUENCY) * CAMERA_BOB_AMPLITUDE + .75, 0)
|
return Vector3(0, sin(t_breath * PlayerConsts.CAMERA_BOB_FREQUENCY) * PlayerConsts.CAMERA_BOB_AMPLITUDE + .75, 0)
|
||||||
|
|
||||||
func get_breathing_bob_offset_rot() -> Vector3:
|
func get_breathing_bob_offset_rot() -> Vector3:
|
||||||
return Vector3(sin(t_breath * CAMERA_BOB_FREQUENCY) * CAMERA_SIDEWAYS_BOB_AMPLITUDE, 0, 0)
|
return Vector3(sin(t_breath * PlayerConsts.CAMERA_BOB_FREQUENCY) * PlayerConsts.CAMERA_SIDEWAYS_BOB_AMPLITUDE, 0, 0)
|
||||||
|
|
||||||
func get_moving_bob_offset_pos() -> Vector3:
|
func get_moving_bob_offset_pos() -> Vector3:
|
||||||
return Vector3(0, sin(t_bob * CAMERA_BOB_FREQUENCY) * CAMERA_BOB_AMPLITUDE, 0)
|
return Vector3(0, sin(t_bob * PlayerConsts.CAMERA_BOB_FREQUENCY) * PlayerConsts.CAMERA_BOB_AMPLITUDE, 0)
|
||||||
|
|
||||||
func get_moving_bob_offset_rot() -> Vector3:
|
func get_moving_bob_offset_rot() -> Vector3:
|
||||||
return Vector3(0, 0, sin(t_bob * CAMERA_BOB_FREQUENCY * .5) * CAMERA_SIDEWAYS_BOB_AMPLITUDE)
|
return Vector3(0, 0, sin(t_bob * PlayerConsts.CAMERA_BOB_FREQUENCY * .5) * PlayerConsts.CAMERA_SIDEWAYS_BOB_AMPLITUDE)
|
||||||
|
|
|
||||||
|
|
@ -1,36 +1,34 @@
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
@export_category("Audio")
|
#@export_category("Audio")
|
||||||
@export var AUDIO_LOUDNESS: float = 100.0
|
#@export var NORMAL_FOOTSTEP_SOUNDS: Array[AudioStream] ##normal footsteps -- walking
|
||||||
@export var NORMAL_FOOTSTEP_SOUNDS: Array[AudioStreamWAV] ##normal footsteps -- walking
|
#@export var HEAVY_FOOTSTEP_SOUNDS: Array[AudioStream] ##heavy footsteps -- running
|
||||||
@export var HEAVY_FOOTSTEP_SOUNDS: Array[AudioStreamWAV] ##heavy footsteps -- running
|
#@export var LIGHT_FOOTSTEP_SOUNDS: Array[AudioStream] ##light footsteps -- crouching
|
||||||
@export var LIGHT_FOOTSTEP_SOUNDS: Array[AudioStreamWAV] ##light footsteps -- crouching
|
#@export var FLASHLIGHT_CLICK_SOUNDS: Array[AudioStream] ##flashlight click
|
||||||
@export var FLASHLIGHT_CLICK_SOUNDS: Array[AudioStreamWAV] ##flashlight click
|
#@export var SHUFFLE_FOOTSTEP_SOUNDS: Array[AudioStream] ##shuffling -- random chance of playing while running
|
||||||
@export var SHUFFLE_FOOTSTEP_SOUNDS: Array[AudioStreamWAV] ##shuffling -- random chance of playing while running
|
#
|
||||||
@export var SHUFFLE_CHANCE: float = 20 ##percentage of chance for a shuffle noise to be played whilst running
|
#@export var JUMP_LANDING_SOUNDS: Array[AudioStream]
|
||||||
|
#@export var JUMP_STARTING_SOUNDS: Array[AudioStream]
|
||||||
@export var JUMP_LANDING_SOUNDS: Array[AudioStream]
|
#@export var JUMP_LANDING_BREATH_SOUNDS: Array[AudioStream]
|
||||||
@export var JUMP_STARTING_SOUNDS: Array[AudioStream]
|
#@export var JUMP_STARTING_BREATH_SOUNDS: Array[AudioStream]
|
||||||
@export var JUMP_LANDING_BREATH_SOUNDS: Array[AudioStream]
|
#
|
||||||
@export var JUMP_STARTING_BREATH_SOUNDS: Array[AudioStream]
|
#@export_group("Breathing")
|
||||||
|
#@export var BREATHE_IN_CALM: Array[AudioStream]
|
||||||
@export_group("Breathing")
|
#@export var BREATHE_IN_LOW: Array[AudioStream]
|
||||||
@export var BREATHE_IN_CALM: Array[AudioStream]
|
#@export var BREATHE_IN_MID: Array[AudioStream]
|
||||||
@export var BREATHE_IN_LOW: Array[AudioStream]
|
#@export var BREATHE_IN_HEAVY: Array[AudioStream]
|
||||||
@export var BREATHE_IN_MID: Array[AudioStream]
|
#@export var BREATHE_IN_MAX: Array[AudioStream]
|
||||||
@export var BREATHE_IN_HEAVY: Array[AudioStream]
|
#@export var BREATHE_IN_EXHAUSTED: Array[AudioStream]
|
||||||
@export var BREATHE_IN_MAX: Array[AudioStream]
|
#
|
||||||
@export var BREATHE_IN_EXHAUSTED: Array[AudioStream]
|
#@export var BREATHE_OUT_CALM: Array[AudioStream]
|
||||||
|
#@export var BREATHE_OUT_LOW: Array[AudioStream]
|
||||||
@export var BREATHE_OUT_CALM: Array[AudioStream]
|
#@export var BREATHE_OUT_MID: Array[AudioStream]
|
||||||
@export var BREATHE_OUT_LOW: Array[AudioStream]
|
#@export var BREATHE_OUT_HEAVY: Array[AudioStream]
|
||||||
@export var BREATHE_OUT_MID: Array[AudioStream]
|
#@export var BREATHE_OUT_MAX: Array[AudioStream]
|
||||||
@export var BREATHE_OUT_HEAVY: Array[AudioStream]
|
#@export var BREATHE_OUT_EXHAUSTED: Array[AudioStream]
|
||||||
@export var BREATHE_OUT_MAX: Array[AudioStream]
|
#
|
||||||
@export var BREATHE_OUT_EXHAUSTED: Array[AudioStream]
|
#@export_group("Whitenoise")
|
||||||
|
#@export var WHITENOISE: AudioStream
|
||||||
@export_group("Whitenoise")
|
|
||||||
@export var WHITENOISE: AudioStream
|
|
||||||
|
|
||||||
var _current_flashlight_sound = null
|
var _current_flashlight_sound = null
|
||||||
var _current_footstep_sound = null
|
var _current_footstep_sound = null
|
||||||
|
|
@ -145,43 +143,43 @@ func play_breath_sound(breathe_in:bool = true):
|
||||||
while play_sound == _current_breath_in_sound:
|
while play_sound == _current_breath_in_sound:
|
||||||
match player_state.breathing_mode:
|
match player_state.breathing_mode:
|
||||||
player_state.breath.calm:
|
player_state.breath.calm:
|
||||||
play_sound = BREATHE_IN_CALM.pick_random()
|
play_sound = Sounds.BREATHE_IN_CALM.pick_random()
|
||||||
player_state.breath.low:
|
player_state.breath.low:
|
||||||
play_sound = BREATHE_IN_LOW.pick_random()
|
play_sound = Sounds.BREATHE_IN_LOW.pick_random()
|
||||||
player_state.breath.mid:
|
player_state.breath.mid:
|
||||||
play_sound = BREATHE_IN_MID.pick_random()
|
play_sound = Sounds.BREATHE_IN_MID.pick_random()
|
||||||
player_state.breath.heavy:
|
player_state.breath.heavy:
|
||||||
play_sound = BREATHE_IN_HEAVY.pick_random()
|
play_sound = Sounds.BREATHE_IN_HEAVY.pick_random()
|
||||||
player_state.breath.max:
|
player_state.breath.max:
|
||||||
play_sound = BREATHE_IN_MAX.pick_random()
|
play_sound = Sounds.BREATHE_IN_MAX.pick_random()
|
||||||
player_state.breath.exhausted:
|
player_state.breath.exhausted:
|
||||||
play_sound = BREATHE_IN_EXHAUSTED.pick_random()
|
play_sound = Sounds.BREATHE_IN_EXHAUSTED.pick_random()
|
||||||
_current_breath_in_sound = play_sound
|
_current_breath_in_sound = play_sound
|
||||||
else:
|
else:
|
||||||
play_sound = _current_breath_out_sound
|
play_sound = _current_breath_out_sound
|
||||||
while play_sound == _current_breath_out_sound:
|
while play_sound == _current_breath_out_sound:
|
||||||
match player_state.breathing_mode:
|
match player_state.breathing_mode:
|
||||||
player_state.breath.calm:
|
player_state.breath.calm:
|
||||||
play_sound = BREATHE_OUT_CALM.pick_random()
|
play_sound = Sounds.BREATHE_OUT_CALM.pick_random()
|
||||||
player_state.breath.low:
|
player_state.breath.low:
|
||||||
play_sound = BREATHE_OUT_LOW.pick_random()
|
play_sound = Sounds.BREATHE_OUT_LOW.pick_random()
|
||||||
player_state.breath.mid:
|
player_state.breath.mid:
|
||||||
play_sound = BREATHE_OUT_MID.pick_random()
|
play_sound = Sounds.BREATHE_OUT_MID.pick_random()
|
||||||
player_state.breath.heavy:
|
player_state.breath.heavy:
|
||||||
play_sound = BREATHE_OUT_HEAVY.pick_random()
|
play_sound = Sounds.BREATHE_OUT_HEAVY.pick_random()
|
||||||
player_state.breath.max:
|
player_state.breath.max:
|
||||||
play_sound = BREATHE_OUT_MAX.pick_random()
|
play_sound = Sounds.BREATHE_OUT_MAX.pick_random()
|
||||||
player_state.breath.exhausted:
|
player_state.breath.exhausted:
|
||||||
play_sound = BREATHE_OUT_EXHAUSTED.pick_random()
|
play_sound = Sounds.BREATHE_OUT_EXHAUSTED.pick_random()
|
||||||
_current_breath_out_sound = play_sound
|
_current_breath_out_sound = play_sound
|
||||||
|
|
||||||
play_stream_on_player(head, play_sound)
|
play_stream_on_player(head, play_sound)
|
||||||
|
|
||||||
func play_flashlight_sound():
|
func play_flashlight_sound():
|
||||||
var play_sound = FLASHLIGHT_CLICK_SOUNDS.pick_random()
|
var play_sound = Sounds.FLASHLIGHT_CLICK_SOUNDS.pick_random()
|
||||||
|
|
||||||
while play_sound == _current_flashlight_sound:
|
while play_sound == _current_flashlight_sound:
|
||||||
play_sound = FLASHLIGHT_CLICK_SOUNDS.pick_random()
|
play_sound = Sounds.FLASHLIGHT_CLICK_SOUNDS.pick_random()
|
||||||
|
|
||||||
play_stream_on_player(head_texture, play_sound)
|
play_stream_on_player(head_texture, play_sound)
|
||||||
_current_flashlight_sound = play_sound
|
_current_flashlight_sound = play_sound
|
||||||
|
|
@ -196,15 +194,15 @@ func play_jump_sound(start:bool = true):
|
||||||
match start:
|
match start:
|
||||||
true:
|
true:
|
||||||
while sound_to_play_foot == _current_jump_start_sound:
|
while sound_to_play_foot == _current_jump_start_sound:
|
||||||
sound_to_play_foot = JUMP_STARTING_SOUNDS.pick_random()
|
sound_to_play_foot = Sounds.JUMP_STARTING_SOUNDS.pick_random()
|
||||||
while sound_to_play_breath == _current_jump_start_breath_sound:
|
while sound_to_play_breath == _current_jump_start_breath_sound:
|
||||||
sound_to_play_breath = JUMP_STARTING_BREATH_SOUNDS.pick_random()
|
sound_to_play_breath = Sounds.JUMP_STARTING_BREATH_SOUNDS.pick_random()
|
||||||
false:
|
false:
|
||||||
print(volume)
|
print(volume)
|
||||||
while sound_to_play_foot == _current_jump_land_sound:
|
while sound_to_play_foot == _current_jump_land_sound:
|
||||||
sound_to_play_foot = JUMP_LANDING_SOUNDS.pick_random()
|
sound_to_play_foot = Sounds.JUMP_LANDING_SOUNDS.pick_random()
|
||||||
while sound_to_play_breath == _current_jump_land_breath_sound:
|
while sound_to_play_breath == _current_jump_land_breath_sound:
|
||||||
sound_to_play_breath = JUMP_LANDING_BREATH_SOUNDS.pick_random()
|
sound_to_play_breath = Sounds.JUMP_LANDING_BREATH_SOUNDS.pick_random()
|
||||||
|
|
||||||
play_stream_on_player(head, sound_to_play_breath, randf_range(.8, 1.2), volume)
|
play_stream_on_player(head, sound_to_play_breath, randf_range(.8, 1.2), volume)
|
||||||
play_stream_on_player(is_right_leg.call(), sound_to_play_foot)
|
play_stream_on_player(is_right_leg.call(), sound_to_play_foot)
|
||||||
|
|
@ -212,19 +210,19 @@ func play_jump_sound(start:bool = true):
|
||||||
func play_footstep_sound():
|
func play_footstep_sound():
|
||||||
var sound_to_play:AudioStream
|
var sound_to_play:AudioStream
|
||||||
if player_state.walking:
|
if player_state.walking:
|
||||||
sound_to_play = NORMAL_FOOTSTEP_SOUNDS.pick_random()
|
sound_to_play = Sounds.NORMAL_FOOTSTEP_SOUNDS.pick_random()
|
||||||
while sound_to_play == _current_footstep_sound:
|
while sound_to_play == _current_footstep_sound:
|
||||||
sound_to_play = NORMAL_FOOTSTEP_SOUNDS.pick_random()
|
sound_to_play = Sounds.NORMAL_FOOTSTEP_SOUNDS.pick_random()
|
||||||
elif player_state.running:
|
elif player_state.running:
|
||||||
sound_to_play = HEAVY_FOOTSTEP_SOUNDS.pick_random()
|
sound_to_play = Sounds.HEAVY_FOOTSTEP_SOUNDS.pick_random()
|
||||||
while sound_to_play == _current_footstep_sound:
|
while sound_to_play == _current_footstep_sound:
|
||||||
sound_to_play = HEAVY_FOOTSTEP_SOUNDS.pick_random()
|
sound_to_play = Sounds.HEAVY_FOOTSTEP_SOUNDS.pick_random()
|
||||||
if randf_range(1, 100) > 100 - SHUFFLE_CHANCE:
|
if randf_range(1, 100) > 100 - PlayerConsts.SHUFFLE_CHANCE:
|
||||||
play_stream_on_player(is_right_leg.call().get_child(0), SHUFFLE_FOOTSTEP_SOUNDS.pick_random())
|
play_stream_on_player(is_right_leg.call().get_child(0), Sounds.SHUFFLE_FOOTSTEP_SOUNDS.pick_random())
|
||||||
elif player_state.crouching:
|
elif player_state.crouching:
|
||||||
sound_to_play = LIGHT_FOOTSTEP_SOUNDS.pick_random()
|
sound_to_play = Sounds.LIGHT_FOOTSTEP_SOUNDS.pick_random()
|
||||||
while sound_to_play == _current_footstep_sound:
|
while sound_to_play == _current_footstep_sound:
|
||||||
sound_to_play = LIGHT_FOOTSTEP_SOUNDS.pick_random()
|
sound_to_play = Sounds.LIGHT_FOOTSTEP_SOUNDS.pick_random()
|
||||||
|
|
||||||
_current_footstep_sound = sound_to_play
|
_current_footstep_sound = sound_to_play
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[gd_scene format=3 uid="uid://bojihx1fwf426"]
|
[gd_scene format=3 uid="uid://bojihx1fwf426"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://d05oodtjpja5k" path="res://scenes/console/console.gd" id="1_v2h8y"]
|
[ext_resource type="Script" uid="uid://d05oodtjpja5k" path="res://scenes/ui/console/console.gd" id="1_v2h8y"]
|
||||||
|
|
||||||
[node name="Console" type="Control" unique_id=1645877163]
|
[node name="Console" type="Control" unique_id=1645877163]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
21
scenes/ui/loading_screen.gd
Normal file
21
scenes/ui/loading_screen.gd
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
extends CanvasLayer
|
||||||
|
|
||||||
|
|
||||||
|
func sound_loading():
|
||||||
|
show()
|
||||||
|
|
||||||
|
func sound_loading_done():
|
||||||
|
hide()
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
hide()
|
||||||
|
|
||||||
|
Sounds.loading_sounds.connect(sound_loading)
|
||||||
|
Sounds.loading_sounds_done.connect(sound_loading_done)
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
pass
|
||||||
1
scenes/ui/loading_screen.gd.uid
Normal file
1
scenes/ui/loading_screen.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://br8pa51piwxuy
|
||||||
50
scenes/ui/loading_screen.tscn
Normal file
50
scenes/ui/loading_screen.tscn
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
[gd_scene format=3 uid="uid://046i0offx3w8"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://br8pa51piwxuy" path="res://scenes/ui/loading_screen.gd" id="1_rqdcv"]
|
||||||
|
|
||||||
|
[node name="LoadingScreen" type="CanvasLayer" unique_id=721141233]
|
||||||
|
script = ExtResource("1_rqdcv")
|
||||||
|
|
||||||
|
[node name="Control" type="Control" parent="." unique_id=2009868353]
|
||||||
|
layout_mode = 3
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
|
||||||
|
[node name="ColorRect" type="ColorRect" parent="Control" unique_id=1237635531]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
color = Color(0, 0, 0, 1)
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="Control/ColorRect" unique_id=1444927305]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = -1
|
||||||
|
anchor_left = 0.9
|
||||||
|
anchor_top = 0.9
|
||||||
|
anchor_right = 0.9
|
||||||
|
anchor_bottom = 0.9
|
||||||
|
offset_left = -219.0
|
||||||
|
offset_top = -69.0
|
||||||
|
grow_horizontal = 0
|
||||||
|
grow_vertical = 0
|
||||||
|
theme_override_font_sizes/font_size = 50
|
||||||
|
text = "loading..."
|
||||||
|
|
||||||
|
[node name="ProgressBar" type="ProgressBar" parent="Control/ColorRect" unique_id=1865933389]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = -1
|
||||||
|
anchor_top = 0.96
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 0.98
|
||||||
|
offset_top = -27.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 0
|
||||||
|
show_percentage = false
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
extends CharacterBody3D
|
extends Node
|
||||||
class_name PlayerCharacter
|
|
||||||
|
|
||||||
##TODO make it so that you can easily tweak settings from here, cascading to the components
|
##TODO make it so that you can easily tweak settings from here, cascading to the components
|
||||||
|
|
||||||
@export_category("Movement")
|
@export_category("Movement")
|
||||||
|
|
@ -33,11 +31,6 @@ class_name PlayerCharacter
|
||||||
|
|
||||||
@export_category("Audio")
|
@export_category("Audio")
|
||||||
@export var AUDIO_LOUDNESS: float = 100.0
|
@export var AUDIO_LOUDNESS: float = 100.0
|
||||||
@export var NORMAL_FOOTSTEP_SOUNDS: Array[AudioStreamWAV] ##normal footsteps -- walking
|
|
||||||
@export var HEAVY_FOOTSTEP_SOUNDS: Array[AudioStreamWAV] ##heavy footsteps -- running
|
|
||||||
@export var LIGHT_FOOTSTEP_SOUNDS: Array[AudioStreamWAV] ##light footsteps -- crouching
|
|
||||||
@export var SHUFFLE_FOOTSTEP_SOUNDS: Array[AudioStreamWAV] ##shuffling -- random chance of playing while running
|
|
||||||
@export var FLASHLIGHT_CLICK_SOUNDS: Array[AudioStreamWAV] ##flashlight click
|
|
||||||
@export var SHUFFLE_CHANCE: float = 20 ##percentage of chance for a shuffle noise to be played whilst running
|
@export var SHUFFLE_CHANCE: float = 20 ##percentage of chance for a shuffle noise to be played whilst running
|
||||||
|
|
||||||
@export_category("Grabbing")
|
@export_category("Grabbing")
|
||||||
195
scripts/autoload/sounds.gd
Normal file
195
scripts/autoload/sounds.gd
Normal file
|
|
@ -0,0 +1,195 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
@export_category("Audio")
|
||||||
|
@export_group("Footsteps")
|
||||||
|
@export var NORMAL_FOOTSTEP_SOUNDS: Array[AudioStream] = [] ##normal footsteps -- walking
|
||||||
|
@export var HEAVY_FOOTSTEP_SOUNDS: Array[AudioStream] = [] ##heavy footsteps -- running
|
||||||
|
@export var LIGHT_FOOTSTEP_SOUNDS: Array[AudioStream] = [] ##light footsteps -- crouching
|
||||||
|
@export var SHUFFLE_FOOTSTEP_SOUNDS: Array[AudioStream] = [] ##shuffling -- random chance of playing while running
|
||||||
|
|
||||||
|
@export_group("Flashlight")
|
||||||
|
@export var FLASHLIGHT_CLICK_SOUNDS: Array[AudioStream] = [] ##flashlight click
|
||||||
|
|
||||||
|
@export_group("Jumping")
|
||||||
|
@export var JUMP_LANDING_SOUNDS: Array[AudioStream] = []
|
||||||
|
@export var JUMP_STARTING_SOUNDS: Array[AudioStream] = []
|
||||||
|
@export var JUMP_LANDING_BREATH_SOUNDS: Array[AudioStream] = []
|
||||||
|
@export var JUMP_STARTING_BREATH_SOUNDS: Array[AudioStream] = []
|
||||||
|
|
||||||
|
@export_group("Breathing")
|
||||||
|
@export var BREATHE_IN_CALM: Array[AudioStream] = []
|
||||||
|
@export var BREATHE_IN_LOW: Array[AudioStream] = []
|
||||||
|
@export var BREATHE_IN_MID: Array[AudioStream] = []
|
||||||
|
@export var BREATHE_IN_HEAVY: Array[AudioStream] = []
|
||||||
|
@export var BREATHE_IN_MAX: Array[AudioStream] = []
|
||||||
|
@export var BREATHE_IN_EXHAUSTED: Array[AudioStream] = []
|
||||||
|
|
||||||
|
@export var BREATHE_OUT_CALM: Array[AudioStream] = []
|
||||||
|
@export var BREATHE_OUT_LOW: Array[AudioStream] = []
|
||||||
|
@export var BREATHE_OUT_MID: Array[AudioStream] = []
|
||||||
|
@export var BREATHE_OUT_HEAVY: Array[AudioStream] = []
|
||||||
|
@export var BREATHE_OUT_MAX: Array[AudioStream] = []
|
||||||
|
@export var BREATHE_OUT_EXHAUSTED: Array[AudioStream] = []
|
||||||
|
|
||||||
|
@export_group("Whitenoise")
|
||||||
|
@export var WHITENOISE: AudioStream = preload("res://assets/sounds/whitenoise.mp3")
|
||||||
|
|
||||||
|
var pending_files = {}
|
||||||
|
|
||||||
|
var _steps = [
|
||||||
|
"normal",
|
||||||
|
"light",
|
||||||
|
"heavy",
|
||||||
|
"shuffle"
|
||||||
|
]
|
||||||
|
|
||||||
|
var _breath = [
|
||||||
|
"_calm",
|
||||||
|
"_low",
|
||||||
|
"_mid",
|
||||||
|
"_heavy",
|
||||||
|
"_max",
|
||||||
|
"_exhausted"
|
||||||
|
]
|
||||||
|
|
||||||
|
func get_random_sound(sound_array: Array) -> AudioStream:
|
||||||
|
if sound_array.is_empty():
|
||||||
|
return null
|
||||||
|
|
||||||
|
return sound_array.pick_random()
|
||||||
|
|
||||||
|
const sound_dir_path: String = "res://assets/sounds"
|
||||||
|
|
||||||
|
func load_sound_from_directory_to_var(path: String, sound_type: Array[AudioStream]):
|
||||||
|
var streams: Array[AudioStream] = []
|
||||||
|
var dir = DirAccess.open(path)
|
||||||
|
|
||||||
|
if dir:
|
||||||
|
dir.list_dir_begin()
|
||||||
|
var filename = dir.get_next()
|
||||||
|
|
||||||
|
while filename != "":
|
||||||
|
if not dir.current_is_dir():
|
||||||
|
var clean_filename = filename.replace(".remap", "")
|
||||||
|
|
||||||
|
if clean_filename.ends_with(".mp3") or clean_filename.ends_with(".wav") or clean_filename.ends_with(".ogg"):
|
||||||
|
var full_path = path + "/" + clean_filename
|
||||||
|
|
||||||
|
pending_files[full_path] = sound_type
|
||||||
|
|
||||||
|
ResourceLoader.load_threaded_request(full_path)
|
||||||
|
|
||||||
|
filename = dir.get_next()
|
||||||
|
else:
|
||||||
|
print_debug("Failed to open directory: ", path)
|
||||||
|
|
||||||
|
func load_step_sounds():
|
||||||
|
var dir_part = sound_dir_path + "/walking/"
|
||||||
|
|
||||||
|
for type in _steps:
|
||||||
|
match type:
|
||||||
|
"normal":
|
||||||
|
load_sound_from_directory_to_var(dir_part+type, NORMAL_FOOTSTEP_SOUNDS)
|
||||||
|
"light":
|
||||||
|
load_sound_from_directory_to_var(dir_part+type, LIGHT_FOOTSTEP_SOUNDS)
|
||||||
|
"heavy":
|
||||||
|
load_sound_from_directory_to_var(dir_part+type, HEAVY_FOOTSTEP_SOUNDS)
|
||||||
|
"shuffle":
|
||||||
|
load_sound_from_directory_to_var(dir_part+type, SHUFFLE_FOOTSTEP_SOUNDS)
|
||||||
|
|
||||||
|
func load_breath_sounds():
|
||||||
|
var in_path_part = sound_dir_path + "/breathe_in"
|
||||||
|
var out_path_part = sound_dir_path + "/breathe_out"
|
||||||
|
|
||||||
|
for type in _breath:
|
||||||
|
var in_path = in_path_part + type
|
||||||
|
var out_path = out_path_part + type
|
||||||
|
|
||||||
|
match type:
|
||||||
|
"_calm":
|
||||||
|
load_sound_from_directory_to_var(in_path, BREATHE_IN_CALM)
|
||||||
|
load_sound_from_directory_to_var(out_path, BREATHE_OUT_CALM)
|
||||||
|
"_low":
|
||||||
|
load_sound_from_directory_to_var(in_path, BREATHE_IN_LOW)
|
||||||
|
load_sound_from_directory_to_var(out_path, BREATHE_OUT_LOW)
|
||||||
|
"_mid":
|
||||||
|
load_sound_from_directory_to_var(in_path, BREATHE_IN_MID)
|
||||||
|
load_sound_from_directory_to_var(out_path, BREATHE_OUT_MID)
|
||||||
|
"_heavy":
|
||||||
|
load_sound_from_directory_to_var(in_path, BREATHE_IN_HEAVY)
|
||||||
|
load_sound_from_directory_to_var(out_path, BREATHE_OUT_HEAVY)
|
||||||
|
"_max":
|
||||||
|
load_sound_from_directory_to_var(in_path, BREATHE_IN_MAX)
|
||||||
|
load_sound_from_directory_to_var(out_path, BREATHE_OUT_MAX)
|
||||||
|
"_exhausted":
|
||||||
|
load_sound_from_directory_to_var(in_path, BREATHE_IN_EXHAUSTED)
|
||||||
|
load_sound_from_directory_to_var(out_path, BREATHE_OUT_EXHAUSTED)
|
||||||
|
|
||||||
|
func load_flashlight_sounds():
|
||||||
|
load_sound_from_directory_to_var(sound_dir_path + "/flashlight", FLASHLIGHT_CLICK_SOUNDS)
|
||||||
|
|
||||||
|
func load_jumping_sounds():
|
||||||
|
var foot_dir_path_part = sound_dir_path + "/walking/jump_"
|
||||||
|
var breath_dir_path_part = sound_dir_path + "/breathing/jump_"
|
||||||
|
|
||||||
|
var types = ["starting", "landing"]
|
||||||
|
|
||||||
|
for type in types:
|
||||||
|
match type:
|
||||||
|
"starting":
|
||||||
|
load_sound_from_directory_to_var(breath_dir_path_part + type, JUMP_STARTING_BREATH_SOUNDS)
|
||||||
|
load_sound_from_directory_to_var(foot_dir_path_part + type, JUMP_STARTING_SOUNDS)
|
||||||
|
"landing":
|
||||||
|
load_sound_from_directory_to_var(breath_dir_path_part + type, JUMP_LANDING_BREATH_SOUNDS)
|
||||||
|
load_sound_from_directory_to_var(foot_dir_path_part + type, JUMP_LANDING_SOUNDS)
|
||||||
|
|
||||||
|
|
||||||
|
func start_loading():
|
||||||
|
emit_signal("loading_sounds")
|
||||||
|
is_loading = true
|
||||||
|
load_breath_sounds()
|
||||||
|
load_flashlight_sounds()
|
||||||
|
load_jumping_sounds()
|
||||||
|
load_step_sounds()
|
||||||
|
|
||||||
|
signal loading_sounds
|
||||||
|
signal loading_sounds_done
|
||||||
|
|
||||||
|
var is_loading:bool = false
|
||||||
|
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
if not is_loading:
|
||||||
|
return
|
||||||
|
|
||||||
|
var all_done = true
|
||||||
|
|
||||||
|
var files_to_remove = []
|
||||||
|
|
||||||
|
for path in pending_files.keys():
|
||||||
|
var status = ResourceLoader.load_threaded_get_status(path)
|
||||||
|
|
||||||
|
if status == ResourceLoader.THREAD_LOAD_IN_PROGRESS:
|
||||||
|
all_done = false
|
||||||
|
|
||||||
|
elif status == ResourceLoader.THREAD_LOAD_LOADED:
|
||||||
|
var stream = ResourceLoader.load_threaded_get(path)
|
||||||
|
|
||||||
|
if pending_files.get(path) is Array[AudioStream]:
|
||||||
|
pending_files.get(path).append(stream)
|
||||||
|
|
||||||
|
files_to_remove.append(path)
|
||||||
|
|
||||||
|
elif status == ResourceLoader.THREAD_LOAD_FAILED:
|
||||||
|
print("failed to load audio: ", path)
|
||||||
|
files_to_remove.append(path)
|
||||||
|
|
||||||
|
for path in files_to_remove:
|
||||||
|
pending_files.erase(path)
|
||||||
|
|
||||||
|
if all_done:
|
||||||
|
is_loading = false
|
||||||
|
emit_signal("loading_sounds_done")
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
start_loading()
|
||||||
|
|
||||||
1
scripts/autoload/sounds.gd.uid
Normal file
1
scripts/autoload/sounds.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://c4vhdhbi2yu8i
|
||||||
Loading…
Reference in a new issue