Add action buttons and related functionality; refactor production logic and update entity definitions
This commit is contained in:
+34
-8
@@ -12,6 +12,7 @@ var entities: Dictionary[String, OwniverseEntity] = {}
|
||||
var items_to_update: Dictionary[String, float] = {}
|
||||
|
||||
var cumulative_amount: Dictionary[String, float] = {}
|
||||
var current_amount: Dictionary[String, float] = {}
|
||||
|
||||
var auto_production: Array = []
|
||||
var locked_entities: Array = []
|
||||
@@ -23,12 +24,24 @@ func cycle(delta: float) -> void:
|
||||
|
||||
|
||||
func produce(item_id: String, amount: int) -> void:
|
||||
print("prdcng ", item_id, " ", amount)
|
||||
#if item_id == "S" or item_id == 'H':
|
||||
#entities[item_id].amount += 1
|
||||
entities[item_id].amount += amount
|
||||
var entity: OwniverseEntity = entities[item_id]
|
||||
_process_enitity(entity, amount)
|
||||
|
||||
var entity_transaction = {}
|
||||
|
||||
for elem in entity.cost:
|
||||
if current_amount[elem] < amount * entity.cost[elem]:
|
||||
return
|
||||
if entity.cost[elem] == 0: continue
|
||||
|
||||
entity_transaction[elem] = -amount * entity.cost[elem]
|
||||
|
||||
print("→: ", entity_transaction)
|
||||
for elem in entity_transaction:
|
||||
_process_enitity(elem, amount)
|
||||
_process_enitity(entity, amount)
|
||||
|
||||
|
||||
func automated_production(_delta: float) -> void:
|
||||
@@ -37,14 +50,24 @@ func automated_production(_delta: float) -> void:
|
||||
var amount_to_produce = int(entity.amount * entity.product_per_year_amount * _delta)
|
||||
|
||||
|
||||
func get_available_to_produce(item_id: String) -> float:
|
||||
#print(item_id)
|
||||
return 1_000
|
||||
|
||||
# add to all lists
|
||||
func _process_enitity(entity: OwniverseEntity, amount: int) -> void:
|
||||
_count_cumulative(entity, amount)
|
||||
if amount == 0: return
|
||||
_count_amount(entity, amount)
|
||||
items_to_update[entity.id] = current_amount[entity.id]
|
||||
|
||||
|
||||
func _count_amount(entity: OwniverseEntity, amount: int) -> void:
|
||||
current_amount[entity.id] += amount
|
||||
if entity.group_as != "":
|
||||
current_amount[entity.group_as] += amount
|
||||
|
||||
items_to_update[entity.id] = entity.amount
|
||||
|
||||
|
||||
func _count_cumulative(entity: OwniverseEntity, amount: int) -> void:
|
||||
if amount <= 0: return
|
||||
|
||||
cumulative_amount[entity.id] += amount
|
||||
if entity.group_as != "":
|
||||
cumulative_amount[entity.group_as] += amount
|
||||
@@ -69,8 +92,11 @@ func init_enitities() -> void:
|
||||
entity.init_entity(Global.OwniverseEntities[entity_id])
|
||||
entities[entity_id] = entity
|
||||
|
||||
current_amount[entity_id] = 0
|
||||
cumulative_amount[entity_id] = 0
|
||||
cumulative_amount[entity.group_as] = 0
|
||||
if entity.group_as != "":
|
||||
current_amount[entity.group_as] = 0
|
||||
cumulative_amount[entity.group_as] = 0
|
||||
|
||||
if entity.unlock != {}:
|
||||
locked_entities.append(entity)
|
||||
|
||||
+16
-6
@@ -16,6 +16,7 @@
|
||||
[ext_resource type="FontFile" uid="uid://d3k1ddvv0rmhs" path="res://fonts/Roboto_Condensed/RobotoCondensed-Light.ttf" id="14_o7xkw"]
|
||||
[ext_resource type="FontFile" uid="uid://8s0fv3gfj317" path="res://fonts/Roboto_Condensed/RobotoCondensed-BoldItalic.ttf" id="15_bfrib"]
|
||||
[ext_resource type="FontFile" uid="uid://derqj4pbwtae6" path="res://fonts/Roboto_Condensed/RobotoCondensed-Italic.ttf" id="16_mip0j"]
|
||||
[ext_resource type="PackedScene" uid="uid://dwneq2qq5p8ek" path="res://ui/actions/actions.tscn" id="17_ifjjt"]
|
||||
[ext_resource type="Texture2D" uid="uid://i43jaaejvh5f" path="res://ui/indicators/energy/energy.png" id="17_l6135"]
|
||||
[ext_resource type="Texture2D" uid="uid://bef36h52n7lxb" path="res://ui/indicators/energy/border-energy.png" id="18_uvuuk"]
|
||||
[ext_resource type="Texture2D" uid="uid://blq0anccuu387" path="res://ui/pages/resources.en.png" id="19_an6vj"]
|
||||
@@ -41,7 +42,14 @@
|
||||
[ext_resource type="Texture2D" uid="uid://bwqmmmg6w7dho" path="res://ui/indicators/trends/trend_icon_4.png" id="39_jms70"]
|
||||
[ext_resource type="Texture2D" uid="uid://4tpbmpe6tbk0" path="res://ui/indicators/trends/trend_bar5.png" id="40_50rdj"]
|
||||
[ext_resource type="Texture2D" uid="uid://cnf3ml5gj2cvl" path="res://ui/indicators/trends/trend_icon_5.png" id="41_mi6gc"]
|
||||
[ext_resource type="Script" uid="uid://xte4iwvipeve" path="res://command_processor.gd" id="42_1s1fv"]
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_behgl"]
|
||||
script/source = "extends Node
|
||||
|
||||
func print_smth(smth: String):
|
||||
pass
|
||||
print(smth)
|
||||
"
|
||||
|
||||
[node name="World" type="Node2D" unique_id=1392592456]
|
||||
|
||||
@@ -493,6 +501,9 @@ layout_mode = 2
|
||||
custom_minimum_size = Vector2(1080, 1024)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Actions" parent="Stage/StageRows/PageScroller/HBoxContainer/StarPage" unique_id=503388208 instance=ExtResource("17_ifjjt")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="StructurePage" type="VBoxContainer" parent="Stage/StageRows/PageScroller/HBoxContainer" unique_id=435979853]
|
||||
layout_mode = 2
|
||||
|
||||
@@ -627,6 +638,9 @@ layout_mode = 2
|
||||
custom_minimum_size = Vector2(1080, 1024)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Actions" parent="Stage/StageRows/PageScroller/HBoxContainer/StructurePage" unique_id=1391835556 instance=ExtResource("17_ifjjt")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="LifePage" type="VBoxContainer" parent="Stage/StageRows/PageScroller/HBoxContainer" unique_id=1519563846]
|
||||
layout_mode = 2
|
||||
|
||||
@@ -825,16 +839,12 @@ offset_bottom = 1024.0
|
||||
[node name="Border" parent="Stage/StageRows" unique_id=145801370 instance=ExtResource("12_58wjt")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="Stage/StageRows" unique_id=1880020851]
|
||||
custom_minimum_size = Vector2(0, 184)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ItemAmountUpdate" type="Timer" parent="Stage" unique_id=1953928024]
|
||||
wait_time = 0.2
|
||||
autostart = true
|
||||
|
||||
[node name="CommandProcessor" type="Node" parent="." unique_id=2069361293]
|
||||
script = ExtResource("42_1s1fv")
|
||||
script = SubResource("GDScript_behgl")
|
||||
|
||||
[connection signal="timeout" from="Background/Timer" to="Background" method="randomize_parallax"]
|
||||
[connection signal="pressed" from="Stage/StageRows/TopMenu/BurgerButton" to="Stage" method="_on_topmenu_button_pressed" binds= ["Burger"]]
|
||||
|
||||
Reference in New Issue
Block a user