embrace static typing
authorEduardo <[email protected]>
Sun, 18 Feb 2024 01:28:03 +0000 (02:28 +0100)
committerEduardo <[email protected]>
Sun, 18 Feb 2024 01:28:03 +0000 (02:28 +0100)
enemies/base_enemy.gd
levels/ui.gd
menus/main_menu/MainMenu.gd
menus/pause/Pause.gd
player/Camera3D.gd
player/Player.gd

index 4df2b35661c5ca40cc8f4e2ba43ae4b4d5b690a9..a15bc9b19e15a8a40c732dfe661a32d4c1507d97 100644 (file)
@@ -9,7 +9,7 @@ extends CharacterBody3D
 @onready var pivot := $Pivot
 
 
-func _physics_process(delta):
+func _physics_process(delta) -> void:
        var distance_to_player := global_position.distance_to(player.global_position)
 
        if player.get_meta("noise") > noise_threshold:
@@ -31,7 +31,7 @@ func _physics_process(delta):
                rotate_y(deg_to_rad(pivot.rotation.y * turn_speed))
 
 
-func can_see_player():
+func can_see_player() -> bool:
        var space_state = get_world_3d().get_direct_space_state()
        var params = PhysicsRayQueryParameters3D.new()
        params.from = global_transform.origin + Vector3.UP
index 2a6eb66bc509d11823fe1db5951763616eb05c2e..db4653a6f0aa3f62c7147e226b6038dd483247e4 100644 (file)
@@ -20,7 +20,7 @@ func _ready() -> void:
        player.connect("recharge_battery", _on_recharge_battery_command)
 
 
-func _on_object_detected(ob: Object):
+func _on_object_detected(ob: Object) -> void:
        if !ob:
                actionTextLabel.set_text("")
 
@@ -37,19 +37,19 @@ func _on_object_detected(ob: Object):
                actionTextLabel.set_text(ob.name)
 
 
-func _on_recharge_battery_command():
+func _on_recharge_battery_command() -> void:
        battery = 100
        batteryLabel.set_text(format_battery_text(battery))
 
 
 # each 1 seconds
-func _on_timer_1_timeout():
+func _on_timer_1_timeout() -> void:
        battery = set_battery_percentage(battery)
        batteryLabel.set_text(format_battery_text(battery))
 
 
 # each 0.25 seconds
-func _on_timer_0_25_timeout():
+func _on_timer_0_25_timeout() -> void:
        timeLabel.set_text(set_rand_timer(timeLabel.get_text()))
 
 
index e08984f5e68d70398f1eb7ce718ffe267a7f0023..8701158f8e0acc7e959c45bf67a5a3985331b2c3 100644 (file)
@@ -1,32 +1,33 @@
 extends Control
 
-@export var playBtnSscene : String
-@export var settingsBtnScene : String
-@export var creditsBtnScene : String
+@export var playBtnSscene: String
+@export var settingsBtnScene: String
+@export var creditsBtnScene: String
 
 @onready var fade_out_options = SceneManager.create_options()
 @onready var fade_in_options = SceneManager.create_options()
 @onready var general_options = SceneManager.create_general_options()
 
+
 # Called when the node enters the scene tree for the first time.
-func _ready():
+func _ready() -> void:
        SceneManager.process_mode = Node.PROCESS_MODE_ALWAYS
        SceneManager.validate_scene(playBtnSscene)
        SceneManager.validate_scene(settingsBtnScene)
        SceneManager.validate_scene(creditsBtnScene)
 
 
-func _on_play_button_pressed():
+func _on_play_button_pressed() -> void:
        SceneManager.change_scene(playBtnSscene, fade_out_options, fade_in_options, general_options)
 
 
-func _on_settings_button_pressed():
+func _on_settings_button_pressed() -> void:
        SceneManager.change_scene(settingsBtnScene, fade_out_options, fade_in_options, general_options)
 
 
