Skip to content

Commit 3745c67

Browse files
committed
Show atmospheric carbon levels.
1 parent 4b13da4 commit 3745c67

File tree

17 files changed

+123
-23
lines changed

17 files changed

+123
-23
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
extends Node
2+
class_name CarbonComponent
3+
4+
@onready var view_model = CarbonViewModel.new()
5+
@export var time_component: TimeComponent
6+
7+
var carbon_level_ppm: float
8+
9+
func _ready():
10+
ViewModelRegistry.register(ViewModelRegistry.Keys.CARBON, view_model)
11+
time_component.on_new_month.connect(_handle_new_month)
12+
13+
func _handle_new_month(new_timestamp: float):
14+
# TODO: this is a large increase for testing. it should be based on the state of the world.
15+
set_carbon_in_atmosphere(carbon_level_ppm + 1)
16+
17+
func set_carbon_in_atmosphere(new_carbon_level_ppm: float):
18+
carbon_level_ppm = new_carbon_level_ppm
19+
view_model.set_carbon_in_atmosphere(carbon_level_ppm)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[gd_scene load_steps=2 format=3 uid="uid://bcq54x0laubvw"]
2+
3+
[ext_resource type="Script" path="res://entities/components/carbon_component.gd" id="1_aa2fy"]
4+
5+
[node name="CarbonComponent" type="Node"]
6+
script = ExtResource("1_aa2fy")

entities/components/temperature_component.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func _ready() -> void:
1717

1818
func _handle_new_day(new_timestamp: int) -> void:
1919
# TODO: this is a large increase for testing. it should be based on the state of the world.
20-
set_temperature_anomaly(temperature_anomaly_celsius + .01)
20+
set_temperature_anomaly(temperature_anomaly_celsius + .001)
2121

2222
func set_temperature_anomaly(new_temperature_anomaly_celsius: float) -> void:
2323
temperature_anomaly_celsius = new_temperature_anomaly_celsius

entities/time_component.gd renamed to entities/components/time_component.gd

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ class_name TimeComponent
88
@export var fast_speed: float = 3
99

1010
signal on_new_day (new_timestamp: int)
11+
signal on_new_month (new_timestamp: int)
1112

1213
var time_since_last_update: float = 0
1314
var time: float = Time.get_unix_time_from_system()
1415
var is_paused: bool = false
1516
var speed: float = default_speed
1617
var date_string_regex: RegEx
18+
var last_month: int
1719

1820
func _ready():
1921
date_string_regex = RegEx.new()
@@ -31,6 +33,11 @@ func _process(delta: float):
3133
time += 86400 # seconds in a day
3234
on_new_day.emit(time)
3335
view_model.set_time(time)
36+
var datetime_dict = Time.get_datetime_dict_from_unix_time(time)
37+
var current_month = datetime_dict.get("month")
38+
if last_month == Time.MONTH_DECEMBER and current_month == Time.MONTH_JANUARY || current_month > last_month:
39+
last_month = current_month
40+
on_new_month.emit(time)
3441

3542
func get_timestamp_from_date_string(date_string: String) -> int:
3643
var results = date_string_regex.search(date_string)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[gd_scene load_steps=2 format=3 uid="uid://b1x0140gst6wf"]
22

3-
[ext_resource type="Script" path="res://entities/time_component.gd" id="1_bhnnc"]
3+
[ext_resource type="Script" path="res://entities/components/time_component.gd" id="1_bhnnc"]
44

55
[node name="TimeComponent" type="Node2D"]
66
script = ExtResource("1_bhnnc")

entities/countries/country.gd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ enum Keys { USA }
55

66
@export var country_key: Keys
77
@export var sprite: Sprite2D
8+
@export var test: StringName
89
var selected_material: Material = preload("res://entities/countries/selected_country_material.tres")
910
var country_name: String
1011

locale/en.mo

103 Bytes
Binary file not shown.

locale/en.po

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,39 @@ msgstr ""
2222
msgid "COUNTRY_USA_NAME"
2323
msgstr "United States of America"
2424

25+
#: ui/widgets/top_app_bar.tscn
26+
msgid "ATMOSPHERE_CARBON_DESCRIPTION"
27+
msgstr "Atmospheric CO₂ Levels"
28+
29+
#: ui/widgets/top_app_bar.tscn
30+
msgid "CARBON_UNIT"
31+
msgstr "ppm"
32+
2533
#: ui/widgets/top_app_bar.tscn
2634
msgid "TEMPERATURE_ANOMALY_DESCRIPTION"
2735
msgstr "Temperature Anomaly"
2836

2937
#: ui/widgets/modal_loss.gd
3038
msgid "LOSSCONDITION_TIMEEXCEEDED_TEXT"
3139
msgstr ""
32-
"Humanity failed to achieve net-zero carbon emissions in time, leading "
33-
"to the worst effects of climate change being unavoidable. They include "
34-
"more frequent and intense weather events like hurricanes, wildfires, "
35-
"and floods. Additionally, biodiversity loss, food and water shortages, "
36-
"and economic instability will increasingly disrupt human life."
40+
"Humanity failed to achieve net-zero carbon emissions in time, leading to the "
41+
"worst effects of climate change being unavoidable. They include more "
42+
"frequent and intense weather events like hurricanes, wildfires, and floods. "
43+
"Additionally, biodiversity loss, food and water shortages, and economic "
44+
"instability will increasingly disrupt human life."
3745

3846
#: ui/widgets/modal_loss.gd
3947
msgid "LOSSCONDITION_TEMPERATUREEXCEEDED_TEXT"
4048
msgstr ""
41-
"The Earth has warmed to a level where the worst effects of climate "
42-
"change are becoming unavoidable. They include more frequent and intense "
43-
"weather events like hurricanes, wildfires, and floods. Additionally, "
44-
"biodiversity loss, food and water shortages, and economic instability "
45-
"will increasingly disrupt human life."
49+
"The Earth has warmed to a level where the worst effects of climate change "
50+
"are becoming unavoidable. They include more frequent and intense weather "
51+
"events like hurricanes, wildfires, and floods. Additionally, biodiversity "
52+
"loss, food and water shortages, and economic instability will increasingly "
53+
"disrupt human life."
4654

4755
#: ui/widgets/modal_loss.tscn
4856
msgid "LOSSMODAL_RESTART_TEXT"
4957
msgstr "Restart"
58+
59+
#~ msgid "ppm"
60+
#~ msgstr "ppm"

locale/tra.pot

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ msgstr ""
1818
msgid "COUNTRY_USA_NAME"
1919
msgstr ""
2020

21+
#: ui/widgets/top_app_bar.tscn
22+
msgid "ATMOSPHERE_CARBON_DESCRIPTION"
23+
msgstr ""
24+
25+
#: ui/widgets/top_app_bar.tscn
26+
msgid "CARBON_UNIT"
27+
msgstr ""
28+
2129
#: ui/widgets/top_app_bar.tscn
2230
msgid "TEMPERATURE_ANOMALY_DESCRIPTION"
2331
msgstr ""

0 commit comments

Comments
 (0)