Skip to content

Commit

Permalink
Embrace the void
Browse files Browse the repository at this point in the history
* Fix Godot warnings about missing `-> void` and other types
* Silence warnings about unused parameters in abstract methods and other intentional behavior
  • Loading branch information
ShinryakuTako committed Aug 27, 2024
1 parent e0847a4 commit 5b36135
Show file tree
Hide file tree
Showing 18 changed files with 28 additions and 20 deletions.
6 changes: 4 additions & 2 deletions AutoLoad/Global.gd
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ func saveGame() -> void: # NOTE: Cannot be `static` because of `self.process_mod
# TBD: Is it necessary to `await` & pause to ensure a reliable & deterministic save?

GlobalOverlay.createTemporaryLabel("Saving...") # NOTE: Don't `await` here or it will wait for the animation to finish.
await Debug.printLog("Saving state → " + Global.saveFilePath)
@warning_ignore("redundant_await")
await Debug.printLog("Saving state → " + Global.saveFilePath) # TBD: await or not?

var sceneTree := get_tree()
self.process_mode = Node.PROCESS_MODE_ALWAYS
Expand All @@ -134,7 +135,8 @@ func loadGame() -> void: # NOTE: Cannot be `static` because of `self.process_mo
# TBD: Is it necessary to `await` & pause to ensure a reliable & deterministic load?

GlobalOverlay.createTemporaryLabel("Loading...") # NOTE: Don't `await` here or it will wait for the animation to finish.
await Debug.printLog("Loading state ← " + Global.saveFilePath)
@warning_ignore("redundant_await")
await Debug.printLog("Loading state ← " + Global.saveFilePath) # TBD: await or not?

var sceneTree := get_tree()
self.process_mode = Node.PROCESS_MODE_ALWAYS
Expand Down
2 changes: 1 addition & 1 deletion Components/Control/ThrustControlComponent.gd
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func _ready() -> void:
printWarning("Missing parentEntity.body: " + parentEntity.logName)


func _physics_process(delta: float):
func _physics_process(delta: float) -> void:
if not isEnabled: return
var input: float = playerInputComponent.thrustInput

Expand Down
4 changes: 2 additions & 2 deletions Components/Control/TileBasedControlComponent.gd
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ func _input(event: InputEvent) -> void:
GlobalInput.Actions.moveUp, GlobalInput.Actions.moveDown)

if shouldAllowDiagonals:
self.recentInputVector = Vector2i(signf(inputVectorFloat.x), signf(inputVectorFloat.y)) # IGNORE Godot Warning; float to int conversion is obvious.
else: # Fractional axis values will get zeroed in the conversion to integers
self.recentInputVector = Vector2i(int(signf(inputVectorFloat.x)), int(signf(inputVectorFloat.y))) # IGNORE: Godot Warning; `float` to `int` conversion is obvious.
else: # Fractional axis values will get zeroed in the conversion to integers.
self.recentInputVector = Vector2i(inputVectorFloat)

move()
Expand Down
2 changes: 2 additions & 0 deletions Components/Gameplay/TextInteractionComponent.gd
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func _ready() -> void:
updateLabel()


@warning_ignore("unused_parameter")
func performInteraction(interactorEntity: Entity, interactionControlComponent: InteractionControlComponent) -> void:
displayNextText()

Expand All @@ -42,6 +43,7 @@ func displayNextText() -> void:
updateLabel()


@warning_ignore("unused_parameter")
func applyTextFromArray(indexOverride: int = self.currentTextIndex) -> void:
self.label = self.textStrings[currentTextIndex]

Expand Down
4 changes: 2 additions & 2 deletions Components/Gameplay/ZoneComponent.gd
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func updateCurrentZones() -> int:
return currentZones.size()


func onAreaEntered(area: Area2D):
func onAreaEntered(area: Area2D) -> void:
# Is the area a member of the "zones" group?
if not isEnabled or not area.is_in_group(Global.Groups.zones): return

Expand All @@ -78,7 +78,7 @@ func onAreaEntered(area: Area2D):
didEnterZone.emit(area)


func onAreaExited(area: Area2D):
func onAreaExited(area: Area2D) -> void:
# Is the area a member of the "zones" group?
if not isEnabled or not area.is_in_group(Global.Groups.zones): return

Expand Down
2 changes: 1 addition & 1 deletion Components/Movement/MouseTrackingComponent.gd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extends Component
#endregion


func _physics_process(delta: float):
func _physics_process(delta: float) -> void:
if not isEnabled: return
if shouldRepositionImmediately:
parentEntity.global_position = parentEntity.get_global_mouse_position()
Expand Down
2 changes: 1 addition & 1 deletion Components/Movement/PositionClampComponent.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ extends Component
@export var maximum: Vector2 = Vector2(500, 500)


func _process(delta: float):
func _process(_delta: float) -> void:
parentEntity.position.clamp(minimum, maximum)
print("SCRIPT ONLY WORKING") # DEBUG
2 changes: 1 addition & 1 deletion Components/Movement/RelativePathMovementComponent.gd
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func _ready() -> void:
willStartMove.emit()


