remove hardcoded node references in favor of exported properties

This commit is contained in:
2025-08-14 14:19:51 +10:00
parent 0791f085ab
commit 0eca6bcf88
24 changed files with 335 additions and 359 deletions

View File

@@ -1,4 +0,0 @@
class_name FootstepsBank
extends Resource
@export var streams: Array[AudioStream]

View File

@@ -1 +0,0 @@
uid://0uwlhmvmnucf

View File

@@ -1,8 +1,7 @@
extends AudioStreamPlayer3D
@export var _footsteps: FootstepsBank
@export var _footsteps: AudioStream
var _footsteps_shuffle: ShuffleBag = ShuffleBag.new()
@onready var _polyphonic := get_stream_playback() as AudioStreamPlaybackPolyphonic
@@ -10,8 +9,6 @@ func _ready() -> void:
if not _footsteps:
return
_footsteps_shuffle.fill(_footsteps.streams.size())
func play_footstep() -> void:
_polyphonic.play_stream(_footsteps.streams[_footsteps_shuffle.take()])
_polyphonic.play_stream(_footsteps)

View File

@@ -10,6 +10,13 @@ const MARKER_RADIUS: float = 0.2
const CIRCLE_RADIUS: float = 3
const DEFAULT_COLOR: Color = Color.RED
@export_group("References")
@export var _control: Control
@export var _label1: RichTextLabel
@export var _label2: RichTextLabel
@export var _label3: RichTextLabel
@export var _label4: RichTextLabel
var mode: Mode = Mode.PERFORMANCE
var _vectors_to_draw: Dictionary = {}
@@ -23,12 +30,6 @@ var _label1_text: String = ""
var _label2_text: String = ""
var _label3_text: String = ""
@onready var _control: Control = $Control
@onready var _label1: RichTextLabel = $Control/LabelContainer1/Label1
@onready var _label2: RichTextLabel = $Control/LabelContainer2/Label2
@onready var _label3: RichTextLabel = $Control/LabelContainer3/Label3
@onready var _label4: RichTextLabel = $Control/LabelContainer4/Label4
func _ready() -> void:
assert(_control, str(self) + ": _control missing!")

View File

@@ -1,17 +0,0 @@
# https://forum.godotengine.org/t/how-to-set-all-3d-animation-tracks-to-nearest-interpolation/22056/4
@tool
extends AnimationPlayer
func _ready() -> void:
interpolation_change()
func interpolation_change() -> void:
for animation in get_animation_list():
var anim_track_1: Animation = get_animation(animation)
var count: int = anim_track_1.get_track_count()
for i in count:
anim_track_1.track_set_interpolation_type(
i, Animation.INTERPOLATION_NEAREST
)

View File

@@ -1 +0,0 @@
uid://c8ocu8tvf2l6k

View File

@@ -1,9 +1,11 @@
extends Node3D
@export var _spawn_point: Node3D
@export var _projectile_scene: PackedScene
@export var _velocity: Vector3 = Vector3.FORWARD
@export var _spawn_rate: float = 2
@export_group("References")
@export var _spawn_point: Node3D
@export var _projectile_scene: PackedScene
@export var _spawn_particles: GPUParticles3D
var _spawn_timer: float

View File

@@ -3,12 +3,13 @@ extends CanvasLayer
@export var _side_change_speed: float = 15
@export var _screen_inset: float = 100
@export_group("References")
@export var _single_cursor: Control
var _cursor_scene := preload("res://scenes/ui/cursor_base.tscn")
var _cursors: Dictionary[int, PlayerCursor]
@onready var _single_cursor: Control = $CursorBase
func _ready() -> void:
Input.mouse_mode = Input.MOUSE_MODE_HIDDEN

View File

@@ -1,6 +1,9 @@
class_name MainCamera
extends Camera3D
@export_group("References")
@export var _listener: AudioListener3D
@export_group("Positioning")
@export var _height_offset: float = 0.5
@export var _distance: float = 50
@@ -25,8 +28,6 @@ var _player_offsets: Dictionary[int, PlayerOffset]
var _damage_shake_time: float = 0
var _hit_shake_time: float = 0
@onready var _listener := $AudioListener3D as AudioListener3D
func _ready() -> void:
Referencer.main_camera = self

View File

@@ -9,6 +9,9 @@ extends CharacterBody3D
@export var _respawn_height: float = -5
@export var _collision_debug_material: Material
@export_group("References")
@export var attack: PlayerAttack
var stats: PlayerStats = PlayerStats.new()
var movement: PlayerMovement = PlayerMovement.new()
var aiming: PlayerAiming = PlayerAiming.new()
@@ -16,8 +19,6 @@ var aiming: PlayerAiming = PlayerAiming.new()
var _respawn_point: Vector3
var _debug_collision_shapes := DebugCollisionShapes.new()
@onready var attack: PlayerAttack = $Attack
func _ready() -> void:
_respawn_point = global_position
@@ -27,7 +28,6 @@ func _ready() -> void:
func _process(_delta: float) -> void:
var aim_pos := global_position + aiming.aim_offset
Debugger.marker("aim", aim_pos + Vector3.UP)
Debugger.vector("aimv", Vector3(aim_pos.x, 0, aim_pos.z), aim_pos + Vector3.UP)

