From 82f2f8976d335885d00c2c762639c6be55bc7d8d Mon Sep 17 00:00:00 2001 From: konsumlamm Date: Mon, 15 Apr 2024 22:28:32 +0200 Subject: [PATCH] Use `const` for `preload` --- src/scripts/enemies/bookworm.gd | 3 ++- src/scripts/pentagram.gd | 2 +- src/scripts/sfx_audio.gd | 2 +- src/scripts/spells/push_back.gd | 5 ++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/scripts/enemies/bookworm.gd b/src/scripts/enemies/bookworm.gd index 3be6b1c..40810df 100644 --- a/src/scripts/enemies/bookworm.gd +++ b/src/scripts/enemies/bookworm.gd @@ -19,7 +19,8 @@ var attack_target := Vector2(0, 0) @onready var shape: CollisionShape2D = $PhysicsCollider @onready var anim: AnimationPlayer = $AnimationPlayer @onready var map: TileMap = get_parent().find_child('Map') -@onready var Spear = preload("res://scenes/projectiles/spearlike.tscn") + +const Spear = preload("res://scenes/projectiles/spearlike.tscn") func _ready() -> void: super._ready() diff --git a/src/scripts/pentagram.gd b/src/scripts/pentagram.gd index 792346a..635bd73 100644 --- a/src/scripts/pentagram.gd +++ b/src/scripts/pentagram.gd @@ -7,7 +7,7 @@ const CLIP_ANGLE := 0.5 @onready var image: TextureRect = $Pentagram @onready var multiline: Line2D = $Multiline -@onready var clip_effect = preload("res://scenes/clip_particles_effect.tscn") +const clip_effect = preload("res://scenes/clip_particles_effect.tscn") const PENTAGRAM_CORNERS: Array[Vector2] = [ Vector2(0.5, 0.885), diff --git a/src/scripts/sfx_audio.gd b/src/scripts/sfx_audio.gd index de079f8..757cf2b 100644 --- a/src/scripts/sfx_audio.gd +++ b/src/scripts/sfx_audio.gd @@ -12,7 +12,7 @@ enum Sound { PUSH_BACK } -var SoundDict = { +const SoundDict = { Sound.CHEST: preload("res://assets/sfx/chest.mp3"), Sound.DRAW: preload("res://assets/sfx/draw.mp3"), Sound.DRAW_INVALID: preload("res://assets/sfx/draw_invalid_spell.mp3"), diff --git a/src/scripts/spells/push_back.gd b/src/scripts/spells/push_back.gd index c1e2568..4369c29 100644 --- a/src/scripts/spells/push_back.gd +++ b/src/scripts/spells/push_back.gd @@ -1,8 +1,7 @@ extends SpellBase -var Pushback_Projectile = preload("res://scenes/projectiles/pushback.tscn") +const PushbackProjectile = preload("res://scenes/projectiles/pushback.tscn") func cast(player: Player, _enemies: Array[Node]): SfxAudio.play_sfx(SfxAudio.Sound.PUSH_BACK) - var projectile = Pushback_Projectile.instantiate() - spawn_projectile(player, projectile) + spawn_projectile(player, PushbackProjectile.instantiate())