-func _on_credits_button_pressed():
+func _on_credits_button_pressed() -> void:
        SceneManager.change_scene(creditsBtnScene, fade_out_options, fade_in_options, general_options)
 
 
-func _on_exit_button_pressed():
+func _on_exit_button_pressed() -> void:
        get_tree().quit()
index ff44267f51cb1e507efbef34ad5280d5c208f90f..8d820cc3d77144da982a7cf35e29e1c1c35a17df 100644 (file)
@@ -1,18 +1,19 @@
 extends Control
 
-@export var settingsBtnScene : String
-@export var exitBtnScene : String
+@export var settingsBtnScene: String
+@export var exitBtnScene: String
 
 @onready var fade_out_options = SceneManager.create_options()
 @onready var fade_in_options = SceneManager.create_options()
 @onready var general_options = SceneManager.create_general_options()
 
-func _init():
+
+func _init() -> void:
        SceneManager.validate_scene(settingsBtnScene)
        SceneManager.validate_scene(exitBtnScene)
 
 
-func _input(event):
+func _input(event) -> void:
        if event.is_action_pressed("ui_cancel"):
                print(get_tree().paused)
                if not get_tree().paused:
@@ -21,22 +22,22 @@ func _input(event):
                        unpause()
 
 
-func _on_unpause_button_pressed():
+func _on_unpause_button_pressed() -> void:
        unpause()
 
 
-func _on_exit_button_pressed():
+func _on_exit_button_pressed() -> void:
        get_tree().paused = false
        SceneManager.change_scene(exitBtnScene, fade_out_options, fade_in_options, general_options)
 
 
-func pause():
+func pause() -> void:
        get_tree().paused = true
        Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
        show()
 
 
-func unpause():
+func unpause() -> void:
        hide()
        Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
        get_tree().paused = false
index bbafc3f521d3a36cf617da58c489c19bf6660750..8a39c16fc01914ba4f0e8bfc464cb199c99823bb 100644 (file)
@@ -16,14 +16,14 @@ var pitch: float = 0.0
 
 
 # Called when the node enters the scene tree for the first time.
-func _ready():
+func _ready() -> void:
        yaw = 0.0
        pitch = 0.0
 
        Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
 
 
-func _input(event):
+func _input(event) -> void:
        # release the mouse on esc
        if event.is_action_pressed("ui_cancel"):
                Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
@@ -49,7 +49,7 @@ func _input(event):
 
 
 # Called every frame. 'delta' is the elapsed time since the previous frame.
-func _process(delta):
+func _process(delta) -> void:
        if Input.is_action_pressed("ui_up"):
                translate(position - global_basis * Vector3(0, 0, 1) * delta * flyspeed * .01)
        if Input.is_action_pressed("ui_down"):
@@ -62,7 +62,7 @@ func _process(delta):
        change_object_detected_status(ray.get_collider())
 
 
-func change_object_detected_status(ob: Object):
+func change_object_detected_status(ob: Object) -> void:
        var new_object_status := false
        if ob:  # is not null
                new_object_status = true
index 8d93bd6061892ebab499aba04c1f8719ea9e25a2..3967dae52b6b12d7e8d08f1623671357af2ae551 100644 (file)
@@ -33,7 +33,7 @@ func _ready() -> void:
 
 
 # Called every frame. 'delta' is the elapsed time since the previous frame.
-func _physics_process(delta):
+func _physics_process(delta) -> void:
        var direction := Vector3.ZERO
        var speed_mod: float = 1
        var noise_mod: float = 1
@@ -96,12 +96,12 @@ func _physics_process(delta):
 
 
 # each second
-func _on_timer_timeout():
+func _on_timer_timeout() -> void:
        noise = clamp(noise - 1, 0, 9)
        set_meta("noise", noise)
        print(noise)
 
 
 # whenever the detection changes it emits an object (or null if nothing detected)
-func _on_object_detected(ob: Object):
+func _on_object_detected(ob: Object) -> void:
        object_detected = ob