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
+6 -1
View File
@@ -5,7 +5,7 @@
[ext_resource type="Script" uid="uid://iiva6x8uo0f2" path="res://stage/stage.gd" id="3_k83x5"]
[ext_resource type="Texture2D" uid="uid://5f80g4i46ycl" path="res://ui/topmenu/buttons/button.burger.normal.png" id="4_b8tmp"]
[ext_resource type="Texture2D" uid="uid://caia36a08wlqs" path="res://ui/topmenu/buttons/button.burger.pressed.png" id="5_en1oy"]
[ext_resource type="Texture2D" uid="uid://cjcchycx7biyl" path="res://ui/topmenu/time&speed/time_x.png" id="6_pfbnl"]
[ext_resource type="Texture2D" uid="uid://cjcchycx7biyl" path="res://ui/topmenu/time&speed/timex.png" id="6_pfbnl"]
[ext_resource type="FontFile" uid="uid://dtyi81a0phumr" path="res://fonts/Roboto_Condensed/RobotoCondensed-Bold.ttf" id="7_gwdna"]
[ext_resource type="Texture2D" uid="uid://davmv5mwt3mo1" path="res://ui/topmenu/time&speed/speed.png" id="8_h4vgh"]
[ext_resource type="Texture2D" uid="uid://cnjtnggw5ccq3" path="res://ui/topmenu/time&speed/time1.png" id="9_kvuv0"]
@@ -202,6 +202,7 @@ theme_override_constants/separation = 0
[node name="ForcePage" type="VBoxContainer" parent="Stage/StageRows/PageScroller/HBoxContainer" unique_id=71643627]
layout_mode = 2
theme_override_constants/separation = 0
[node name="PageHeader" type="HBoxContainer" parent="Stage/StageRows/PageScroller/HBoxContainer/ForcePage" unique_id=2102307933]
custom_minimum_size = Vector2(0, 128)
@@ -260,6 +261,7 @@ theme_override_styles/panel = SubResource("StyleBoxEmpty_ifjjt")
[node name="ResourcePage" type="VBoxContainer" parent="Stage/StageRows/PageScroller/HBoxContainer" unique_id=1417647206]
layout_mode = 2
theme_override_constants/separation = 0
[node name="ResourceHeader" type="HBoxContainer" parent="Stage/StageRows/PageScroller/HBoxContainer/ResourcePage" unique_id=1468901953]
custom_minimum_size = Vector2(0, 128)
@@ -411,6 +413,7 @@ theme_override_styles/panel = SubResource("StyleBoxEmpty_ifjjt")
[node name="StarPage" type="VBoxContainer" parent="Stage/StageRows/PageScroller/HBoxContainer" unique_id=270059674]
layout_mode = 2
theme_override_constants/separation = 0
[node name="StarHeader" type="HBoxContainer" parent="Stage/StageRows/PageScroller/HBoxContainer/StarPage" unique_id=1459928]
custom_minimum_size = Vector2(0, 128)
@@ -527,6 +530,7 @@ layout_mode = 2
[node name="StructurePage" type="VBoxContainer" parent="Stage/StageRows/PageScroller/HBoxContainer" unique_id=435979853]
layout_mode = 2
theme_override_constants/separation = 0
[node name="StructureHeader" type="HBoxContainer" parent="Stage/StageRows/PageScroller/HBoxContainer/StructurePage" unique_id=1291109226]
custom_minimum_size = Vector2(0, 128)
@@ -667,6 +671,7 @@ layout_mode = 2
[node name="LifePage" type="VBoxContainer" parent="Stage/StageRows/PageScroller/HBoxContainer" unique_id=1519563846]
layout_mode = 2
theme_override_constants/separation = 0
[node name="LifeHeader" type="HBoxContainer" parent="Stage/StageRows/PageScroller/HBoxContainer/LifePage" unique_id=1673431378]
custom_minimum_size = Vector2(0, 128)