Refactor: Added explicit typing and void return types

- Introduced explicit typing to variables and functions across multiple scripts for better code clarity.
- Specified 'void' as the return type for functions that do not return a value.
- Removed redundant code in some scripts.
This commit is contained in:
Dan 2024-05-15 10:42:16 +01:00
parent a62cd6018e
commit 2a9e78b52e
37 changed files with 216 additions and 248 deletions

View file

@ -1,16 +1,16 @@
extends Node2D
class_name Flowers
@onready var outline = $AreaHighlight
@onready var outline : Sprite2D = $AreaHighlight
@export var health : int = 100
var spawn_snails : bool = false
@onready var spawn_area = $FlowerCollectionArea/CollisionShape2D
@onready var snail = $Snail
@onready var spawn_area : CollisionShape2D = $FlowerCollectionArea/CollisionShape2D
@onready var snail : Snail = $Snail
func _ready():
func _ready() -> void:
hide_outline()
## Check if this level is spawning snails or not
@ -22,21 +22,21 @@ func _ready():
snail.global_position = get_random_snail_spawn()
func show_outline():
func show_outline() -> void:
outline.visible = true
func hide_outline():
func hide_outline() -> void:
outline.visible = false
func get_random_snail_spawn():
var circle_radius = spawn_area.shape.radius
var random_angle = randf_range(0, TAU)
func get_random_snail_spawn() -> Vector2:
var circle_radius : float = spawn_area.shape.radius
var random_angle : float = randf_range(0, TAU)
var x = circle_radius * cos(random_angle)
var y = circle_radius * sin(random_angle)
var x : float = circle_radius * cos(random_angle)
var y : float = circle_radius * sin(random_angle)
var circle_center = spawn_area.global_position
var random_point = circle_center + Vector2(x, y)
var circle_center : Vector2 = spawn_area.global_position
var random_point : Vector2 = circle_center + Vector2(x, y)
return random_point