Refactor: update SPEED_LIMIT type, comment out signal, and enhance evolution logic
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
extends Node
|
||||
|
||||
const SPEED_LIMIT = 4
|
||||
const SPEED_LIMIT: int = 4
|
||||
|
||||
var Settings: Dictionary = {
|
||||
"filename": "save-0001",
|
||||
|
||||
+1
-1
@@ -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")
|
||||
|
||||
|
||||
+2
-2
@@ -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]
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
uid://mgnxt6kbf80n
|
||||
+17
-10
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user