View File

@@ -1,5 +1,12 @@
extends AnimationTree
@export_group("References")
@export var _player: Player
@export var _attack: PlayerAttack
@export var _bone_flipper: BoneFlipper
@export var _sfx_audio_player: AudioStreamPlayer3D
@export var _hurt_particles: GPUParticles3D
@export_group("Audio")
@export var _hurt_sound: AudioStream
@export var _hit_sounds: Array[AudioStream]
@@ -10,13 +17,6 @@ var _has_input: bool
var _queue_hit_sound: bool
@onready var _player: Player = $"../" as Player
@onready var _attack: PlayerAttack = $"../Attack" as PlayerAttack
@onready var _bone_flipper: BoneFlipper = $"../Model/Armature/Skeleton3D/BoneFlipper"
@onready var _sfx_audio_player: AudioStreamPlayer3D = $"../Audio/ScriptSFXPlayer"
@onready var _hurt_particles: GPUParticles3D = $"../Effects/HurtParticles"
@onready var _sfx_audio_playback_polyphonic := (
_sfx_audio_player.get_stream_playback() as AudioStreamPlaybackPolyphonic
)
@@ -86,7 +86,10 @@ func _run_to_idle() -> void:
func _abort_oneshots() -> void:
set(&"parameters/hit_oneshot/request", AnimationNodeOneShot.ONE_SHOT_REQUEST_ABORT)
set(&"parameters/run->idle_oneshot/request", AnimationNodeOneShot.ONE_SHOT_REQUEST_ABORT)
set(
&"parameters/run->idle_oneshot/request",
AnimationNodeOneShot.ONE_SHOT_REQUEST_ABORT
)
func _on_attack_attacked() -> void:

View File

@@ -6,6 +6,9 @@ signal did_hit
enum Side { RIGHT, LEFT }
@export_group("References")
@export var _attack_shape_node: CollisionShape3D
@export_group("Collision")
@export var _collision_debug_material: Material
@export var _attack_max_angle: float = 2 * PI / 3
@@ -29,8 +32,6 @@ var _cooldown_timer: float
var _hit_window_timer: float
var _queue_hit_stop: bool
@onready var _attack_shape_node: CollisionShape3D = $AttackShape
@onready var _attack_shape: CylinderShape3D = _attack_shape_node.shape as CylinderShape3D

View File

@@ -2,9 +2,11 @@ extends MeshInstance3D
@export var _swoop_effect_time: float = 0.25
@export_group("References")
@export var _attack: PlayerAttack
var _swoop_effect_timer: float
@onready var _attack: PlayerAttack = $"../../Attack" as PlayerAttack
func _ready() -> void:
mesh.radius = _attack.attack_radius

View File

@@ -10,6 +10,10 @@ const MAX_STRETCH: float = 0.75
@export var _hit_particles_scene: PackedScene
@export var _destroy_particles_scene: PackedScene
@export_group("References")
@export var _model_base: Node3D
@export var _model_mesh: MeshInstance3D
var _start_position: Vector3
var _velocity: Vector3
var _lifetime: float
@@ -19,9 +23,6 @@ var _life_timer: float
var _debug_collision_shapes := DebugCollisionShapes.new()
@onready var _model_base: Node3D = $Model
@onready var _model_mesh: MeshInstance3D = $Model/ProjectileMesh
func _ready() -> void:
_life_timer = _lifetime

View File

@@ -1,31 +0,0 @@
class_name ShuffleBag
var _max_size: int
var _indices: PackedInt32Array = []
var _prev_bag_index: int
## Clears and fills the shuffle bag with integers from 0 to [code]size - 1[/code]
func fill(size: int) -> void:
_max_size = size
_indices.clear()
_indices.resize(_max_size)
for i in _max_size:
_indices[i] = i
## Removes a random number from the shuffle bag and returns it.[br]
## If the bag becomes empty, it gets refilled.
func take() -> int:
var bag_index := randi_range(0, _indices.size() - 1)
if bag_index == _prev_bag_index:
bag_index = (bag_index + 1) % _indices.size()
var index := _indices[bag_index]
_indices.remove_at(bag_index)
if _indices.size() == 0:
fill(_max_size)
_prev_bag_index = index
return index

View File

@@ -1 +0,0 @@
uid://dfg3r3ken1xyd