Add manual extractor resource transfers
This commit is contained in:
parent
e2d4297ee5
commit
db0e6a0ec2
7 changed files with 180 additions and 14 deletions
26
GameState.gd
26
GameState.gd
|
|
@ -896,6 +896,14 @@ func has_extractor_at(planet_key: String) -> bool:
|
|||
return false
|
||||
|
||||
|
||||
func extractor_index_at(planet_key: String) -> int:
|
||||
for i in range(extractors.size()):
|
||||
var extractor: Dictionary = extractors[i]
|
||||
if String(extractor.get("planet_id", extractor.get("planet_name", ""))) == planet_key:
|
||||
return i
|
||||
return -1
|
||||
|
||||
|
||||
signal extractor_added(planet_name: String)
|
||||
|
||||
|
||||
|
|
@ -924,6 +932,24 @@ func extractor_stock(index: int) -> int:
|
|||
return _extractor_inventory(extractor).amount(String(extractor.get("resource_type", RESOURCE_ORE)))
|
||||
|
||||
|
||||
func extractor_resource(index: int, resource_type: String) -> int:
|
||||
if index < 0 or index >= extractors.size():
|
||||
return 0
|
||||
return _extractor_inventory(extractors[index]).amount(resource_type)
|
||||
|
||||
|
||||
func transfer_resource_to_extractor(index: int, resource_type: String, amount: int) -> int:
|
||||
if index < 0 or index >= extractors.size():
|
||||
return 0
|
||||
return fleet_inventory.transfer_to(_extractor_inventory(extractors[index]), resource_type, amount)
|
||||
|
||||
|
||||
func transfer_resource_from_extractor(index: int, resource_type: String, amount: int) -> int:
|
||||
if index < 0 or index >= extractors.size():
|
||||
return 0
|
||||
return _extractor_inventory(extractors[index]).transfer_to(fleet_inventory, resource_type, amount)
|
||||
|
||||
|
||||
func _extractor_inventory(extractor: Dictionary) -> RefCounted:
|
||||
var inventory: RefCounted = extractor.get("inventory") as RefCounted
|
||||
if inventory == null:
|
||||
|
|
|
|||
Loading…
Reference in a new issue