Refactor: update SPEED_LIMIT type, comment out signal, and enhance evolution logic

This commit is contained in:
Kirill
2026-07-20 00:11:44 +03:00
parent a81359c1e6
commit f4524a7acc
6 changed files with 46 additions and 14 deletions
+24
View File
@@ -0,0 +1,24 @@
extends Node
class_name OwniverseEvolution
var batch_count: int = 40
var entity_batches = {}
var distribution: Dictionary[String, float] = {}
func update_distribution(_distribute_by: Dictionary[String, float]) -> void:
distribution = {}
var _total: float = 0
for id in _distribute_by:
if _distribute_by[id] != 0:
var _value: float = _distribute_by[id]
_total += _value
distribution[id] = _value
if _total == 0: return
for id in distribution:
distribution[id] /= _total
+1
View File
@@ -0,0 +1 @@
uid://mgnxt6kbf80n
+17 -10
View File
@@ -1,10 +1,12 @@
extends Node
class_name Owniverse
var evolution: OwniverseEvolution = OwniverseEvolution.new()
signal unlock_item(item_id: String)
var current_year: float = 0
var current_speed: float = 1
var current_speed: int = 1
var current_speed_in_years:float = 1
var entities: Dictionary[String, OwniverseEntity] = {}
@@ -31,21 +33,26 @@ func cycle(year_delta: float) -> void:
_check_locked_items()
#print(_get_distribution(current_amount))
#var v = _get_distribution(current_amount)
evolution.update_distribution(current_amount)
#for k in current_amount:
#if current_amount[k] != 0:
#print(k, "|", current_amount[k])
#region auto production and evolution
func _auto_production(year_delta: float) -> void:
var cycle_production = {"S": 0.0, "H": 0.0}
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] += \
_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])
for item in _cycle_production:
_count_amount(item, _cycle_production[item])
func _entity_evolution(year_delta: float) -> void:
@@ -140,8 +147,8 @@ func add_time_delta(delta) -> float:
return current_year
func change_speed(delta: int) -> float:
current_speed = clamp(current_speed + delta, 1, Global.SPEED_LIMIT)
func change_speed(delta: int) -> int:
current_speed = clampi(current_speed + delta, 1, Global.SPEED_LIMIT)
current_speed_in_years = pow(10, current_speed - 1)
return current_speed
@@ -210,6 +217,6 @@ func init_enitities() -> void:
#if entity.event_group != "":
#entity_event_groups.append(entity.id)
print(entity_groups)
print(entity_event_groups)
#print(entity_groups)
#print(entity_event_groups)
#endregion