fix snow and exposure
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
extends Path3D
|
||||
|
||||
const STEAM_DISTANCE_STAT: String = "stat_distance_km"
|
||||
const DISTANCE_KM_PER_UNIT: float = 0.001
|
||||
const DISTANCE_KM_PER_UNIT: float = 0.01
|
||||
|
||||
@export_group("Train")
|
||||
##train speed
|
||||
@@ -83,17 +83,20 @@ var environment_config: EnvironmentConfig
|
||||
var wagon_instances: Array[Node3D] = []
|
||||
var wagon_progress_offsets: Array[float] = []
|
||||
var _pending_steam_distance_km: float = 0.0
|
||||
var _initial_is_inmotion: bool = true
|
||||
|
||||
func _ready() -> void:
|
||||
randomize()
|
||||
|
||||
_cache_environment_config()
|
||||
_initial_is_inmotion = is_inmotion
|
||||
|
||||
if curve != null and curve.get_baked_length() > 0:
|
||||
build_rails()
|
||||
build_train()
|
||||
_plan_stops()
|
||||
_apply_initial_train_start()
|
||||
_apply_train_start_delay()
|
||||
else:
|
||||
print("WARNING: Draw Path3D for rails!")
|
||||
|
||||
@@ -138,6 +141,23 @@ func _apply_initial_train_start() -> void:
|
||||
|
||||
_snap_train_to_progress()
|
||||
|
||||
func _apply_train_start_delay() -> void:
|
||||
if not _initial_is_inmotion:
|
||||
return
|
||||
|
||||
var start_delay_seconds: float = 0.0
|
||||
if environment_config != null:
|
||||
start_delay_seconds = maxf(environment_config.train_start_delay_seconds, 0.0)
|
||||
if start_delay_seconds <= 0.0:
|
||||
return
|
||||
|
||||
is_inmotion = false
|
||||
await get_tree().create_timer(start_delay_seconds).timeout
|
||||
if not is_inside_tree():
|
||||
return
|
||||
|
||||
is_inmotion = _initial_is_inmotion
|
||||
|
||||
func _set_next_stop_index_from_current(current_stop_index: int) -> void:
|
||||
if stop_offset.is_empty():
|
||||
next_stop_index = 0
|
||||
|
||||
@@ -139,10 +139,10 @@ func _apply_dynamic_environment_materials(node: Node) -> void:
|
||||
if node.is_in_group("wind_node"):
|
||||
_apply_wind_noise_to_node(node, NOISE_TEXTURE)
|
||||
|
||||
if node.is_in_group("weather_node"):
|
||||
if node.is_in_group("weather_node") or node.is_in_group("weather_vegetables_node"):
|
||||
_apply_weather_overlay_to_node(node, _get_weather_overlay_material(node))
|
||||
|
||||
if _should_clear_weather_overlay(node):
|
||||
if _should_ignore_weather_overlay(node):
|
||||
_clear_weather_overlay_from_node(node)
|
||||
|
||||
func ApplyWindNoiseToMaterials():
|
||||
@@ -169,8 +169,7 @@ func ApplyWeatherShaderToMaterials():
|
||||
_apply_weather_overlay_to_node(node, _get_weather_overlay_material(node))
|
||||
|
||||
for node in get_tree().get_nodes_in_group("weather_vegetables_node"):
|
||||
if _should_clear_weather_overlay(node):
|
||||
_clear_weather_overlay_from_node(node)
|
||||
_apply_weather_overlay_to_node(node, _get_weather_overlay_material(node))
|
||||
|
||||
func _get_weather_overlay_material(node: Node) -> Material:
|
||||
if not node.is_in_group("weather_overlay_no_noise"):
|
||||
@@ -185,12 +184,12 @@ func _get_weather_overlay_material(node: Node) -> Material:
|
||||
return weather_shader_no_noise
|
||||
|
||||
func _apply_weather_overlay_to_node(node: Node, material: Material) -> void:
|
||||
if _should_clear_weather_overlay(node):
|
||||
if _should_ignore_weather_overlay(node):
|
||||
_clear_weather_overlay_from_node(node)
|
||||
return
|
||||
|
||||
if node is GeometryInstance3D:
|
||||
if _geometry_uses_alpha_texture(node):
|
||||
if _should_clear_weather_overlay(node) or _geometry_uses_alpha_texture(node):
|
||||
node.material_overlay = null
|
||||
else:
|
||||
node.material_overlay = material
|
||||
@@ -230,8 +229,11 @@ func _shader_material_uses_alpha_texture(material: ShaderMaterial) -> bool:
|
||||
|
||||
return material.shader.code.find("alpha_texture") != -1
|
||||
|
||||
func _should_ignore_weather_overlay(node: Node) -> bool:
|
||||
return node.is_in_group("weather_overlay_ignore")
|
||||
|
||||
func _should_clear_weather_overlay(node: Node) -> bool:
|
||||
return node.is_in_group("weather_vegetables_node") or node.is_in_group("weather_overlay_ignore")
|
||||
return node.is_in_group("weather_vegetables_node")
|
||||
|
||||
func select_day_time(normalized_time: float) -> void:
|
||||
#set show_day_time_debug = true to show debug on screen
|
||||
|
||||
@@ -158,6 +158,8 @@ extends Resource
|
||||
@export_group("Train Start")
|
||||
@export var train_start_from_random_position: bool = true #When enabled the train starts from a random offset on the rail curve instead of a stop
|
||||
@export_range(0, 64, 1, "or_greater") var train_start_stop_index: int = 1 #Stop index used for the train start when random start is disabled
|
||||
@export var train_start_delay_seconds: float = 3.0 #Seconds the train waits before starting at game launch
|
||||
@export var train_start_acceleration_seconds: float = 4.0 #Seconds used to progressively reach normal train speed after launch
|
||||
|
||||
#Snow settings
|
||||
@export_group("Snow")
|
||||
|
||||
@@ -1,20 +1,47 @@
|
||||
extends Control
|
||||
|
||||
const TRAIN_WHISTLE_STREAM: AudioStream = preload("res://tgcc/train/sounds/train_whistle2.mp3")
|
||||
|
||||
@onready var play_button: Button = $%PlayButton
|
||||
@onready var resume_button: Button = $%ResumeButton
|
||||
@onready var settings_button: Button = $%SettingsButton
|
||||
@onready var save_button: Button = $%SaveButton
|
||||
@onready var quit_button: Button = $%QuitButton
|
||||
@export var fade_time: float = 0.5
|
||||
@export var menu_whistle_volume_db: float = -12.0
|
||||
|
||||
var _fallback_whistle_player: AudioStreamPlayer
|
||||
|
||||
func _ready() -> void:
|
||||
_create_fallback_whistle_player()
|
||||
play_button.pressed.connect(_on_play_button_pressed)
|
||||
save_button.pressed.connect(_on_save_button_pressed)
|
||||
quit_button.pressed.connect(_on_quit_button_pressed)
|
||||
|
||||
func _on_play_button_pressed() -> void:
|
||||
_play_train_horn()
|
||||
await get_tree().create_timer(fade_time).timeout
|
||||
SceneManager.change_scene(SceneConfig.SceneName.GAME)
|
||||
|
||||
func _create_fallback_whistle_player() -> void:
|
||||
_fallback_whistle_player = AudioStreamPlayer.new()
|
||||
_fallback_whistle_player.name = "FallbackTrainWhistlePlayer"
|
||||
_fallback_whistle_player.bus = &"SFX"
|
||||
_fallback_whistle_player.volume_db = menu_whistle_volume_db
|
||||
_fallback_whistle_player.stream = TRAIN_WHISTLE_STREAM
|
||||
add_child(_fallback_whistle_player)
|
||||
|
||||
func _play_train_horn() -> void:
|
||||
if not UIEvents.toot_toot.get_connections().is_empty():
|
||||
UIEvents.toot_toot.emit(false)
|
||||
return
|
||||
|
||||
if _fallback_whistle_player == null:
|
||||
return
|
||||
|
||||
_fallback_whistle_player.stop()
|
||||
_fallback_whistle_player.play()
|
||||
|
||||
func _on_save_button_pressed() -> void:
|
||||
GameState.save_game()
|
||||
|
||||
|
||||
@@ -35,8 +35,6 @@ 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()):
|
||||
|
||||
@@ -196,8 +196,8 @@ func _on_photo_taken_finished() -> void:
|
||||
StatsManager.store()
|
||||
|
||||
func _on_choo_choo_button_pressed() -> void:
|
||||
#play sfx
|
||||
pass
|
||||
UIEvents.toot_toot.emit(true)
|
||||
AchievementManager.is_unlocked("ACH_CHANGE_TRAIN_COLOR")
|
||||
|
||||
func _set_buttons_mouse_filter(ignore: bool) -> void:
|
||||
var filter = Control.MOUSE_FILTER_IGNORE if ignore else Control.MOUSE_FILTER_STOP
|
||||
|
||||
@@ -35,6 +35,8 @@ func _on_global_percentages_ready(_game: int, _result: int) -> void:
|
||||
pass
|
||||
|
||||
func unlock(api_name: String) -> void:
|
||||
if not SteamManager.is_on_steam:
|
||||
return
|
||||
if not KNOWN.has(api_name):
|
||||
push_warning("Achievement unknown: %s" % api_name)
|
||||
return
|
||||
@@ -47,17 +49,25 @@ func unlock(api_name: String) -> void:
|
||||
unlocked.emit(api_name)
|
||||
|
||||
func is_unlocked(api_name: String) -> bool:
|
||||
if not SteamManager.is_on_steam:
|
||||
return false
|
||||
var data: Dictionary = Steam.getAchievement(api_name)
|
||||
return data.get("achieved", false)
|
||||
|
||||
func get_display_name(api_name: String) -> String:
|
||||
if not SteamManager.is_on_steam:
|
||||
return ""
|
||||
return Steam.getAchievementDisplayAttribute(api_name, "name")
|
||||
|
||||
func get_description(api_name: String) -> String:
|
||||
if not SteamManager.is_on_steam:
|
||||
return ""
|
||||
return Steam.getAchievementDisplayAttribute(api_name, "desc")
|
||||
|
||||
#Global percentage of player who have unlocked the achievement
|
||||
func get_global_percent(api_name: String) -> float:
|
||||
if not SteamManager.is_on_steam:
|
||||
return 0.0
|
||||
var data: Dictionary = Steam.getAchievementAchievedPercent(api_name)
|
||||
if not data.get("ret", false):
|
||||
return -1.0 #global percentage not yet available
|
||||
@@ -65,9 +75,10 @@ func get_global_percent(api_name: String) -> float:
|
||||
|
||||
#for development only: reset an achievement
|
||||
func clear(api_name: String) -> void:
|
||||
if not SteamManager.is_on_steam:
|
||||
return
|
||||
Steam.clearAchievement(api_name)
|
||||
Steam.storeStats()
|
||||
|
||||
func _on_achievement_stored(_game: int, _group: bool, api_name: String,
|
||||
current: int, maximum: int) -> void:
|
||||
func _on_achievement_stored(_game: int, _group: bool, api_name: String, current: int, maximum: int) -> void:
|
||||
print("Achievement confirmed by server: %s (%d/%d)" % [api_name, current, maximum])
|
||||
|
||||
@@ -30,15 +30,21 @@ func _ready() -> void:
|
||||
Steam.user_stats_stored.connect(_on_stats_stored)
|
||||
|
||||
func get_int(stat: String) -> int:
|
||||
if not SteamManager.is_on_steam:
|
||||
return 0
|
||||
return Steam.getStatInt(stat)
|
||||
|
||||
func get_float(stat: String) -> float:
|
||||
if not SteamManager.is_on_steam:
|
||||
return 0.0
|
||||
return Steam.getStatFloat(stat)
|
||||
|
||||
func set_int(stat: String, value: int) -> void:
|
||||
if not KNOWN.has(stat):
|
||||
push_warning("Stat not found: %s" % stat)
|
||||
return
|
||||
if not SteamManager.is_on_steam:
|
||||
return
|
||||
|
||||
if not Steam.setStatInt(stat, value):
|
||||
push_error("setStatInt failed (incremental with value less than current value? is published on steam?): %s" % stat)
|
||||
@@ -52,18 +58,26 @@ func set_float(stat: String, value: float) -> void:
|
||||
push_error("setStatFloat failed: %s" % stat)
|
||||
|
||||
func add_int(stat: String, amount: int = 1) -> void:
|
||||
if not SteamManager.is_on_steam:
|
||||
return
|
||||
set_int(stat, get_int(stat) + amount)
|
||||
|
||||
func update_avg_rate(stat: String, count_this_session: float, session_length: float) -> void:
|
||||
if not SteamManager.is_on_steam:
|
||||
return
|
||||
Steam.updateAvgRateStat(stat, count_this_session, session_length)
|
||||
|
||||
#Send all data to server; call it at the end of the game of when exit
|
||||
func store() -> void:
|
||||
if not SteamManager.is_on_steam:
|
||||
return
|
||||
if not Steam.storeStats():
|
||||
push_error("storeStats failed; data saved locally")
|
||||
|
||||
#Development only: reset stats
|
||||
func reset_all(include_achievements: bool = false) -> void:
|
||||
if not SteamManager.is_on_steam:
|
||||
return
|
||||
if !Steam.resetAllStats(include_achievements):
|
||||
push_error("resetAllStats failed")
|
||||
|
||||
|
||||
@@ -46,4 +46,4 @@ signal day_time_option_changed(index: int)
|
||||
|
||||
#train signals
|
||||
@warning_ignore("unused_signal")
|
||||
signal toot_toot()
|
||||
signal toot_toot(update_stats: bool)
|
||||
|
||||
Reference in New Issue
Block a user