func _physics_process(delta: float):
func _physics_process(delta: float) -> void:
if (not isEnabled) or isInDelay or hasNoMoreMoves or self.currentVector.is_zero_approx(): return

# The node's position after applying the current movement vector.
Expand Down
2 changes: 1 addition & 1 deletion Components/Movement/SpinComponent.gd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func _ready() -> void:
self.parent = get_parent()


func _physics_process(delta: float):
func _physics_process(delta: float) -> void:

if isPaused: return

Expand Down
3 changes: 2 additions & 1 deletion Components/Objects/PortalInteractionComponent.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ extends InteractionComponent
#endregion


func performInteraction(interactorEntity: Entity, interactionControlComponent: InteractionControlComponent):
@warning_ignore("unused_parameter")
func performInteraction(interactorEntity: Entity, interactionControlComponent: InteractionControlComponent) -> void:
interactorEntity.global_position = destinationNode.global_position
2 changes: 1 addition & 1 deletion Components/Physics/CharacterToRigidCollisionComponent.gd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extends CharacterBodyManipulatingComponentBase
#endregion


func _physics_process(delta: float) -> void:
func _physics_process(_delta: float) -> void:
for collisionIndex in body.get_slide_collision_count():
var collision: KinematicCollision2D = body.get_slide_collision(collisionIndex)
if collision.get_collider() is RigidBody2D:
Expand Down
4 changes: 2 additions & 2 deletions Components/Visual/CompassComponent.gd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extends Component
#endregion


func _process(delta: float):
func _process(delta: float) -> void:

var compass: Node2D

Expand All @@ -30,7 +30,7 @@ func _process(delta: float):
var targetPosition := nodeToTrack.global_position

if shouldDisappearWhenNear:
var distance = parentEntity.global_position.distance_to(targetPosition)
var distance: float = parentEntity.global_position.distance_to(targetPosition)

if distance < proximityDistance or is_equal_approx(distance, proximityDistance):
compass.visible = false
Expand Down
2 changes: 1 addition & 1 deletion Components/Visual/HealthVisualComponent.gd
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func connectToHealthComponent() -> void:
healthComponent.didIncrease.connect(self.onHealthComponent_healthChanged)


func onHealthComponent_healthChanged(difference: int):
func onHealthComponent_healthChanged(_difference: int) -> void:
var health: Stat = healthComponent.health

var red: float = 1.0 - (health.percentage / 100.0)
Expand Down
2 changes: 1 addition & 1 deletion Resources/Upgrade.gd
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const payloadDiscardMethodName: StringName = &"onUpgrade_willDiscard" ## The met

## This is the property that is ACTUALLY used to search for the required Stat, so that ANY instance of a particular Stat resource may be usable.
var costStatName: StringName:
get: return self.costStat.name if self.costStat else ""
get: return self.costStat.name if self.costStat else &""

## A list of costs for each [member level] of this upgrade. The first cost at array index 0 is the requirement for initially acquiring this upgrade.
## `cost[n]` == Level n+1 so `cost[1]` == Upgrade Level 2.
Expand Down
1 change: 1 addition & 0 deletions Scenes/Areas/PopulateArea.gd
Original file line number Diff line number Diff line change
Expand Up @@ -214,5 +214,6 @@ func clearAllNodes() -> void:

## A method for sublasses to override. Prepares newly spawned node with further game-specific logic.
## May suppress the creation of a newly spawned node by checking additional conditions and returning `false`.
@warning_ignore("unused_parameter")
func validateNewNode(newCopy: Node2D, parent: Node2D) -> bool:
return true
1 change: 1 addition & 0 deletions Scenes/Areas/SpawnArea.gd
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,6 @@ func spawn() -> Node2D:

## A method for sublasses to override. Prepares newly spawned node with further game-specific logic.
## May suppress the creation of a newly spawned node by checking additional conditions and returning `false`.
@warning_ignore("unused_parameter")
func validateNewNode(newSpawn: Node2D, parent: Node2D) -> bool:
return isEnabled
4 changes: 2 additions & 2 deletions Scenes/GameFrame/OptionsUI.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ extends Control
# TODO: @export var setting: UserSetting

# Called when the node enters the scene tree for the first time.
func _ready():
func _ready() -> void:
pass
# TODO: buildTestSettings()
#printInputList()
Expand All @@ -21,6 +21,6 @@ func _ready():
#settings.test = newSetting
#print(newSetting.currentValue)

func printInputList():
func printInputList() -> void:
for action: StringName in InputMap.get_actions():
print(action)
3 changes: 2 additions & 1 deletion Scenes/Launch/InitialScene.gd
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ func clearScenePlaceholder() -> void:
#endregion

func _ready() -> void:
await startLogoScene()
@warning_ignore("redundant_await")
await startLogoScene() # TBD: await or not?
startMainScene()


Expand Down

0 comments on commit 5b36135

Please sign in to comment.