More building work

This commit is contained in:
2024-03-13 09:57:10 -05:00
parent 4718108407
commit 4f0f97b91d
10 changed files with 43 additions and 31 deletions

View File

@@ -13,11 +13,13 @@ func _on_gained_resource(res: GameResource) -> void:
func pickup(resource: GameResource) -> void:
if not resources.has(resource):
resources[resource] = 0
resources[resource] += resource.pickup_value
var changed_resources := {
resource: resource.pickup_value
}
changed_resource.emit(ResourceChangedSignal.new(changed_resources))
var pickup_amount = min(resource.pickup_value, resource.storage_max - resources[resource])
if pickup_amount > 0:
resources[resource] += pickup_amount
var changed_resources := {
resource: pickup_amount
}
changed_resource.emit(ResourceChangedSignal.new(changed_resources))
func has_amount(res: GameResource, amount: int) -> bool:
return resources[res] >= amount if resources.has(res) else false