This commit is contained in:
Kirill
2026-06-24 23:25:55 +03:00
parent 2d2979a1cf
commit b41ccdb659
8 changed files with 64 additions and 33 deletions
+45 -19
View File
@@ -17,12 +17,39 @@ var current_amount: Dictionary[String, float] = {}
var auto_production: Array = []
var locked_entities: Array = []
#region Production
var some_flag := true
func cycle(delta: float) -> void:
func cycle(year_delta: float) -> void:
# all owniverse activity should be called here
_auto_production(year_delta)
_entity_evolution(year_delta)
_check_locked_items()
#region object evolution
func _auto_production(year_delta: float) -> void:
var cycle_production = {"S": 0.0, "H": 0.0}
for entity: OwniverseEntity in auto_production:
if current_amount[entity.id] == 0:
continue
cycle_production[entity.product_per_year_type] += \
current_amount[entity.id] * entity.product_per_year_amount * year_delta
for item in cycle_production:
_count_amount(item, cycle_production[item])
func _entity_evolution(year_delta: float) -> void:
pass
#endregion
#region Production
func produce(item_id: String, amount: float) -> void:
var entity: OwniverseEntity = entities[item_id]
@@ -59,21 +86,23 @@ func get_available_to_produce(item_id: String) -> float:
func _process_enitity(entity_id: String, amount: float) -> void:
if amount == 0: return
_count_amount(entity_id, amount)
items_to_update[entity_id] = current_amount[entity_id]
func _count_amount(entity_id: String, amount: float) -> void:
if amount == 0: return
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
if amount < 0: return
cumulative_amount[entity_id] += amount
if entity.group_as != "":
cumulative_amount[entity.group_as] += amount
items_to_update[entity_id] = current_amount[entity_id]
func _check_locked_items() -> void:
for entity:OwniverseEntity in locked_entities:
@@ -88,6 +117,18 @@ func _check_locked_items() -> void:
#endregion
func add_time_delta(delta) -> float:
var year_delta: float = delta * g_speed_in_years
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 init_enitities() -> void:
for entity_id in Global.OwniverseEntities:
var entity = OwniverseEntity.new()
@@ -105,18 +146,3 @@ func init_enitities() -> void:
if entity.product_per_year_type != "":
auto_production.append(entity)
func add_time_delta(delta) -> float:
var year_delta: float = delta * g_speed_in_years
# all ownivewrse activity should be called here
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