Skip to content

Commit

Permalink
Add 'not enough resources on construction' voice event, #83
Browse files Browse the repository at this point in the history
  • Loading branch information
Scony committed Dec 31, 2024
1 parent 616fb09 commit 97b5093
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
1 change: 1 addition & 0 deletions source/match/MatchSignals.gd
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ signal unit_deselected(unit)
signal unit_died(unit)
signal unit_production_started(unit_prototype, producer_unit)
signal not_enough_resources_for_production(player)
signal not_enough_resources_for_construction(player)
9 changes: 4 additions & 5 deletions source/match/players/human/StructurePlacementHandler.gd
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,11 @@ func _handle_lmb_down_event(_event):

func _handle_lmb_up_event(_event):
get_viewport().set_input_as_handled()
if _blueprint_position_is_valid():
var blueprint_position_validity = _calculate_blueprint_position_validity()
if blueprint_position_validity == BlueprintPositionValidity.VALID:
_finish_structure_placement()
elif blueprint_position_validity == BlueprintPositionValidity.NOT_ENOUGH_RESOURCES:
MatchSignals.not_enough_resources_for_construction.emit(_player)
_finish_blueprint_rotation()


Expand All @@ -84,10 +87,6 @@ func _structure_placement_started():
return _active_blueprint_node != null


func _blueprint_position_is_valid():
return _calculate_blueprint_position_validity() == BlueprintPositionValidity.VALID


func _blueprint_rotation_started():
return _blueprint_rotating == true

Expand Down
7 changes: 3 additions & 4 deletions source/match/players/human/VoiceNarratorController.gd
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ func _ready():
)
MatchSignals.unit_died.connect(_on_unit_died)
MatchSignals.unit_production_started.connect(_on_production_started)
MatchSignals.not_enough_resources_for_production.connect(
_on_not_enough_resources_for_production
)
MatchSignals.not_enough_resources_for_production.connect(_on_not_enough_resources)
MatchSignals.not_enough_resources_for_construction.connect(_on_not_enough_resources)


func _handle_event(event):
Expand All @@ -32,6 +31,6 @@ func _on_production_started(_unit_prototype, producer_unit):
_handle_event(Constants.Match.VoiceNarrator.Events.UNIT_PRODUCTION_STARTED)


func _on_not_enough_resources_for_production(player):
func _on_not_enough_resources(player):
if player == get_parent():
_handle_event(Constants.Match.VoiceNarrator.Events.NOT_ENOUGH_RESOURCES)

0 comments on commit 97b5093

Please sign in to comment.