Refactor formatting functions and improve item production logic; update UI components for better layout and usability
This commit is contained in:
+17
-15
@@ -23,10 +23,7 @@ func cycle(delta: float) -> void:
|
||||
_check_locked_items()
|
||||
|
||||
|
||||
func produce(item_id: String, amount: int) -> void:
|
||||
print("prdcng ", item_id, " ", amount)
|
||||
#if item_id == "S" or item_id == 'H':
|
||||
#entities[item_id].amount += 1
|
||||
func produce(item_id: String, amount: float) -> void:
|
||||
var entity: OwniverseEntity = entities[item_id]
|
||||
|
||||
var entity_transaction = {}
|
||||
@@ -38,10 +35,9 @@ func produce(item_id: String, amount: int) -> void:
|
||||
|
||||
entity_transaction[elem] = -amount * entity.cost[elem]
|
||||
|
||||
print("→: ", entity_transaction)
|
||||
for elem in entity_transaction:
|
||||
_process_enitity(elem, amount)
|
||||
_process_enitity(entity, amount)
|
||||
_process_enitity(elem, entity_transaction[elem])
|
||||
_process_enitity(item_id, amount)
|
||||
|
||||
|
||||
func automated_production(_delta: float) -> void:
|
||||
@@ -51,24 +47,30 @@ func automated_production(_delta: float) -> void:
|
||||
|
||||
|
||||
func get_available_to_produce(item_id: String) -> float:
|
||||
#print(item_id)
|
||||
return 1_000
|
||||
var entity: OwniverseEntity = entities[item_id]
|
||||
if entity.cost == {}: return 0
|
||||
var amount: float = 1E50
|
||||
for elem in entity.cost:
|
||||
amount = min(floorf(current_amount[elem] / entity.cost[elem]), amount)
|
||||
#print(elem, amount)
|
||||
return amount
|
||||
|
||||
# add to all lists
|
||||
func _process_enitity(entity: OwniverseEntity, amount: int) -> void:
|
||||
func _process_enitity(entity_id: String, amount: float) -> void:
|
||||
if amount == 0: return
|
||||
_count_amount(entity, amount)
|
||||
items_to_update[entity.id] = current_amount[entity.id]
|
||||
_count_amount(entity_id, amount)
|
||||
items_to_update[entity_id] = current_amount[entity_id]
|
||||
|
||||
|
||||
func _count_amount(entity: OwniverseEntity, amount: int) -> void:
|
||||
current_amount[entity.id] += amount
|
||||
func _count_amount(entity_id: String, amount: float) -> void:
|
||||
current_amount[entity_id] += amount
|
||||
var entity: OwniverseEntity = entities[entity_id]
|
||||
if entity.group_as != "":
|
||||
current_amount[entity.group_as] += amount
|
||||
|
||||
if amount <= 0: return
|
||||
|
||||
cumulative_amount[entity.id] += amount
|
||||
cumulative_amount[entity_id] += amount
|
||||
if entity.group_as != "":
|
||||
cumulative_amount[entity.group_as] += amount
|
||||
|
||||
|
||||
Reference in New Issue
Block a user