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,10 +1,10 @@
extends State
class_name BeeDeath
@onready var bee = get_parent().get_parent() as Bee
@onready var bee : Bee = get_parent().get_parent() as Bee
func enter(_msg := {}):
func enter(_msg : Dictionary = {}) -> void:
GameState.bee_died()
bee.bee_position_animation.play("Death")
bee.bee_wing_animation.stop()

View file

@ -2,13 +2,13 @@ extends State
class_name BeeGathering
@export var animator : AnimationPlayer
@onready var bee = get_parent().get_parent() as Bee # I think this is bad but I dont care it works
@onready var bee : Bee= get_parent().get_parent() as Bee # I think this is bad but I dont care it works
var time_at_patch : float = 0.0
var target : Vector2 = Vector2.ZERO
func enter(_msg := {}):
func enter(_msg : Dictionary = {}) -> void:
bee.just_gathering = true
Log.pr("Gathering now...")
@ -16,7 +16,7 @@ func enter(_msg := {}):
randomize()
target = bee.get_global_position() + Vector2(randi_range(-100, 100), randi_range(-100, 100))
func update(_delta : float):
func update(_delta : float) -> void:
if bee.in_range_of_flowers:
#animator.play("Gathering")

View file

@ -1,7 +1,7 @@
extends State
class_name BeeIdle
@onready var bee = get_parent().get_parent() as Bee # I think this is bad but I dont care it works
@onready var bee : Bee = get_parent().get_parent() as Bee # I think this is bad but I dont care it works
var idle_time : float = 0.0
@ -10,14 +10,14 @@ var target : Vector2 = Vector2.ZERO
var acquire_new_target : bool = false
func enter(_msg := {}):
func enter(_msg : Dictionary = {}) -> void:
if acquire_new_target:
target = bee.get_global_position() + Vector2(randi_range(-60, 60), randi_range(-60, 60))
func exit():
func exit() -> void:
acquire_new_target = true
func update(delta : float):
func update(delta : float) -> void:
if target == Vector2.ZERO:
randomize()
@ -39,7 +39,7 @@ func physics_update(delta : float) -> void:
bee.move_and_collide(bee.velocity)
bee.bee_body.look_at(target)
func find_something_to_do():
func find_something_to_do() -> void:
if bee.nectar > 0:
Log.pr("I have pollen, time to move..")
## Bee has pollen - head home

View file

@ -1,10 +1,10 @@
extends State
class_name BeeReturning
@onready var bee = get_parent().get_parent() as Bee # I think this is bad but I dont care it works
@onready var target = get_tree().get_first_node_in_group("beehive")
@onready var bee : Bee = get_parent().get_parent() as Bee # I think this is bad but I dont care it works
@onready var target : Beehive = get_tree().get_first_node_in_group("beehive")
func enter(_msg := {}) -> void:
func enter(_msg : Dictionary = {}) -> void:
Log.pr("Returning to the hive")
bee.bee_position_animation.play("Flying")

View file

@ -5,10 +5,10 @@ class_name BeeSleeping
var time_at_patch : float = 0.0
func enter(_msg := {}) -> void:
func enter(_msg : Dictionary = {}) -> void:
pass
func update(_delta) -> void:
func update(_delta : float) -> void:
pass
func physics_update(_delta : float) -> void:

View file

@ -3,12 +3,12 @@ class_name BeeTravelling
@export var target : Drone = null
@onready var bee = get_parent().get_parent() as Bee # I think this is bad but I dont care it works
@onready var bee : Bee = get_parent().get_parent() as Bee # I think this is bad but I dont care it works
var return_to_hive : bool = false
var moving_to : Vector2 = Vector2(0,0)
func enter(_msg := {}):
func enter(_msg : Dictionary = {}) -> void:
return_to_hive = false
## Get the next target location from the bee
if bee.just_gathering: