Skip to content

Commit

Permalink
[wip] handle storage save
Browse files Browse the repository at this point in the history
  • Loading branch information
theludovyc committed Dec 30, 2024
1 parent fa89d94 commit 6d7c28b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions theLudovyc/Game2D.gd
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func _ready():
warehouse_pos = Vector2(building_data[1], building_data[2])


the_storage.load_storage_save()
the_bank.load_bank_save()
else:
# save cannot be loaded
Expand Down
14 changes: 14 additions & 0 deletions theLudovyc/TheStorage.gd
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,17 @@ func recover_building_construction(building_id: Buildings.Ids):

func get_storage_save() -> Dictionary:
return {"Storage":storage}

func load_storage_save() -> Error:
if SaveHelper.last_loaded_data.is_empty():
return FAILED

var storage_data:Dictionary = SaveHelper.last_loaded_data.get("Storage", {})

if storage_data.is_empty():
return FAILED

for resource_type_str:String in storage_data:
add_resource(resource_type_str.to_int(), storage_data[resource_type_str])

return OK

0 comments on commit 6d7c28b

Please sign in to comment.