two buildings working!

created research building base
This commit is contained in:
2024-03-14 07:28:18 -05:00
parent 4f0f97b91d
commit 82675b6ed2
11 changed files with 51 additions and 25 deletions

View File

@@ -0,0 +1,17 @@
extends Node
var _resource_buildings = {}
var _storage_buildings = {}
func add_resource_building(res: GameResource, building: BuildingBase) -> void:
if not _resource_buildings.has(res):
_resource_buildings[res] = []
_resource_buildings[res].append(building)
func add_storage_building(res: GameResource, building: BuildingBase) -> void:
if not _storage_buildings.has(res):
_storage_buildings[res] = []
_storage_buildings[res].append(building)
func get_storage_count_for_resource(res: GameResource) -> int:
return 0 if not _storage_buildings.has(res) else _storage_buildings[res].size()

View File

@@ -13,7 +13,7 @@ func _on_gained_resource(res: GameResource) -> void:
func pickup(resource: GameResource) -> void:
if not resources.has(resource):
resources[resource] = 0
var pickup_amount = min(resource.pickup_value, resource.storage_max - resources[resource])
var pickup_amount = min(resource.pickup_value, get_resource_limit(resource) - resources[resource])
if pickup_amount > 0:
resources[resource] += pickup_amount
var changed_resources := {
@@ -34,6 +34,9 @@ func use_resources(cost: Dictionary) -> void:
resources[res] -= cost[res]
changed_resources[res] = -cost[res]
changed_resource.emit(ResourceChangedSignal.new(changed_resources))
func get_resource_limit(resource: GameResource) -> int:
return resource.storage_max * (1 + BuildingManager.get_storage_count_for_resource(resource))
#func _on_timer_timeout() -> void:
#var corrupted_resources := Grid.get_corrupted_resources()