diff --git a/UserContext.tscn b/UserContext.tscn new file mode 100644 index 0000000..f64eba6 --- /dev/null +++ b/UserContext.tscn @@ -0,0 +1,6 @@ +[gd_scene format=3 uid="uid://0a08ucta58lp"] + +[ext_resource type="Script" uid="uid://cl24d6o0rj78f" path="res://user_context.gd" id="1_1x84n"] + +[node name="UserContext" type="Node" unique_id=1649918931] +script = ExtResource("1_1x84n") diff --git a/currency/currency.gd b/currency/currency.gd index fcc6f6c..cfaa12a 100644 --- a/currency/currency.gd +++ b/currency/currency.gd @@ -3,3 +3,4 @@ class_name Currency @export var name: String @export var production: Array[Production] +@export_multiline var description = "no description of currency" diff --git a/currency/inanimate/fertilizer.tres b/currency/inanimate/fertilizer.tres new file mode 100644 index 0000000..c86587c --- /dev/null +++ b/currency/inanimate/fertilizer.tres @@ -0,0 +1,9 @@ +[gd_resource type="Resource" script_class="InanimateCurrency" format=3 uid="uid://y4ssn47oa8tm"] + +[ext_resource type="Script" uid="uid://dddyxbkq0ienn" path="res://currency/production.gd" id="1_2mm5k"] +[ext_resource type="Script" uid="uid://cthcf4w1il4h8" path="res://currency/inanimate_currency.gd" id="2_e2hgv"] + +[resource] +script = ExtResource("2_e2hgv") +name = "Fertilizer" +metadata/_custom_type_script = "uid://b3tqa2kc2bu0p" diff --git a/currency/production/human_production_shared_1.tres b/currency/production/human_production_shared_1.tres new file mode 100644 index 0000000..f2910d9 --- /dev/null +++ b/currency/production/human_production_shared_1.tres @@ -0,0 +1,10 @@ +[gd_resource type="Resource" script_class="Production" format=3 uid="uid://boshkhnywnk27"] + +[ext_resource type="Script" uid="uid://dddyxbkq0ienn" path="res://currency/production.gd" id="1_mn5kr"] +[ext_resource type="Resource" uid="uid://ervsee7ku1i2" path="res://currency/inanimate/bread.tres" id="1_q30nv"] + +[resource] +script = ExtResource("1_mn5kr") +currency = ExtResource("1_q30nv") +amount = -1 +metadata/_custom_type_script = "uid://dddyxbkq0ienn" diff --git a/currency/production/human_production_shared_2.tres b/currency/production/human_production_shared_2.tres new file mode 100644 index 0000000..d76bde5 --- /dev/null +++ b/currency/production/human_production_shared_2.tres @@ -0,0 +1,10 @@ +[gd_resource type="Resource" script_class="Production" format=3 uid="uid://mgb7y1r3eapq"] + +[ext_resource type="Resource" uid="uid://y4ssn47oa8tm" path="res://currency/inanimate/fertilizer.tres" id="1_yms1a"] +[ext_resource type="Script" uid="uid://dddyxbkq0ienn" path="res://currency/production.gd" id="2_ww73s"] + +[resource] +script = ExtResource("2_ww73s") +currency = ExtResource("1_yms1a") +amount = 1 +metadata/_custom_type_script = "uid://dddyxbkq0ienn" diff --git a/currency/sentient/archer.tres b/currency/sentient/archer.tres index d4d2f5d..bb9e87d 100644 --- a/currency/sentient/archer.tres +++ b/currency/sentient/archer.tres @@ -2,8 +2,11 @@ [ext_resource type="Script" uid="uid://hcvynq5fjypj" path="res://currency/sentient_currency.gd" id="1_e7gnr"] [ext_resource type="Script" uid="uid://dddyxbkq0ienn" path="res://currency/production.gd" id="1_m37xt"] +[ext_resource type="Resource" uid="uid://boshkhnywnk27" path="res://currency/production/human_production_shared_1.tres" id="2_b0duy"] +[ext_resource type="Resource" uid="uid://mgb7y1r3eapq" path="res://currency/production/human_production_shared_2.tres" id="3_k672a"] [resource] script = ExtResource("1_e7gnr") name = "Archer" +production = Array[ExtResource("1_m37xt")]([ExtResource("2_b0duy"), ExtResource("3_k672a")]) metadata/_custom_type_script = "uid://hcvynq5fjypj" diff --git a/currency/sentient/calvary.tres b/currency/sentient/calvary.tres index 5a5928b..721567f 100644 --- a/currency/sentient/calvary.tres +++ b/currency/sentient/calvary.tres @@ -2,8 +2,11 @@ [ext_resource type="Script" uid="uid://dddyxbkq0ienn" path="res://currency/production.gd" id="1_cnnt2"] [ext_resource type="Script" uid="uid://hcvynq5fjypj" path="res://currency/sentient_currency.gd" id="1_o1w50"] +[ext_resource type="Resource" uid="uid://boshkhnywnk27" path="res://currency/production/human_production_shared_1.tres" id="2_hqcau"] +[ext_resource type="Resource" uid="uid://mgb7y1r3eapq" path="res://currency/production/human_production_shared_2.tres" id="3_lyu7q"] [resource] script = ExtResource("1_o1w50") name = "Calvary" +production = Array[ExtResource("1_cnnt2")]([ExtResource("2_hqcau"), ExtResource("3_lyu7q")]) metadata/_custom_type_script = "uid://hcvynq5fjypj" diff --git a/currency/sentient/doctor.tres b/currency/sentient/doctor.tres index d9814ad..ebf27bc 100644 --- a/currency/sentient/doctor.tres +++ b/currency/sentient/doctor.tres @@ -2,8 +2,11 @@ [ext_resource type="Script" uid="uid://hcvynq5fjypj" path="res://currency/sentient_currency.gd" id="1_8u0th"] [ext_resource type="Script" uid="uid://dddyxbkq0ienn" path="res://currency/production.gd" id="1_ohece"] +[ext_resource type="Resource" uid="uid://boshkhnywnk27" path="res://currency/production/human_production_shared_1.tres" id="2_u3n2t"] +[ext_resource type="Resource" uid="uid://mgb7y1r3eapq" path="res://currency/production/human_production_shared_2.tres" id="3_yv5d2"] [resource] script = ExtResource("1_8u0th") name = "Doctor" +production = Array[ExtResource("1_ohece")]([ExtResource("2_u3n2t"), ExtResource("3_yv5d2")]) metadata/_custom_type_script = "uid://hcvynq5fjypj" diff --git a/currency/sentient/drunk.tres b/currency/sentient/drunk.tres index adfa44f..9c713ce 100644 --- a/currency/sentient/drunk.tres +++ b/currency/sentient/drunk.tres @@ -1,9 +1,12 @@ [gd_resource type="Resource" script_class="SentientCurrency" format=3 uid="uid://dv834343s36af"] [ext_resource type="Script" uid="uid://dddyxbkq0ienn" path="res://currency/production.gd" id="1_b07i1"] +[ext_resource type="Resource" uid="uid://boshkhnywnk27" path="res://currency/production/human_production_shared_1.tres" id="2_0dvy8"] [ext_resource type="Script" uid="uid://hcvynq5fjypj" path="res://currency/sentient_currency.gd" id="2_j265y"] +[ext_resource type="Resource" uid="uid://mgb7y1r3eapq" path="res://currency/production/human_production_shared_2.tres" id="3_0dvy8"] [resource] script = ExtResource("2_j265y") name = "Drunk" +production = Array[ExtResource("1_b07i1")]([ExtResource("2_0dvy8"), ExtResource("3_0dvy8")]) metadata/_custom_type_script = "uid://hcvynq5fjypj" diff --git a/currency/sentient/farmer.tres b/currency/sentient/farmer.tres index 041d176..e18e84d 100644 --- a/currency/sentient/farmer.tres +++ b/currency/sentient/farmer.tres @@ -2,8 +2,11 @@ [ext_resource type="Script" uid="uid://dddyxbkq0ienn" path="res://currency/production.gd" id="1_35xhy"] [ext_resource type="Script" uid="uid://hcvynq5fjypj" path="res://currency/sentient_currency.gd" id="1_kipvp"] +[ext_resource type="Resource" uid="uid://boshkhnywnk27" path="res://currency/production/human_production_shared_1.tres" id="2_jkjll"] +[ext_resource type="Resource" uid="uid://mgb7y1r3eapq" path="res://currency/production/human_production_shared_2.tres" id="3_kfqfp"] [resource] script = ExtResource("1_kipvp") name = "Farmer" +production = Array[ExtResource("1_35xhy")]([ExtResource("2_jkjll"), ExtResource("3_kfqfp")]) metadata/_custom_type_script = "uid://hcvynq5fjypj" diff --git a/currency/sentient/kings_guard.tres b/currency/sentient/kings_guard.tres index a317fad..1fa6401 100644 --- a/currency/sentient/kings_guard.tres +++ b/currency/sentient/kings_guard.tres @@ -2,8 +2,11 @@ [ext_resource type="Script" uid="uid://dddyxbkq0ienn" path="res://currency/production.gd" id="1_f1fuf"] [ext_resource type="Script" uid="uid://hcvynq5fjypj" path="res://currency/sentient_currency.gd" id="1_y7sat"] +[ext_resource type="Resource" uid="uid://boshkhnywnk27" path="res://currency/production/human_production_shared_1.tres" id="2_s3h3i"] +[ext_resource type="Resource" uid="uid://mgb7y1r3eapq" path="res://currency/production/human_production_shared_2.tres" id="3_3jtdd"] [resource] script = ExtResource("1_y7sat") name = "King Guard" +production = Array[ExtResource("1_f1fuf")]([ExtResource("2_s3h3i"), ExtResource("3_3jtdd")]) metadata/_custom_type_script = "uid://hcvynq5fjypj" diff --git a/currency/sentient/knight.tres b/currency/sentient/knight.tres new file mode 100644 index 0000000..a949688 --- /dev/null +++ b/currency/sentient/knight.tres @@ -0,0 +1,12 @@ +[gd_resource type="Resource" script_class="SentientCurrency" format=3 uid="uid://ihsvxienxbeu"] + +[ext_resource type="Script" uid="uid://dddyxbkq0ienn" path="res://currency/production.gd" id="1_626vc"] +[ext_resource type="Resource" uid="uid://boshkhnywnk27" path="res://currency/production/human_production_shared_1.tres" id="2_sa77c"] +[ext_resource type="Resource" uid="uid://mgb7y1r3eapq" path="res://currency/production/human_production_shared_2.tres" id="3_xhy5h"] +[ext_resource type="Script" uid="uid://hcvynq5fjypj" path="res://currency/sentient_currency.gd" id="4_7d8n3"] + +[resource] +script = ExtResource("4_7d8n3") +name = "Knight" +production = Array[ExtResource("1_626vc")]([ExtResource("2_sa77c"), ExtResource("3_xhy5h")]) +metadata/_custom_type_script = "uid://hcvynq5fjypj" diff --git a/currency/sentient/lover.tres b/currency/sentient/lover.tres index 716ea77..57837c0 100644 --- a/currency/sentient/lover.tres +++ b/currency/sentient/lover.tres @@ -2,8 +2,11 @@ [ext_resource type="Script" uid="uid://dddyxbkq0ienn" path="res://currency/production.gd" id="1_8hvx0"] [ext_resource type="Script" uid="uid://hcvynq5fjypj" path="res://currency/sentient_currency.gd" id="1_qvvhd"] +[ext_resource type="Resource" uid="uid://boshkhnywnk27" path="res://currency/production/human_production_shared_1.tres" id="2_xggvw"] +[ext_resource type="Resource" uid="uid://mgb7y1r3eapq" path="res://currency/production/human_production_shared_2.tres" id="3_8a0mj"] [resource] script = ExtResource("1_qvvhd") name = "Lover" +production = Array[ExtResource("1_8hvx0")]([ExtResource("2_xggvw"), ExtResource("3_8a0mj")]) metadata/_custom_type_script = "uid://hcvynq5fjypj" diff --git a/currency/sentient/mercenary.tres b/currency/sentient/mercenary.tres index 7c96784..3c31dc9 100644 --- a/currency/sentient/mercenary.tres +++ b/currency/sentient/mercenary.tres @@ -2,8 +2,11 @@ [ext_resource type="Script" uid="uid://dddyxbkq0ienn" path="res://currency/production.gd" id="1_81xhi"] [ext_resource type="Script" uid="uid://hcvynq5fjypj" path="res://currency/sentient_currency.gd" id="1_m8i4c"] +[ext_resource type="Resource" uid="uid://boshkhnywnk27" path="res://currency/production/human_production_shared_1.tres" id="2_x1puw"] +[ext_resource type="Resource" uid="uid://mgb7y1r3eapq" path="res://currency/production/human_production_shared_2.tres" id="3_yveov"] [resource] script = ExtResource("1_m8i4c") name = "Mercenary" +production = Array[ExtResource("1_81xhi")]([ExtResource("2_x1puw"), ExtResource("3_yveov")]) metadata/_custom_type_script = "uid://hcvynq5fjypj" diff --git a/currency/sentient/messenger.tres b/currency/sentient/messenger.tres index 7bc1462..5526c2a 100644 --- a/currency/sentient/messenger.tres +++ b/currency/sentient/messenger.tres @@ -2,8 +2,11 @@ [ext_resource type="Script" uid="uid://hcvynq5fjypj" path="res://currency/sentient_currency.gd" id="1_egwdx"] [ext_resource type="Script" uid="uid://dddyxbkq0ienn" path="res://currency/production.gd" id="1_iy37t"] +[ext_resource type="Resource" uid="uid://boshkhnywnk27" path="res://currency/production/human_production_shared_1.tres" id="2_demtt"] +[ext_resource type="Resource" uid="uid://mgb7y1r3eapq" path="res://currency/production/human_production_shared_2.tres" id="3_mxgt6"] [resource] script = ExtResource("1_egwdx") name = "Messenger" +production = Array[ExtResource("1_iy37t")]([ExtResource("2_demtt"), ExtResource("3_mxgt6")]) metadata/_custom_type_script = "uid://hcvynq5fjypj" diff --git a/currency/sentient/miner.tres b/currency/sentient/miner.tres index c106653..9f62129 100644 --- a/currency/sentient/miner.tres +++ b/currency/sentient/miner.tres @@ -2,8 +2,11 @@ [ext_resource type="Script" uid="uid://hcvynq5fjypj" path="res://currency/sentient_currency.gd" id="1_phc4h"] [ext_resource type="Script" uid="uid://dddyxbkq0ienn" path="res://currency/production.gd" id="1_yn73g"] +[ext_resource type="Resource" uid="uid://boshkhnywnk27" path="res://currency/production/human_production_shared_1.tres" id="2_8h62s"] +[ext_resource type="Resource" uid="uid://mgb7y1r3eapq" path="res://currency/production/human_production_shared_2.tres" id="3_2kvuq"] [resource] script = ExtResource("1_phc4h") name = "Miner" +production = Array[ExtResource("1_yn73g")]([ExtResource("2_8h62s"), ExtResource("3_2kvuq")]) metadata/_custom_type_script = "uid://hcvynq5fjypj" diff --git a/currency/sentient/royalty.tres b/currency/sentient/royalty.tres index c57f4cc..f345124 100644 --- a/currency/sentient/royalty.tres +++ b/currency/sentient/royalty.tres @@ -2,8 +2,11 @@ [ext_resource type="Script" uid="uid://dddyxbkq0ienn" path="res://currency/production.gd" id="1_acsld"] [ext_resource type="Script" uid="uid://hcvynq5fjypj" path="res://currency/sentient_currency.gd" id="1_jo5ux"] +[ext_resource type="Resource" uid="uid://boshkhnywnk27" path="res://currency/production/human_production_shared_1.tres" id="2_40pnt"] +[ext_resource type="Resource" uid="uid://mgb7y1r3eapq" path="res://currency/production/human_production_shared_2.tres" id="3_xy04b"] [resource] script = ExtResource("1_jo5ux") name = "Royalty" +production = Array[ExtResource("1_acsld")]([ExtResource("2_40pnt"), ExtResource("3_xy04b")]) metadata/_custom_type_script = "uid://hcvynq5fjypj" diff --git a/currency/sentient/spy.tres b/currency/sentient/spy.tres index 9ab32e6..126edbb 100644 --- a/currency/sentient/spy.tres +++ b/currency/sentient/spy.tres @@ -2,8 +2,11 @@ [ext_resource type="Script" uid="uid://hcvynq5fjypj" path="res://currency/sentient_currency.gd" id="1_ou6ev"] [ext_resource type="Script" uid="uid://dddyxbkq0ienn" path="res://currency/production.gd" id="1_wync1"] +[ext_resource type="Resource" uid="uid://boshkhnywnk27" path="res://currency/production/human_production_shared_1.tres" id="2_30yvg"] +[ext_resource type="Resource" uid="uid://mgb7y1r3eapq" path="res://currency/production/human_production_shared_2.tres" id="3_pvkom"] [resource] script = ExtResource("1_ou6ev") name = "Spy" +production = Array[ExtResource("1_wync1")]([ExtResource("2_30yvg"), ExtResource("3_pvkom")]) metadata/_custom_type_script = "uid://hcvynq5fjypj" diff --git a/currency/sentient/town_crier.tres b/currency/sentient/town_crier.tres index ef2ee3c..be7b687 100644 --- a/currency/sentient/town_crier.tres +++ b/currency/sentient/town_crier.tres @@ -2,8 +2,11 @@ [ext_resource type="Script" uid="uid://dddyxbkq0ienn" path="res://currency/production.gd" id="1_0qymk"] [ext_resource type="Script" uid="uid://hcvynq5fjypj" path="res://currency/sentient_currency.gd" id="1_an3bl"] +[ext_resource type="Resource" uid="uid://boshkhnywnk27" path="res://currency/production/human_production_shared_1.tres" id="2_0o8mq"] +[ext_resource type="Resource" uid="uid://mgb7y1r3eapq" path="res://currency/production/human_production_shared_2.tres" id="3_xknsl"] [resource] script = ExtResource("1_an3bl") name = "Town Crier" +production = Array[ExtResource("1_0qymk")]([ExtResource("2_0o8mq"), ExtResource("3_xknsl")]) metadata/_custom_type_script = "uid://hcvynq5fjypj" diff --git a/currency/sentient/wizard.tres b/currency/sentient/wizard.tres index c175f26..2086768 100644 --- a/currency/sentient/wizard.tres +++ b/currency/sentient/wizard.tres @@ -2,8 +2,11 @@ [ext_resource type="Script" uid="uid://dddyxbkq0ienn" path="res://currency/production.gd" id="1_05kyk"] [ext_resource type="Script" uid="uid://hcvynq5fjypj" path="res://currency/sentient_currency.gd" id="1_tds6s"] +[ext_resource type="Resource" uid="uid://boshkhnywnk27" path="res://currency/production/human_production_shared_1.tres" id="2_ud150"] +[ext_resource type="Resource" uid="uid://mgb7y1r3eapq" path="res://currency/production/human_production_shared_2.tres" id="3_mp872"] [resource] script = ExtResource("1_tds6s") name = "Wizard" +production = Array[ExtResource("1_05kyk")]([ExtResource("2_ud150"), ExtResource("3_mp872")]) metadata/_custom_type_script = "uid://hcvynq5fjypj" diff --git a/economy.gd b/economy.gd index 1f79d8d..0049d46 100644 --- a/economy.gd +++ b/economy.gd @@ -6,6 +6,7 @@ signal production_log(producer: Currency, p: Production) @export var members: Array func get_currency(c: Currency) -> Production: + sync_currency.call_deferred() for p in currencies: if c == p.currency: return p @@ -13,24 +14,36 @@ func get_currency(c: Currency) -> Production: p.currency = c p.amount = 0 currencies.append(p) - productions_update.emit.call_deferred(currencies) return p func sync_currency(): - #for p in currencies: - #if p.amount == 0: - #currencies.remove_at() - productions_update.emit.call_deferred(currencies) + var did_remove := true + while did_remove: + did_remove = false + for i in range(len(currencies)): + var p: Production = currencies[i] + if p.amount == 0: + currencies.remove_at(i) + did_remove = true + break + productions_update.emit(currencies) func produce(producer: Currency, production: Production): - production_log.emit.call_deferred(producer, production) + sync_currency.call_deferred() + var c := get_currency(production.currency) + c.amount += production.amount func simulate(): productions_update.emit.call_deferred(currencies) + for c in currencies: + for p in c.currency.production: + var pp := Production.new() + pp.currency = p.currency + pp.amount = c.amount * p.amount + produce(c.currency, pp) + # TODO remove this + production_log.emit.call_deferred(c.currency, pp) func _ready() -> void: simulate() - for i in range(100): - produce(preload("res://currency/sentient/chicken.tres"), currencies[0]) - produce(preload("res://currency/sentient/chicken.tres"), currencies[2]) diff --git a/economy.tscn b/economy.tscn index 06760a1..af02a24 100644 --- a/economy.tscn +++ b/economy.tscn @@ -2,28 +2,63 @@ [ext_resource type="Script" uid="uid://i14prh1jocdd" path="res://economy.gd" id="1_csm0v"] [ext_resource type="Script" uid="uid://dddyxbkq0ienn" path="res://currency/production.gd" id="2_tljx8"] -[ext_resource type="Resource" uid="uid://dmctedq3pav0t" path="res://currency/inanimate/corpse.tres" id="3_4ctyq"] -[ext_resource type="Resource" uid="uid://rdrcyvuvrp2m" path="res://currency/sentient/pig.tres" id="4_d7dul"] -[ext_resource type="Resource" uid="uid://dfj4jwdmff6bu" path="res://currency/sentient/spy.tres" id="5_4ctyq"] +[ext_resource type="Resource" uid="uid://dk3wsnr3ku7ka" path="res://currency/sentient/royalty.tres" id="3_ms0h4"] +[ext_resource type="Resource" uid="uid://cwpk5e2exbgcr" path="res://currency/sentient/kings_guard.tres" id="4_17ik3"] +[ext_resource type="Resource" uid="uid://ervsee7ku1i2" path="res://currency/inanimate/bread.tres" id="4_yg0ra"] +[ext_resource type="Resource" uid="uid://b8b6yr444ecdk" path="res://currency/inanimate/water.tres" id="5_17ik3"] +[ext_resource type="Resource" uid="uid://chsv8oeajty8j" path="res://currency/sentient/town_crier.tres" id="6_2k4vk"] +[ext_resource type="Resource" uid="uid://dn0c1pfq04obw" path="res://currency/sentient/farmer.tres" id="7_isn2b"] +[ext_resource type="Resource" uid="uid://ihsvxienxbeu" path="res://currency/sentient/knight.tres" id="8_qb8iw"] +[ext_resource type="Resource" uid="uid://l8osuuxl7exe" path="res://currency/sentient/archer.tres" id="9_4ywr4"] -[sub_resource type="Resource" id="Resource_jd86c"] +[sub_resource type="Resource" id="Resource_g3220"] script = ExtResource("2_tljx8") -currency = ExtResource("3_4ctyq") -amount = 10 +currency = ExtResource("3_ms0h4") +amount = 1 metadata/_custom_type_script = "uid://dddyxbkq0ienn" -[sub_resource type="Resource" id="Resource_jd7cj"] +[sub_resource type="Resource" id="Resource_bb1uu"] script = ExtResource("2_tljx8") -currency = ExtResource("4_d7dul") -amount = 3 +currency = ExtResource("4_17ik3") +amount = 4 metadata/_custom_type_script = "uid://dddyxbkq0ienn" -[sub_resource type="Resource" id="Resource_ei3g1"] +[sub_resource type="Resource" id="Resource_vw3jp"] script = ExtResource("2_tljx8") -currency = ExtResource("5_4ctyq") -amount = -4 +currency = ExtResource("4_yg0ra") +amount = 1000 +metadata/_custom_type_script = "uid://dddyxbkq0ienn" + +[sub_resource type="Resource" id="Resource_xg8li"] +script = ExtResource("2_tljx8") +currency = ExtResource("5_17ik3") +amount = 5000 +metadata/_custom_type_script = "uid://dddyxbkq0ienn" + +[sub_resource type="Resource" id="Resource_f6kxb"] +script = ExtResource("2_tljx8") +currency = ExtResource("6_2k4vk") +amount = 1 +metadata/_custom_type_script = "uid://dddyxbkq0ienn" + +[sub_resource type="Resource" id="Resource_6u4g3"] +script = ExtResource("2_tljx8") +currency = ExtResource("7_isn2b") +amount = 50 +metadata/_custom_type_script = "uid://dddyxbkq0ienn" + +[sub_resource type="Resource" id="Resource_aqv3t"] +script = ExtResource("2_tljx8") +currency = ExtResource("8_qb8iw") +amount = 25 +metadata/_custom_type_script = "uid://dddyxbkq0ienn" + +[sub_resource type="Resource" id="Resource_g2km3"] +script = ExtResource("2_tljx8") +currency = ExtResource("9_4ywr4") +amount = 15 metadata/_custom_type_script = "uid://dddyxbkq0ienn" [node name="Economy" type="Node" unique_id=1950923383] script = ExtResource("1_csm0v") -currencies = Array[ExtResource("2_tljx8")]([SubResource("Resource_jd86c"), SubResource("Resource_jd7cj"), SubResource("Resource_ei3g1")]) +currencies = Array[ExtResource("2_tljx8")]([SubResource("Resource_g3220"), SubResource("Resource_bb1uu"), SubResource("Resource_vw3jp"), SubResource("Resource_xg8li"), SubResource("Resource_f6kxb"), SubResource("Resource_6u4g3"), SubResource("Resource_aqv3t"), SubResource("Resource_g2km3")]) diff --git a/gui/currency_inspector_panel.gd b/gui/currency_inspector_panel.gd new file mode 100644 index 0000000..f3e5eb5 --- /dev/null +++ b/gui/currency_inspector_panel.gd @@ -0,0 +1,28 @@ +extends Control + +var currency: Currency = null + +func _ready() -> void: + UserContext.currency_inspect.connect(currency_inspect) + update() + +func currency_inspect(c: Currency): + currency = c + update() + +func update(): + if currency == null: + visible = false + return + visible = true + %InspectedCurrency.text = currency.name + %CurrencyDescription.text = currency.description + for child in %ProductionsList.get_children(): + child.queue_free() + for production in currency.production: + var display := preload("res://gui/production_display.tscn").instantiate() + display.production = production + %ProductionsList.add_child(display) + +func _on_close_button_pressed() -> void: + visible = false diff --git a/gui/currency_inspector_panel.gd.uid b/gui/currency_inspector_panel.gd.uid new file mode 100644 index 0000000..aeb9710 --- /dev/null +++ b/gui/currency_inspector_panel.gd.uid @@ -0,0 +1 @@ +uid://bkptc7j6c1r7p diff --git a/gui/currency_inspector_panel.tscn b/gui/currency_inspector_panel.tscn new file mode 100644 index 0000000..eff7f63 --- /dev/null +++ b/gui/currency_inspector_panel.tscn @@ -0,0 +1,76 @@ +[gd_scene format=3 uid="uid://75htlmk51oo"] + +[ext_resource type="Script" uid="uid://bkptc7j6c1r7p" path="res://gui/currency_inspector_panel.gd" id="1_tj5vo"] + +[sub_resource type="Gradient" id="Gradient_jd7cj"] + +[sub_resource type="GradientTexture2D" id="GradientTexture2D_y6nab"] +gradient = SubResource("Gradient_jd7cj") + +[sub_resource type="CanvasTexture" id="CanvasTexture_4sc8i"] +diffuse_texture = SubResource("GradientTexture2D_y6nab") + +[node name="CurrencyInspectorPanel" type="Control" unique_id=169191981] +custom_minimum_size = Vector2(0, 100) +layout_mode = 3 +anchors_preset = 11 +anchor_left = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -188.0 +offset_right = -188.0 +grow_horizontal = 0 +grow_vertical = 2 +script = ExtResource("1_tj5vo") + +[node name="VBoxContainer" type="VBoxContainer" parent="." unique_id=362599487] +custom_minimum_size = Vector2(400, 0) +custom_maximum_size = Vector2(400, -1) +layout_mode = 1 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -253.0 +offset_right = 47.0 +offset_bottom = 149.0 +grow_horizontal = 2 + +[node name="InspectedCurrency" type="Label" parent="VBoxContainer" unique_id=1206438498] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 0 +text = "< Selected Currency >" + +[node name="CurrrencyImage" type="TextureRect" parent="VBoxContainer" unique_id=1066520786] +unique_name_in_owner = true +layout_mode = 2 +texture = SubResource("CanvasTexture_4sc8i") + +[node name="CurrencyDescription" type="Label" parent="VBoxContainer" unique_id=543173020] +unique_name_in_owner = true +layout_mode = 2 +text = "< Description of currency >" + +[node name="word" type="Label" parent="VBoxContainer" unique_id=835011658] +layout_mode = 2 +text = "Production:" + +[node name="ProductionsList" type="VBoxContainer" parent="VBoxContainer" unique_id=1042554009] +unique_name_in_owner = true +layout_mode = 2 + +[node name="CloseButton" type="Button" parent="." unique_id=404008755] +layout_mode = 1 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = -44.5 +offset_top = -31.0 +offset_right = 44.5 +grow_horizontal = 2 +grow_vertical = 0 +text = "close" + +[connection signal="pressed" from="CloseButton" to="." method="_on_close_button_pressed"] diff --git a/gui/production_display.gd b/gui/production_display.gd index b618ed0..f0274b6 100644 --- a/gui/production_display.gd +++ b/gui/production_display.gd @@ -5,3 +5,7 @@ extends Control func _ready() -> void: %Name.text = production.currency.name %Amount.text = str(production.amount) + + +func _on_inspect_button_pressed() -> void: + UserContext.currency_inspect.emit(production.currency) diff --git a/gui/production_display.tscn b/gui/production_display.tscn index 0255058..beb0ed5 100644 --- a/gui/production_display.tscn +++ b/gui/production_display.tscn @@ -16,3 +16,8 @@ unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 8 text = "0" + +[node name="InspectButton" type="Button" parent="." unique_id=54175511] +layout_mode = 2 + +[connection signal="pressed" from="InspectButton" to="." method="_on_inspect_button_pressed"] diff --git a/project.godot b/project.godot index f6a5bdf..d7b67f0 100644 --- a/project.godot +++ b/project.godot @@ -18,6 +18,7 @@ config/features=PackedStringArray("4.7") Dialogic="*uid://ds2q0uclmolvu" Economy="*uid://dnpioqaes87yb" Random="*uid://cu3n7igqstbxi" +UserContext="*uid://0a08ucta58lp" [dialogic] diff --git a/test/test_economy.gd b/test/test_economy.gd index e07a0bf..9f2363f 100644 --- a/test/test_economy.gd +++ b/test/test_economy.gd @@ -1 +1,11 @@ extends Control + + +func _on_get_cow_pressed() -> void: + var p := Economy.get_currency(preload("res://currency/sentient/cow.tres")) + p.amount += 1 + + + +func _on_run_simulate_pressed() -> void: + Economy.simulate() diff --git a/test/test_economy.tscn b/test/test_economy.tscn index ba5af42..6f1faf1 100644 --- a/test/test_economy.tscn +++ b/test/test_economy.tscn @@ -3,10 +3,15 @@ [ext_resource type="Script" uid="uid://6438cbkn3fhm" path="res://test/test_economy.gd" id="1_s48qe"] [ext_resource type="PackedScene" uid="uid://desvyn6e28oar" path="res://gui/production_chart.tscn" id="2_jd86c"] [ext_resource type="PackedScene" uid="uid://cxv743rjsolk5" path="res://gui/production_ledger.tscn" id="3_jd7cj"] +[ext_resource type="PackedScene" uid="uid://75htlmk51oo" path="res://gui/currency_inspector_panel.tscn" id="4_7ya5o"] [node name="TestEconomy" type="Control" unique_id=629898212] layout_mode = 3 -anchors_preset = 0 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 script = ExtResource("1_s48qe") [node name="ProductionChart" parent="." unique_id=1301678172 instance=ExtResource("2_jd86c")] @@ -22,3 +27,36 @@ offset_bottom = 346.0 [node name="ProductionChart2" parent="ScrollContainer" unique_id=1698529519 instance=ExtResource("3_jd7cj")] layout_mode = 2 + +[node name="Control" type="Control" parent="." unique_id=641955392] +layout_mode = 1 +anchors_preset = 6 +anchor_left = 1.0 +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 0.5 +offset_left = -145.0 +offset_top = -17.0 +offset_right = -105.0 +offset_bottom = 23.0 +grow_horizontal = 0 +grow_vertical = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="Control" unique_id=74649172] +layout_mode = 0 +offset_right = 40.0 +offset_bottom = 40.0 + +[node name="GetCow" type="Button" parent="Control/VBoxContainer" unique_id=1886603156] +layout_mode = 2 +text = "Get cow" + +[node name="RunSimulate" type="Button" parent="Control/VBoxContainer" unique_id=158790493] +layout_mode = 2 +text = "Run simulate" + +[node name="CurrencyInspectorPanel" parent="." unique_id=169191981 instance=ExtResource("4_7ya5o")] +layout_mode = 1 + +[connection signal="pressed" from="Control/VBoxContainer/GetCow" to="." method="_on_get_cow_pressed"] +[connection signal="pressed" from="Control/VBoxContainer/RunSimulate" to="." method="_on_run_simulate_pressed"] diff --git a/user_context.gd b/user_context.gd new file mode 100644 index 0000000..4c505fe --- /dev/null +++ b/user_context.gd @@ -0,0 +1,4 @@ +extends Node + +@warning_ignore("unused_signal") +signal currency_inspect(c: Currency) diff --git a/user_context.gd.uid b/user_context.gd.uid new file mode 100644 index 0000000..c098cd9 --- /dev/null +++ b/user_context.gd.uid @@ -0,0 +1 @@ +uid://cl24d6o0rj78f