Skip to content

Commit cda1350

Browse files
committed
Create an initial representation of temperature anomaly and display it in the app bar.
1 parent ac20e9a commit cda1350

File tree

14 files changed

+100
-41
lines changed

14 files changed

+100
-41
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
extends Node
2+
3+
@onready var view_model = TemperatureViewModel.new()
4+
5+
@export var time_component: TimeComponent
6+
7+
# TODO: Currently sourced from https://climate.nasa.gov/vital-signs/global-temperature/?intent=121.
8+
# This should be based on the actual start date of the game.
9+
var temperature_anomaly_celsius = 1.28
10+
11+
func _ready() -> void:
12+
ViewModelRegistry.register(ViewModelRegistry.Keys.TEMPERATURE, view_model)
13+
time_component.on_new_day.connect(_handle_new_day)
14+
15+
func _handle_new_day(new_temperature_anomaly: int) -> void:
16+
# TODO: this is a large increase for testing. it should be based on the state of the world.
17+
temperature_anomaly_celsius += .01
18+
view_model.set_temperature_anomaly(temperature_anomaly_celsius)
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://cxdm1p8x2yt7d"]
2+
3+
[ext_resource type="Script" path="res://entities/components/temperature_component.gd" id="1_gnlrf"]
4+
5+
[node name="TemperatureComponent" type="Node"]
6+
script = ExtResource("1_gnlrf")

entities/time_component.gd

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

10+
signal on_new_day (new_timestamp: int)
11+
1012
var time_since_last_update: float = 0
1113
var time: float = Time.get_unix_time_from_system()
1214
var is_paused: bool = false
@@ -24,6 +26,7 @@ func _process(delta: float):
2426
if time_since_last_update > (day_update_interval_seconds / speed):
2527
time_since_last_update = 0
2628
time += 86400 # seconds in a day
29+
on_new_day.emit(time)
2730
view_model.set_time(time)
2831

2932
func toggle_paused():

locale/en.mo

68 Bytes
Binary file not shown.

locale/en.po

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# LANGUAGE translation for project-evergreen for the following files:
22
# res://entities/countries/usa.gd
3+
# res://ui/widgets/top_app_bar.tscn
34
#
45
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
56
#
@@ -20,3 +21,7 @@ msgstr ""
2021
#: entities/countries/usa.gd
2122
msgid "COUNTRY_USA_NAME"
2223
msgstr "United States of America"
24+
25+
#: ui/widgets/top_app_bar.tscn
26+
msgid "TEMPERATURE_ANOMALY_DESCRIPTION"
27+
msgstr "Temperature Anomaly"

locale/countries.pot renamed to locale/tra.pot

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# LANGUAGE translation for project-evergreen for the following files:
22
# res://entities/countries/usa.gd
3+
# res://ui/widgets/top_app_bar.tscn
34
#
45
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
56
#
@@ -14,3 +15,7 @@ msgstr ""
1415
#: entities/countries/usa.gd
1516
msgid "COUNTRY_USA_NAME"
1617
msgstr ""
18+
19+
#: ui/widgets/top_app_bar.tscn
20+
msgid "TEMPERATURE_ANOMALY_DESCRIPTION"
21+
msgstr ""

locale/zh_TW.mo

-327 Bytes
Binary file not shown.

locale/zh_TW.po

Lines changed: 0 additions & 22 deletions
This file was deleted.

project.godot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ select={
6666
[internationalization]
6767

6868
locale/translations=PackedStringArray("res://locale/en.mo", "res://locale/zh_TW.mo")
69-
locale/translations_pot_files=PackedStringArray("res://entities/countries/usa.gd")
69+
locale/translations_pot_files=PackedStringArray("res://entities/countries/usa.gd", "res://ui/widgets/top_app_bar.tscn")

scenes/main/main.tscn

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[gd_scene load_steps=8 format=3 uid="uid://d3nj6rt0cm53e"]
1+
[gd_scene load_steps=9 format=3 uid="uid://d3nj6rt0cm53e"]
22

33
[ext_resource type="PackedScene" uid="uid://xlfbl7fowoic" path="res://scenes/worldmap/world_map.tscn" id="1_cjno1"]
44
[ext_resource type="PackedScene" uid="uid://qjjw8mvvjabt" path="res://ui/viewmodels/vm_countries.tscn" id="1_grghp"]
@@ -7,6 +7,7 @@
77
[ext_resource type="PackedScene" uid="uid://dap6c80qsg2ip" path="res://entities/music_player_component.tscn" id="3_l6axm"]
88
[ext_resource type="PackedScene" uid="uid://dcnty7qxod06" path="res://scenes/components/camera_component.tscn" id="4_xha1d"]
99
[ext_resource type="PackedScene" uid="uid://b1x0140gst6wf" path="res://entities/time_component.tscn" id="5_6js18"]
10+
[ext_resource type="PackedScene" uid="uid://cxdm1p8x2yt7d" path="res://entities/components/temperature_component.tscn" id="5_p0y26"]
1011

1112
[node name="World" type="Node2D"]
1213

@@ -22,6 +23,9 @@
2223

2324
[node name="MusicPlayerComponent" parent="Components" instance=ExtResource("3_l6axm")]
2425

26+
[node name="TemperatureComponent" parent="Components" node_paths=PackedStringArray("time_component") instance=ExtResource("5_p0y26")]
27+
time_component = NodePath("../TimeComponent")
28+
2529
[node name="WorldMap" parent="." instance=ExtResource("1_cjno1")]
2630
position = Vector2(0, 1)
2731

0 commit comments

Comments
 (0)