7 Commits

Author SHA1 Message Date
67a99051bd update save mode 2026-06-29 15:23:44 +02:00
fb848a9848 add new transaction and add splash screen 2026-06-29 14:59:58 +02:00
bc30a169dc fix stats manager 2026-06-29 10:48:58 +02:00
f5576959b7 add achievement for train change 2026-06-29 10:21:56 +02:00
b8ab8f4971 Merge pull request 'add whistle to train' (#38) from whitleandstats into main
Reviewed-on: #38
2026-06-29 08:20:37 +00:00
22653d62bc fix train_selector 2026-06-29 10:20:11 +02:00
6a2a2d2e8a add whistle to train 2026-06-29 08:35:14 +02:00
32 changed files with 521 additions and 81 deletions

View File

@@ -1,7 +1,7 @@
extends Path3D
const STEAM_DISTANCE_STAT: String = "stat_distance_km"
const STEAM_DISTANCE_KM_PER_UNIT: float = 1#0.001
const DISTANCE_KM_PER_UNIT: float = 0.001
@export_group("Train")
##train speed
@@ -396,13 +396,13 @@ func _track_steam_distance(distance_units: float) -> void:
return
# Always track the global distance in our save file (for UI and persistency)
GameState.save_data.total_distance_km += distance_units * STEAM_DISTANCE_KM_PER_UNIT
GameState.save_data.total_distance_km += distance_units * DISTANCE_KM_PER_UNIT
# Steam specific logic
if not SteamManager.is_on_steam:
return
_pending_steam_distance_km += distance_units * STEAM_DISTANCE_KM_PER_UNIT
_pending_steam_distance_km += distance_units * DISTANCE_KM_PER_UNIT
var whole_km: int = int(floor(_pending_steam_distance_km))
if whole_km <= 0:
return

View File

@@ -35,6 +35,8 @@ func _set_selected_color(index: int, material_index: int) -> void:
else:
color_pickers[i].deselect()
AchievementManager.is_unlocked("ACH_CHANGE_TRAIN_COLOR")
func _on_color_selected(selected_color_picker: TrainColorPicker, material_index: int) -> void:
var color_pickers = color_pickers_1 if material_index == 0 else color_pickers_2
for i in range(color_pickers.size()):

View File

@@ -9,10 +9,10 @@ func _ready() -> void:
deselect()
disable()
func set_option_text(text: String) -> void:
func set_option_text(_text: String) -> void:
if label == null:
label = $%Label
label.text = text
label.text = _text
func select() -> void:
if checkbox == null:

View File

@@ -22,6 +22,7 @@ signal on_photo_taken_finished
signal on_photo_mode_black_screen_disappeared
const SAVE_PATH: String = "user://savegame.json"
const SAVE_PASSWORD: String = "jmpgames_megapwd"
var save_data: SaveGameData = SaveGameData.new()
var is_loaded: bool = false
@@ -39,7 +40,7 @@ func apply_video_settings() -> void:
get_viewport().use_taa = save_data.anti_aliasing
var msaa_mode = Viewport.MSAA_2X if save_data.anti_aliasing else Viewport.MSAA_DISABLED
get_viewport().msaa_3d = msaa_mode
get_viewport().msaa_2d = msaa_mode
get_viewport().msaa_2d = Viewport.MSAA_DISABLED
func apply_train_colors() -> void:
if not save_data.train_color_1.is_empty():
@@ -64,33 +65,68 @@ func apply_train_colors() -> void:
DisplayServer.window_set_size(Vector2i(save_data.resolution_x, save_data.resolution_y))
# Optional: center the window if resized
var screen_center = DisplayServer.screen_get_position() + DisplayServer.screen_get_size() / 2
var window_size = DisplayServer.window_get_size()
DisplayServer.window_set_position(screen_center - window_size / 2)
func save_game() -> void:
var save_file = FileAccess.open(SAVE_PATH, FileAccess.WRITE)
var json_string = JSON.stringify(save_data.to_dictionary())
save_file.store_line(json_string)
var screen_position: Vector2i = DisplayServer.screen_get_position()
var screen_size: Vector2i = DisplayServer.screen_get_size()
var window_size: Vector2i = DisplayServer.window_get_size()
var screen_center := screen_position + Vector2i(
floori(float(screen_size.x) / 2.0),
floori(float(screen_size.y) / 2.0)
)
var window_half_size := Vector2i(
floori(float(window_size.x) / 2.0),
floori(float(window_size.y) / 2.0)
)
DisplayServer.window_set_position(screen_center - window_half_size)
#encrypted file + binary serialization (standard)
func load_game() -> void:
if not FileAccess.file_exists(SAVE_PATH):
save_data = SaveGameData.new()
is_loaded = true
return
var file = FileAccess.open(SAVE_PATH, FileAccess.READ)
var json_string = file.get_as_text()
var json = JSON.new()
var parse_result = json.parse(json_string)
var file := FileAccess.open_encrypted_with_pass(SAVE_PATH, FileAccess.READ, SAVE_PASSWORD)
save_data = SaveGameData.new()
if parse_result == OK and json.data is Dictionary:
save_data = SaveGameData.from_dictionary(json.data)
if file != null:
var data = file.get_var()
file.close()
if data is Dictionary:
save_data = SaveGameData.from_dictionary(data)
#if file == null the key or the file is corrupted -> start with new data
is_loaded = true
func save_game() -> void:
var file := FileAccess.open_encrypted_with_pass(SAVE_PATH, FileAccess.WRITE, SAVE_PASSWORD)
if file == null:
push_error("Salvataggio fallito: %s" % FileAccess.get_open_error())
return
file.store_var(save_data.to_dictionary()) # binario, non JSON
file.close()
#JSon Version
#func save_game() -> void:
#var save_file = FileAccess.open(SAVE_PATH, FileAccess.WRITE)
#var json_string = JSON.stringify(save_data.to_dictionary())
#save_file.store_line(json_string)
#
#func load_game() -> void:
#if not FileAccess.file_exists(SAVE_PATH):
#save_data = SaveGameData.new()
#is_loaded = true
#return
#
#var file = FileAccess.open(SAVE_PATH, FileAccess.READ)
#var json_string = file.get_as_text()
#
#var json = JSON.new()
#var parse_result = json.parse(json_string)
#
#save_data = SaveGameData.new()
#if parse_result == OK and json.data is Dictionary:
#save_data = SaveGameData.from_dictionary(json.data)
#
#is_loaded = true
func pause_game() -> void:
get_tree().paused = true

View File

@@ -1,6 +1,5 @@
extends Control
@onready var game_menu: Control = $%GameMenu
@onready var game_menu_panel: Control = $%GameMenuPanel
@onready var menu_icon_button: Button = $%MenuIconButton
@@ -43,10 +42,12 @@ func _ready() -> void:
choo_choo_button.pressed.connect(_on_choo_choo_button_pressed)
resume_button.pressed.connect(_on_resume_button_pressed)
func _process(delta: float) -> void:
func _process(_delta: float) -> void:
if time_label and dist_label and GameState.is_loaded:
var time = GameState.save_data.total_time_played_seconds
@warning_ignore("integer_division")
var hours = int(time) / 3600
@warning_ignore("integer_division")
var minutes = (int(time) % 3600) / 60
var seconds = int(time) % 60
time_label.text = "Travel Time: %02d:%02d:%02d" % [hours, minutes, seconds]
@@ -112,6 +113,8 @@ func _on_weather_row_on_option_changed(data: String) -> void:
pick_random_weather()
_:
pass
AchievementManager.is_unlocked("ACH_CHANGE_METEO")
func pick_random_weather() -> void:
var valid_buttons = []
@@ -189,6 +192,8 @@ func _on_photo_taken_finished() -> void:
await tween.finished
photo_mode_black_screen.hide()
GameState.on_photo_mode_black_screen_disappeared.emit()
StatsManager.add_int("stat_photo_number", 1)
StatsManager.store()
func _on_choo_choo_button_pressed() -> void:
#play sfx

View File

@@ -0,0 +1,70 @@
## Updates total elapsed time and train distance labels.
class_name TotalStatsDisplay
extends Node
const RAILS_SCRIPT = preload("res://core/biome_generator/rails.gd")
const SECONDS_PER_MINUTE: int = 60
const MINUTES_PER_HOUR: int = 60
const HOURS_PER_DAY: int = 24
#DISTANCE_KM_PER_UNIT is taken from rails.gd constant
@export var time_label_path: NodePath
@export var distance_label_path: NodePath
@export var rail_path: NodePath
var _elapsed_seconds: float = 0.0
var _total_distance_km: float = 0.0
var _last_train_progress: float = -1.0
@onready var _time_label: Label = get_node_or_null(time_label_path) as Label
@onready var _distance_label: Label = get_node_or_null(distance_label_path) as Label
@onready var _rail_path: Path3D = get_node_or_null(rail_path) as Path3D
func _ready() -> void:
_update_time_label()
_update_distance_label()
func _process(delta: float) -> void:
_elapsed_seconds += delta
_update_total_distance()
_update_time_label()
_update_distance_label()
func _update_total_distance() -> void:
if _rail_path == null or _rail_path.curve == null:
return
var current_train_progress: float = float(_rail_path.get("train_progress"))
if _last_train_progress < 0.0:
_last_train_progress = current_train_progress
return
var total_length: float = _rail_path.curve.get_baked_length()
if total_length <= 0.0:
return
var progress_delta: float = absf(current_train_progress - _last_train_progress)
var wrapped_progress_delta: float = minf(progress_delta, total_length - progress_delta)
_total_distance_km += wrapped_progress_delta * RAILS_SCRIPT.DISTANCE_KM_PER_UNIT
_last_train_progress = current_train_progress
func _update_time_label() -> void:
if _time_label == null:
return
var total_minutes: int = int(floor(_elapsed_seconds / SECONDS_PER_MINUTE))
var days: int = floori(float(total_minutes) / float(MINUTES_PER_HOUR * HOURS_PER_DAY))
var hours: int = floori(float(total_minutes) / float(MINUTES_PER_HOUR)) % HOURS_PER_DAY
var minutes: int = total_minutes % MINUTES_PER_HOUR
_time_label.text = "Time %dd %02dh %02dm" % [days, hours, minutes]
func _update_distance_label() -> void:
if _distance_label == null:
return
_distance_label.text = "Distance %.1f km" % _total_distance_km

View File

@@ -0,0 +1 @@
uid://c2usnexa5x7pg

View File

@@ -1,6 +1,6 @@
class_name SceneConfig
extends Resource
enum SceneName { MAIN_MENU, GAME }
enum SceneName { MAIN_MENU, GAME, SPLASH_SCREEN }
@export var scenes: Dictionary[SceneName, PackedScene]

View File

@@ -3,11 +3,13 @@
[ext_resource type="PackedScene" uid="uid://btcpge7cj2041" path="res://core/main_menu/main_menu.tscn" id="1_72aup"]
[ext_resource type="Script" uid="uid://bbgyhmb8a17i7" path="res://core/scene_manager/scene_config.gd" id="1_km45g"]
[ext_resource type="PackedScene" uid="uid://vjf4bdxd8saj" path="res://tgcc/main_scene.tscn" id="2_prsyo"]
[ext_resource type="PackedScene" uid="uid://ri5kxx4mipo" path="res://core/splash_screen/splash_screen.tscn" id="3_aasbo"]
[resource]
script = ExtResource("1_km45g")
scenes = Dictionary[int, PackedScene]({
0: ExtResource("1_72aup"),
1: ExtResource("2_prsyo")
1: ExtResource("2_prsyo"),
2: ExtResource("3_aasbo")
})
metadata/_custom_type_script = "uid://bbgyhmb8a17i7"

View File

@@ -4,41 +4,91 @@ extends CanvasLayer
@onready var color_rect = $ColorRect
@onready var loading_screen = $LoadingScreen
@export var transition_duration: float = 1
const SHADER_PATH := "res://core/transition.gdshader"
func _ready() -> void:
color_rect.color.a = 0.0
color_rect.mouse_filter = Control.MOUSE_FILTER_IGNORE
loading_screen.hide()
_build_material()
_update_resolution()
get_viewport().size_changed.connect(_update_resolution)
_set_factor(0.0)
color_rect.visible = false
func change_scene(scene_enum: SceneConfig.SceneName) -> void:
func _build_material() -> void:
var mat := ShaderMaterial.new()
mat.shader = load(SHADER_PATH)
#directional gradient: botto-left-> black; top-right -> white
var g := Gradient.new()
g.set_color(0, Color.BLACK)
g.set_color(1, Color.WHITE)
var grad_tex := GradientTexture2D.new()
grad_tex.gradient = g
grad_tex.fill = GradientTexture2D.FILL_LINEAR
grad_tex.fill_from = Vector2(0.0, 1.0) # bottom-left
grad_tex.fill_to = Vector2(1.0, 0.0) # top-right
grad_tex.width = 256
grad_tex.height = 256
#shape: sphere (white at the center, black around)
var sg := Gradient.new()
sg.set_color(0, Color.WHITE)
sg.set_color(1, Color.BLACK)
var shape_tex := GradientTexture2D.new()
shape_tex.gradient = sg
shape_tex.fill = GradientTexture2D.FILL_RADIAL
shape_tex.fill_from = Vector2(0.5, 0.5) # center
shape_tex.fill_to = Vector2(0.5, 0.0) # ray
shape_tex.width = 64
shape_tex.height = 64
mat.set_shader_parameter("base_color", Color.BLACK)
mat.set_shader_parameter("gradient_texture", grad_tex)
mat.set_shader_parameter("gradient_fixed", false)
mat.set_shader_parameter("shape_texture", shape_tex)
mat.set_shader_parameter("shape_tiling", 16.0)
mat.set_shader_parameter("shape_rotation", 0.0)
mat.set_shader_parameter("shape_scroll", Vector2.ZERO)
mat.set_shader_parameter("shape_feathering", 0.05)
mat.set_shader_parameter("shape_treshold", 1.0) # >=1 -> full at the end of the transation
mat.set_shader_parameter("width", 0.5)
color_rect.material = mat
func _update_resolution() -> void:
var s := get_viewport().get_visible_rect().size
color_rect.material.set_shader_parameter("node_resolution", s)
func _set_factor(v: float) -> void:
color_rect.material.set_shader_parameter("factor", v)
func cover(duration := 0.5) -> void:
color_rect.visible = true
var t := create_tween()
t.tween_method(_set_factor, 0.0, 1.0, duration)
await t.finished
func reveal(duration := 0.5) -> void:
var t := create_tween()
t.tween_method(_set_factor, 1.0, 0.0, duration)
await t.finished
color_rect.visible = false
func change_scene(scene_enum: SceneConfig.SceneName) -> void:
if not config or not config.scenes.has(scene_enum):
return
var target_scene: PackedScene = config.scenes[scene_enum]
color_rect.mouse_filter = Control.MOUSE_FILTER_STOP
loading_screen.visible = true
var tween_in = create_tween()
tween_in.tween_property(color_rect, "color:a", 1.0, transition_duration)
await tween_in.finished
loading_screen.show()
await get_tree().process_frame
await cover(transition_duration)
get_tree().change_scene_to_packed(target_scene)
await reveal(transition_duration)
loading_screen.hide()
var tween_out = create_tween()
tween_out.tween_property(color_rect, "color:a", 0.0, transition_duration)
await tween_out.finished
loading_screen.visible = false
color_rect.mouse_filter = Control.MOUSE_FILTER_IGNORE
func quit_game() -> void:
color_rect.mouse_filter = Control.MOUSE_FILTER_STOP
var tween = create_tween()
tween.tween_property(color_rect, "color:a", 1.0, transition_duration)
await tween.finished
get_tree().quit()

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

View File

@@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dp3qxncy8u184"
path="res://.godot/imported/jmp_logo.png-c6094efb2c4c429c25ff79b5a4cee21c.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://core/splash_screen/jmp_logo.png"
dest_files=["res://.godot/imported/jmp_logo.png-c6094efb2c4c429c25ff79b5a4cee21c.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -0,0 +1,8 @@
extends Control
@export var main_menu_scene: PackedScene
@export var display_time: float = 3.0
func _ready() -> void:
await get_tree().create_timer(display_time).timeout
SceneManager.change_scene(SceneConfig.SceneName.MAIN_MENU)

View File

@@ -0,0 +1 @@
uid://ckj2pcoxi5j3

View File

@@ -0,0 +1,18 @@
[gd_scene format=3 uid="uid://ri5kxx4mipo"]
[ext_resource type="Script" uid="uid://ckj2pcoxi5j3" path="res://core/splash_screen/splash_screen.gd" id="1_elsnp"]
[ext_resource type="Texture2D" uid="uid://dp3qxncy8u184" path="res://core/splash_screen/jmp_logo.png" id="1_jkpgl"]
[node name="Control" type="Control" unique_id=163470013]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_elsnp")
[node name="JMPLogo" type="Sprite2D" parent="." unique_id=1244888940]
position = Vector2(980.99994, 556)
scale = Vector2(0.37799045, 0.37799042)
texture = ExtResource("1_jkpgl")

View File

@@ -4,23 +4,22 @@ extends Node
#if you have an error setting achievements or stats in debug mode remember to open your steam client
#with jmp games account or another account who bought this game. If error persist try to clos and reopen steam client.
const KNOWN := [
"ACH_DISTANCE_100",
"ACH_DISTANCE_200",
"ACH_10_PHOTOS",
"ACH_CHANGE_METEO",
"ACH_CHANGE_TRAIN_COLOR",
]
#how it works:
#func _on_player_won() -> void:
# Achievements.unlock("ACH_DISTANCE_100") #unlock the achievement at first win
# AchievementManager.unlock("ACH_DISTANCE_100") #unlock the achievement at first win
#func _on_match_finished(coins_collected: int) -> void:
#update stats
#...
#check thresholds and unlock achievements
# if Stats.get_int("stat_distance_km") >= 100:
# Achievements.unlock("ACH_DISTANCE_100")
# if Stats.get_int("stat_distance_km") >= 200:
# Achievements.unlock("ACH_DISTANCE_200")
# if StatsManager.get_int("stat_distance_km") >= 100:
# AchievementManager.unlock("ACH_DISTANCE_100")
# if StatsManager.get_int("stat_distance_km") >= 200:
# AchievementManager.unlock("ACH_DISTANCE_200")
signal unlocked(api_name: String)

View File

@@ -7,7 +7,7 @@ extends Node
#if you have an error setting achievements or stats in debug mode remember to open your steam client
#with jmp games account or another account who bought this game. If error persist try to clos and reopen steam client.
const KNOWN := [
"stat_games_played",
"stat_time_played",
"stat_distance_km",
"stat_stop_number",
"stat_photo_number",
@@ -16,11 +16,11 @@ const KNOWN := [
#how it works:
#func _on_match_finished(score: int) -> void:
# Stats.add_int("stat_games_played", 1)
# Stats.set_int("stat_total_score", Stats.get_int("stat_total_score") + score)
# Stats.store() #only one push at the end of the game
# if Stats.get_int("stat_games_played") >= 10:
# Achievements.unlock("ACH_PLAY_10_GAMES") #it call storeStats()
# StatsManager.add_int("stat_time_played", 1)
# StatsManager.set_int("stat_total_score", StatsManager.get_int("stat_total_score") + score)
# StatsManager.store() #only one push at the end of the game
# if StatsManager.get_int("stat_time_played") >= 10:
# AchievementManager.unlock("ACH_PLAY_10_HOURS") #it call storeStats()
func _ready() -> void:
@@ -64,8 +64,8 @@ func store() -> void:
#Development only: reset stats
func reset_all(include_achievements: bool = false) -> void:
Steam.resetAllStats(include_achievements)
Steam.storeStats()
if !Steam.resetAllStats(include_achievements):
push_error("resetAllStats failed")
func _on_stats_stored(_game: int, result: int) -> void:
if !result:

57
core/transition.gdshader Normal file
View File

@@ -0,0 +1,57 @@
shader_type canvas_item;
uniform vec4 base_color : source_color;
uniform vec2 node_resolution;
uniform float factor : hint_range(0.0, 1.0, 0.01) = 0.54;
uniform float width = 0.4;
group_uniforms gradient;
uniform sampler2D gradient_texture;
uniform bool gradient_fixed = false;
group_uniforms shape;
uniform sampler2D shape_texture;
uniform float shape_tiling = 32.0;
uniform float shape_rotation = 0.0;
uniform vec2 shape_scroll = vec2(0.0);
uniform float shape_feathering : hint_range(0.0, 1.0, 0.01) = 0.00;
uniform float shape_treshold : hint_range(0.0, 2.0, 0.01) = 1.0;
float gradient(vec2 uv, vec2 fixed_uv, bool fixed){
float value = 0.0;
if(fixed){
value = texture(gradient_texture, fixed_uv).r;
} else {
value = texture(gradient_texture, uv).r;
}
return value;
}
vec2 rotate(vec2 uv, vec2 pivot, float angle)
{
mat2 rotation = mat2(vec2(sin(angle), -cos(angle)),
vec2(cos(angle), sin(angle)));
uv -= pivot;
uv = uv * rotation;
uv += pivot;
return uv;
}
void fragment() {
float progress = mix(-width, 1.0, factor);
float aspect = node_resolution.y / node_resolution.x;
vec2 aspect_uv = ((UV-vec2(0.0,0.5)) * vec2(1.0, aspect))+vec2(0.0,0.5);
float value = clamp((gradient(UV, aspect_uv, gradient_fixed) - progress) / (width), 0.0, 1.0);
vec2 tiled_uv = rotate(mod((aspect_uv + vec2(TIME)*shape_scroll) * shape_tiling, 1.0), vec2(0.5), radians(shape_rotation));
float shape_value = 1.0 - texture(shape_texture, tiled_uv).r;
shape_value = mix(shape_feathering * 0.5, 1.0 - shape_feathering * 0.5, shape_value);
float shaped_gradient = smoothstep(value - (shape_feathering * 0.5), value + (shape_feathering * 0.5), shape_treshold - shape_value);
COLOR.rgb = base_color.rgb;
COLOR.a = shaped_gradient;
}

View File

@@ -0,0 +1 @@
uid://ovrd5ydp8p0q

View File

@@ -43,3 +43,7 @@ signal day_time_changed(value: float, time_string: String)
signal time_option_item_changed(index: int)
@warning_ignore("unused_signal")
signal day_time_option_changed(index: int)
#train signals
@warning_ignore("unused_signal")
signal toot_toot()

View File

@@ -1,6 +1,6 @@
extends Node3D
func _input(event):
if event is InputEventKey and event.pressed:
if event.keycode == KEY_ESCAPE:
get_tree().quit()
#func _input(event):
#if event is InputEventKey and event.pressed:
#if event.keycode == KEY_ESCAPE:
#get_tree().quit()

View File

@@ -107,3 +107,9 @@ func _on_fog_toggled(toggled_on: bool) -> void:
func _on_update_rails_pressed() -> void:
UIEvents.update_rail_chunks.emit()
func _on_toot_toot_pressed() -> void:
UIEvents.toot_toot.emit()
func _on_reset_stats_ach_pressed() -> void:
StatsManager.reset_all(true)

View File

@@ -1,6 +1,6 @@
extends Node3D
func _input(event):
if event is InputEventKey and event.pressed:
if event.keycode == KEY_ESCAPE:
get_tree().quit()
#func _input(event):
#if event is InputEventKey and event.pressed:
#if event.keycode == KEY_ESCAPE:
#get_tree().quit()

View File

@@ -11,7 +11,7 @@ config_version=5
[application]
config/name="tgcc"
run/main_scene="uid://vjf4bdxd8saj"
run/main_scene="uid://ri5kxx4mipo"
config/features=PackedStringArray("4.6", "Forward Plus")
run/max_fps=60
config/icon="uid://bfar1kk3pgq8f"

View File

@@ -65,6 +65,7 @@
[ext_resource type="PackedScene" uid="uid://bei7fscn77p1p" path="res://core/main_scene_ui/main_scene_ui.tscn" id="49_exdk1"]
[ext_resource type="PackedScene" uid="uid://vni5kjalum6d" path="res://core/photo_mode/runtime/photo_mode_controller.tscn" id="50_57hhv"]
[ext_resource type="PackedScene" uid="uid://bujym3ai10i7q" path="res://tgcc/chunk/countryside/scene/tea/chunk_country_tea_corner_01.tscn" id="51_lxncq"]
[ext_resource type="Script" uid="uid://c2usnexa5x7pg" path="res://core/main_scene_ui/total_stats_display.gd" id="51_totals"]
[ext_resource type="PackedScene" uid="uid://bdfosig4g14vt" path="res://tgcc/chunk/countryside/scene/tea/chunk_country_tea_corner_02.tscn" id="52_317hq"]
[ext_resource type="PackedScene" uid="uid://ffblnqib7fry" path="res://tgcc/chunk/countryside/scene/tea/chunk_country_tea_cross_3_01.tscn" id="53_0ur37"]
[ext_resource type="PackedScene" uid="uid://b785qpoxbrovj" path="res://tgcc/chunk/countryside/scene/tea/chunk_country_tea_cross_3_02.tscn" id="54_vbb0s"]
@@ -218,6 +219,11 @@ transform = Transform3D(0.57785755, -0.57709646, 0.5770964, 0, 0.7071067, 0.7071
rotation_target = NodePath("../pivot")
iso_camera = NodePath("../camera_iso")
[node name="MainSceneUi" parent="cameras" unique_id=1359391222 instance=ExtResource("49_exdk1")]
offset_left = 3.0
offset_right = 3.0
mouse_filter = 2
[node name="DayNight" parent="." unique_id=1611939731 node_paths=PackedStringArray("camera_pivot") instance=ExtResource("36_qwsp8")]
camera_pivot = NodePath("../cameras")
thunder_sounds = Array[AudioStream]([SubResource("AudioStreamMP3_ra0ar"), SubResource("AudioStreamMP3_j8mxr"), ExtResource("37_pdfkp"), ExtResource("38_fpbvh"), ExtResource("39_hxtdl")])
@@ -262,7 +268,6 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -91.191925, 0, 539.03174)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -312.19193, 0, 349.03174)
[node name="Control" type="Control" parent="." unique_id=630650980]
visible = false
layout_mode = 3
anchors_preset = 0
offset_right = 40.0
@@ -348,6 +353,29 @@ theme_override_colors/font_hover_pressed_color = Color(1, 1, 1, 1)
theme_override_colors/font_outline_color = Color(1, 1, 1, 1)
text = "Storm"
[node name="TotalDistance" type="Label" parent="Control" unique_id=1735753299]
layout_mode = 0
offset_left = 277.0
offset_top = 31.0
offset_right = 611.0
offset_bottom = 54.0
theme_override_colors/font_color = Color(1, 1, 1, 1)
theme_override_colors/font_outline_color = Color(1, 1, 1, 1)
text = "Distance 0 km"
[node name="TotalTime" type="Label" parent="Control" unique_id=1065776479]
layout_mode = 0
offset_left = 276.0
offset_top = 13.0
offset_right = 610.0
offset_bottom = 36.0
theme_override_colors/font_color = Color(1, 1, 1, 1)
theme_override_colors/font_outline_color = Color(1, 1, 1, 1)
text = "Time 00:00"
[node name="TotalStatsDisplay" type="Node" parent="Control" unique_id=1147065793]
script = ExtResource("51_totals")
[node name="DayTimeLabel" type="Label" parent="Control" unique_id=1124935856]
layout_mode = 0
offset_left = 13.0
@@ -479,6 +507,34 @@ theme_override_colors/font_hover_pressed_color = Color(1, 1, 1, 1)
theme_override_colors/font_outline_color = Color(1, 1, 1, 1)
text = "Fog"
[node name="ResetStatsAch" type="Button" parent="Control" unique_id=960673125]
layout_mode = 0
offset_left = 12.0
offset_top = 425.0
offset_right = 195.0
offset_bottom = 456.0
theme_override_colors/font_color = Color(1, 1, 1, 1)
theme_override_colors/font_focus_color = Color(1, 1, 1, 1)
theme_override_colors/font_pressed_color = Color(1, 1, 1, 1)
theme_override_colors/font_hover_color = Color(1, 1, 1, 1)
theme_override_colors/font_hover_pressed_color = Color(1, 1, 1, 1)
theme_override_colors/font_outline_color = Color(1, 1, 1, 1)
text = "Reset Stats & Ach."
[node name="TootToot" type="Button" parent="Control" unique_id=2047151132]
layout_mode = 0
offset_left = 12.0
offset_top = 388.0
offset_right = 195.0
offset_bottom = 419.0
theme_override_colors/font_color = Color(1, 1, 1, 1)
theme_override_colors/font_focus_color = Color(1, 1, 1, 1)
theme_override_colors/font_pressed_color = Color(1, 1, 1, 1)
theme_override_colors/font_hover_color = Color(1, 1, 1, 1)
theme_override_colors/font_hover_pressed_color = Color(1, 1, 1, 1)
theme_override_colors/font_outline_color = Color(1, 1, 1, 1)
text = "Toot Toot"
[node name="UpdateRails" type="Button" parent="Control" unique_id=267134156]
layout_mode = 0
offset_left = 12.0
@@ -493,9 +549,6 @@ theme_override_colors/font_hover_pressed_color = Color(1, 1, 1, 1)
theme_override_colors/font_outline_color = Color(1, 1, 1, 1)
text = "Update Rails"
[node name="MainSceneUi" parent="." unique_id=1359391222 instance=ExtResource("49_exdk1")]
mouse_filter = 2
[connection signal="toggled" from="Control/Snow" to="Control" method="_on_snow_toggled"]
[connection signal="toggled" from="Control/Rain" to="Control" method="_on_rain_toggled"]
[connection signal="toggled" from="Control/Wind" to="Control" method="_on_wind_toggled"]
@@ -510,6 +563,8 @@ mouse_filter = 2
[connection signal="toggled" from="Control/Shadows" to="Control" method="_on_shadows_toggled"]
[connection signal="pressed" from="Control/RandomWeather" to="Control" method="_on_random_weather_pressed"]
[connection signal="toggled" from="Control/Fog" to="Control" method="_on_fog_toggled"]
[connection signal="pressed" from="Control/ResetStatsAch" to="Control" method="_on_reset_stats_ach_pressed"]
[connection signal="pressed" from="Control/TootToot" to="Control" method="_on_toot_toot_pressed"]
[connection signal="pressed" from="Control/UpdateRails" to="Control" method="_on_update_rails_pressed"]
[editable path="cameras"]

Binary file not shown.

View File

@@ -0,0 +1,19 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
uid="uid://dc6si4i1wgtg1"
path="res://.godot/imported/train_whistle.mp3-7c9ba844b982f1e2dc8f87df905de652.mp3str"
[deps]
source_file="res://tgcc/train/sounds/train_whistle.mp3"
dest_files=["res://.godot/imported/train_whistle.mp3-7c9ba844b982f1e2dc8f87df905de652.mp3str"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

Binary file not shown.

View File

@@ -0,0 +1,19 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
uid="uid://cr7evvbfp33ra"
path="res://.godot/imported/train_whistle2.mp3-fa64a19fd0b0cdce9722553ae5dff242.mp3str"
[deps]
source_file="res://tgcc/train/sounds/train_whistle2.mp3"
dest_files=["res://.godot/imported/train_whistle2.mp3-fa64a19fd0b0cdce9722553ae5dff242.mp3str"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

46
tgcc/train/train.gd Normal file
View File

@@ -0,0 +1,46 @@
extends Node3D
#const TRAIN_WHISTLE_STREAM: AudioStream = preload("res://tgcc/train/sounds/train_whistle.mp3")
const TRAIN_WHISTLE_STREAM: AudioStream = preload("res://tgcc/train/sounds/train_whistle2.mp3")
@export_group("Whistle")
@export var whistle_volume_db: float = 1.0
@export var whistle_unit_size: float = 90.0
@export var whistle_max_distance: float = 1200.0
var _whistle_player: AudioStreamPlayer3D
func _ready() -> void:
_create_whistle_player()
if not UIEvents.toot_toot.is_connected(_on_toot_toot):
UIEvents.toot_toot.connect(_on_toot_toot)
func _exit_tree() -> void:
if UIEvents.toot_toot.is_connected(_on_toot_toot):
UIEvents.toot_toot.disconnect(_on_toot_toot)
func _create_whistle_player() -> void:
_whistle_player = AudioStreamPlayer3D.new()
_whistle_player.name = "TrainWhistlePlayer"
_whistle_player.bus = &"SFX"
_whistle_player.volume_db = whistle_volume_db
_whistle_player.unit_size = whistle_unit_size
_whistle_player.max_distance = whistle_max_distance
_whistle_player.stream = TRAIN_WHISTLE_STREAM
add_child(_whistle_player)
func _on_toot_toot() -> void:
if _whistle_player == null:
return
print("stat_toottoot_number")
StatsManager.add_int("stat_toottoot_number", 1)
StatsManager.store()
_whistle_player.stop()
_whistle_player.play()

1
tgcc/train/train.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://c34qgl2afyhse

View File

@@ -7,7 +7,7 @@
[ext_resource type="Material" uid="uid://o31kp0jm07q3" path="res://tgcc/chunk/material/rocks.tres" id="5_pj7tp"]
[ext_resource type="Material" uid="uid://bsote67noubj2" path="res://tgcc/train/Color1_train.tres" id="7_sgpgi"]
[ext_resource type="Shader" uid="uid://d0ch5ofrgf7y6" path="res://core/daynight/trunk_shader.gdshader" id="8_eke0t"]
[ext_resource type="Script" uid="uid://5frq4qrokiy2" path="res://tgcc/train/train_glass_emission.gd" id="9_4qk3b"]
[ext_resource type="Script" path="res://tgcc/train/train.gd" id="9_4qk3b"]
[ext_resource type="Texture2D" uid="uid://j4m5wsf4magb" path="res://tgcc/chunk/material/decal/vending_decal.png" id="9_eke0t"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_p4ai0"]