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,19 +1,19 @@
extends Node2D
class_name Dog
@onready var death_box = $DeathBox
@onready var outline = $AreaHighlight
@onready var death_box : Area2D = $DeathBox
@onready var outline : Sprite2D = $AreaHighlight
var acquired_target : Bee = null
var acquired_target : Node2D = null
var target_timer : float = 0.0
@export var distracted : bool = false
var distracted_by : Node2D = null
func _ready():
func _ready() -> void:
death_box.connect("body_entered", Callable(self, "_on_body_entered"))
death_box.connect("body_exited", Callable(self, "_on_body_exited"))
func _process(delta):
func _process(delta : float) -> void:
if acquired_target:
target_timer += delta
@ -32,14 +32,14 @@ func _process(delta):
# Look around
rotation = lerp_angle(rotation, rotation + get_angle_to(distracted_by.global_position), 0.5)
func show_outline():
func show_outline() -> void:
outline.visible = true
func hide_outline():
func hide_outline() -> void:
outline.visible = false
func _on_body_entered(area):
func _on_body_entered(area : Node2D) -> void:
if area.is_in_group("bee") and distracted == false:
if !acquired_target:
Log.pr("Acquired target")
@ -52,7 +52,7 @@ func _on_body_entered(area):
distracted = true
distracted_by = area
func _on_body_exited(area):
func _on_body_exited(area : Node2D) -> void:
if area == acquired_target:
Log.pr("Lost target")
acquired_target = null