Skip to content

Commit

Permalink
[wip] handle game_save in Game2D
Browse files Browse the repository at this point in the history
  • Loading branch information
theludovyc committed Jan 2, 2025
1 parent 6488126 commit 360c4e5
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion theLudovyc/Game2D.gd
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ func _ready():
the_storage.add_resource(Resources.Types.Textile, 16)

elif SaveHelper.load_saved_file_name() == OK:
if SaveHelper.last_loaded_data.is_empty():
return

var game_data:Dictionary = SaveHelper.last_loaded_data.get("Game", {})

if game_data.is_empty():
return

population = game_data["population"]

the_storage.load_storage_save()
the_bank.load_bank_save()
the_factory.load_factory_save()
Expand Down Expand Up @@ -247,7 +257,10 @@ func _on_EventBus_ask_demolish_current_building():
event_bus.send_current_building_demolished.emit()

func _on_PauseMenu_ask_to_save() -> void:
var dicoToSave := {}
var dicoToSave := {
"Game": {"population":population}
}

dicoToSave.merge(the_storage.get_storage_save())
dicoToSave.merge(the_bank.get_bank_save())
dicoToSave.merge(the_factory.get_factory_save())
Expand Down

0 comments on commit 360c4e5

Please sign in to comment.