Skip to content

Commit 4074983

Browse files
authored
State: Use Resource.emit_changed() not changed.emit() (#2367)
State: Use Resource.emit_changed() not changed.emit() These are almost completely equivalent, except when a resource is being loaded, but I believe emit_changed() is better practice.
1 parent eb07ffc commit 4074983

4 files changed

Lines changed: 10 additions & 10 deletions

File tree

scenes/globals/game_state/global_state.gd

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ signal helper_changed
3737
else:
3838
push_warning("Ignoring unknown inventory item type: %s" % type_name)
3939
inventory = items
40-
changed.emit()
40+
emit_changed()
4141

4242
## [Quest]s which the player has previously completed. Modify this with
4343
## [method set_quest_completed_state].
@@ -63,7 +63,7 @@ signal helper_changed
6363
push_warning("Ignoring unknown quest in save file: %s" % path)
6464
completed_quests = quests
6565
completed_quests_changed.emit()
66-
changed.emit()
66+
emit_changed()
6767

6868
## Global player state. During a quest, [member QuestState.player] should be
6969
## used instead. [GameState.player] always points to the correct instance.
@@ -82,15 +82,15 @@ func _validate_property(property: Dictionary) -> void:
8282
func add_collected_item(item: InventoryItem) -> void:
8383
inventory.append(item)
8484
item_collected.emit(item)
85-
changed.emit()
85+
emit_changed()
8686

8787

8888
## Remove all [InventoryItem]s from the [member inventory].
8989
func clear_inventory() -> void:
9090
for item: InventoryItem in inventory.duplicate():
9191
inventory.erase(item)
9292
item_consumed.emit(item)
93-
changed.emit()
93+
emit_changed()
9494

9595

9696
## Updates [member completed_quests] to include [param quest] if [param
@@ -101,12 +101,12 @@ func set_quest_completed_state(quest: Quest, is_completed: bool) -> void:
101101
if quest not in completed_quests:
102102
completed_quests.append(quest)
103103
completed_quests_changed.emit()
104-
changed.emit()
104+
emit_changed()
105105
else:
106106
while quest in completed_quests:
107107
completed_quests.erase(quest)
108108
completed_quests_changed.emit()
109-
changed.emit()
109+
emit_changed()
110110

111111

112112
## Obtain the help from a townie, for using it later in the game.

scenes/globals/game_state/per_scene_state.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ func set_lights_on(new_value: bool, immediate: bool = false) -> void:
4343

4444
func set_spawn_point(new_value: NodePath) -> void:
4545
spawn_point = new_value
46-
changed.emit()
46+
emit_changed()

scenes/globals/game_state/player_state.gd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ const MAX_LIVES := 2 ** 53
1313
@export_range(0, MAX_LIVES, 1) var lives: int = MAX_LIVES:
1414
set(value):
1515
lives = value
16-
changed.emit()
16+
emit_changed()
1717

1818
## Bitfield of elements of Enums.PlayerAbilities
1919
@export var abilities: int:
2020
set(value):
2121
if abilities != value:
2222
abilities = value
23-
changed.emit()
23+
emit_changed()
2424
abilities_changed.emit()
2525

2626

scenes/globals/game_state/quest_state.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@ func get_challenge_start_scene() -> String:
6262

6363
func set_challenge_start_scene(value: String) -> void:
6464
challenge_start_scene = ResourceUID.ensure_path(value)
65-
changed.emit()
65+
emit_changed()

0 commit comments

Comments
 (0)