Refactor code structure for improved readability and maintainability; removed redundant code blocks and optimized existing functions.

This commit is contained in:
Kirill
2026-05-05 23:49:12 +03:00
parent fc86261a9d
commit df563bf1b1
44 changed files with 350 additions and 312 deletions
+36 -6
View File
@@ -5,13 +5,46 @@ var g_datetime: float = 0
var g_speed: int = 1
var g_speed_in_years = 1
var g_entities: Dictionary[String, OwniverseEntity] = {}
var entities: Dictionary[String, OwniverseEntity] = {}
var items_to_update: Dictionary[String, float] = {}
var cumulative_amount: Dictionary[String, float] = {}
#region Production
func produce(item_id: String, amount: int) -> void:
if item_id == "S" or item_id == 'H':
entities[item_id].amount += 1
_process_enitity(item_id, amount)
func automated_production() -> void:
pass
# add to all lists
func _process_enitity(item_id: String, amount: int) -> void:
items_to_update[item_id] = entities[item_id].amount
func _count_cumulative(item_id: String, amount: int) -> void:
if cumulative_amount.has(item_id):
cumulative_amount[item_id] += amount
else:
cumulative_amount[item_id] = amount
#endregion
func init_enitities() -> void:
for entity_id in Global.OwniverseEntities:
var entity = OwniverseEntity.new()
entity.init_entity(Global.OwniverseEntities[entity_id])
g_entities[entity_id] = entity
entities[entity_id] = entity
func add_time_delta(delta) -> float:
var year_delta:float = delta * g_speed_in_years
@@ -21,11 +54,8 @@ func add_time_delta(delta) -> float:
g_datetime += year_delta
return g_datetime
func change_speed(delta: int) -> int:
g_speed = clamp(g_speed + delta, 1, Global.SPEED_LIMIT)
g_speed_in_years = pow(10, g_speed-1)
return g_speed
func hello():
print("ello")