diff --git a/Autoload/Global.gd b/Autoload/Global.gd index af3b295..916c9a1 100644 --- a/Autoload/Global.gd +++ b/Autoload/Global.gd @@ -1,6 +1,6 @@ extends Node -const SPEED_LIMIT = 4 +const SPEED_LIMIT: int = 4 var Settings: Dictionary = { "filename": "save-0001", diff --git a/Stage/stage.gd b/Stage/stage.gd index d923d69..8da2ad9 100644 --- a/Stage/stage.gd +++ b/Stage/stage.gd @@ -1,6 +1,6 @@ extends Control -signal produce_items(item_id: String, amount: int) +#signal produce_items(item_id: String, amount: int) const OWNIVERSE_ITEM = preload("uid://d3xjfxwe3w16v") diff --git a/project.godot b/project.godot index 529a2a0..f926f9b 100644 --- a/project.godot +++ b/project.godot @@ -17,7 +17,7 @@ compatibility/default_parent_skeleton_in_mesh_instance_3d=true config/name="Owniverse" config/version="0.6.13" run/main_scene="uid://bv384dpmvjv8o" -config/features=PackedStringArray("4.6", "Mobile") +config/features=PackedStringArray("4.7", "Mobile") boot_splash/show_image=false config/icon="uid://do5teb1i7uiuw" config/size/borderless=true @@ -25,7 +25,7 @@ config/stretch_mode=0 [autoload] -Global="*uid://5xb12usvrifm" +Global="*uid://dojk16crca3cx" SaveManager="*uid://ul0srjc4gcgg" [display] diff --git a/world/evolution.gd b/world/evolution.gd new file mode 100644 index 0000000..de8bded --- /dev/null +++ b/world/evolution.gd @@ -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 + diff --git a/world/evolution.gd.uid b/world/evolution.gd.uid new file mode 100644 index 0000000..4224459 --- /dev/null +++ b/world/evolution.gd.uid @@ -0,0 +1 @@ +uid://mgnxt6kbf80n diff --git a/world/owniverse.gd b/world/owniverse.gd index e0687a5..5be3db1 100644 --- a/world/owniverse.gd +++ b/world/owniverse.gd @@ -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