set main manu play event
This commit is contained in:
@@ -87,6 +87,8 @@ const RIVER_NEIGHBOUR_OFFSETS: Dictionary = {
|
||||
@export_range(1, 6, 1) var lamppost_search_radius_cells: int = 3
|
||||
##max allowed distance between lamppost pairs
|
||||
@export var lamppost_max_wire_distance: float = 35.0
|
||||
##minimum horizontal distance between generated wires and the railway centerline
|
||||
@export var lamppost_rail_clearance_distance: float = 4.0
|
||||
##if true wire connections blocked by colliders are discarded
|
||||
@export var lamppost_obstacle_check_enabled: bool = true
|
||||
|
||||
@@ -1423,6 +1425,25 @@ func _get_wire_sample_point(p1: Vector3, p2: Vector3, t: float) -> Vector3:
|
||||
point.y -= gravity
|
||||
return point
|
||||
|
||||
func _is_wire_too_close_to_rail(p1: Vector3, p2: Vector3) -> bool:
|
||||
if rail_path == null or rail_path.curve == null:
|
||||
return false
|
||||
if lamppost_rail_clearance_distance <= 0.0:
|
||||
return false
|
||||
|
||||
var clearance_sq: float = lamppost_rail_clearance_distance * lamppost_rail_clearance_distance
|
||||
var samples: int = 10
|
||||
for i in range(samples + 1):
|
||||
var t: float = float(i) / float(samples)
|
||||
var wire_point: Vector3 = _get_wire_sample_point(p1, p2, t)
|
||||
var rail_local_point: Vector3 = rail_path.to_local(wire_point)
|
||||
var closest_rail_point: Vector3 = rail_path.to_global(rail_path.curve.get_closest_point(rail_local_point))
|
||||
var horizontal_delta := Vector2(wire_point.x - closest_rail_point.x, wire_point.z - closest_rail_point.z)
|
||||
if horizontal_delta.length_squared() < clearance_sq:
|
||||
return true
|
||||
|
||||
return false
|
||||
|
||||
func _collect_wire_excluded_rids(root: Node, excluded_rids: Array[RID]) -> void:
|
||||
if root == null:
|
||||
return
|
||||
@@ -1441,6 +1462,9 @@ func _get_wire_excluded_rids(excluded_roots: Array) -> Array[RID]:
|
||||
return excluded_rids
|
||||
|
||||
func _is_wire_path_blocked(p1: Vector3, p2: Vector3, excluded_roots: Array = []) -> bool:
|
||||
if _is_wire_too_close_to_rail(p1, p2):
|
||||
return true
|
||||
|
||||
if not lamppost_obstacle_check_enabled:
|
||||
return false
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ const STEAM_DISTANCE_STAT: String = "stat_distance_km"
|
||||
const DISTANCE_KM_PER_UNIT: float = 0.01
|
||||
const STATION_STOP_GROUP: StringName = &"railway_station"
|
||||
|
||||
enum TrainStartMode { RANDOM_POSITION, SPECIFIED_STATION, SPECIFIED_POSITION }
|
||||
|
||||
@export_group("Train")
|
||||
##train speed
|
||||
@export var train_speed: float = 6.0
|
||||
@@ -32,6 +34,14 @@ const STATION_STOP_GROUP: StringName = &"railway_station"
|
||||
##swing of the train during the ran
|
||||
@export_range(0.0, 1.0) var basic_swing: float = 0.1
|
||||
|
||||
@export_group("Train Start")
|
||||
@export_enum("random_position", "specified_station", "specified_position") var train_start_mode: int = TrainStartMode.RANDOM_POSITION
|
||||
@export_range(0, 64, 1, "or_greater") var train_start_stop_index: int = 1
|
||||
@export var train_start_position: float = 0.0
|
||||
@export var train_start_delay_seconds: float = 0.0
|
||||
@export var train_start_after_delay: bool = true
|
||||
@export var train_start_acceleration_seconds: float = 4.0
|
||||
|
||||
@export_group("Rails Bulding")
|
||||
##distance between sleepers of the rails
|
||||
@export var sleepers_distance: float = 1.0
|
||||
@@ -84,7 +94,6 @@ var next_stop_index: int = 0
|
||||
var stop_multiply: float = 1.0
|
||||
var is_restarting: bool = false
|
||||
var tween_restart: Tween
|
||||
var environment_config: EnvironmentConfig
|
||||
var wagon_instances: Array[Node3D] = []
|
||||
var wagon_progress_offsets: Array[float] = []
|
||||
var _pending_steam_distance_km: float = 0.0
|
||||
@@ -96,7 +105,6 @@ func _ready() -> void:
|
||||
GameState.on_enable_photo_mode_request.connect(func(): _is_photo_mode_active = true)
|
||||
GameState.on_disable_photo_mode_request.connect(func(): _is_photo_mode_active = false)
|
||||
|
||||
_cache_environment_config()
|
||||
_initial_is_inmotion = is_inmotion
|
||||
|
||||
if curve != null and curve.get_baked_length() > 0:
|
||||
@@ -108,24 +116,6 @@ func _ready() -> void:
|
||||
else:
|
||||
print("WARNING: Draw Path3D for rails!")
|
||||
|
||||
func _cache_environment_config() -> void:
|
||||
var parent_node: Node = get_parent()
|
||||
if parent_node != null:
|
||||
var day_night_node := parent_node.get_node_or_null("DayNight") as EnvironmentManagerRoot
|
||||
if day_night_node != null:
|
||||
environment_config = day_night_node.environment_config
|
||||
return
|
||||
|
||||
var current_scene: Node = get_tree().current_scene
|
||||
if current_scene == null:
|
||||
return
|
||||
|
||||
for child in current_scene.get_children():
|
||||
var environment_manager := child as EnvironmentManagerRoot
|
||||
if environment_manager != null:
|
||||
environment_config = environment_manager.environment_config
|
||||
return
|
||||
|
||||
func _apply_initial_train_start() -> void:
|
||||
if train_instance == null or curve == null:
|
||||
return
|
||||
@@ -134,25 +124,21 @@ func _apply_initial_train_start() -> void:
|
||||
if total_length <= 0.0:
|
||||
return
|
||||
|
||||
if environment_config != null:
|
||||
match environment_config.train_start_from_random_position:
|
||||
EnvironmentConfig.TrainStartMode.RANDOM_POSITION:
|
||||
train_progress = randf() * total_length
|
||||
match train_start_mode:
|
||||
TrainStartMode.RANDOM_POSITION:
|
||||
train_progress = randf() * total_length
|
||||
_update_next_stop_index_from_progress()
|
||||
TrainStartMode.SPECIFIED_STATION:
|
||||
if stop_offset.is_empty():
|
||||
train_progress = wrapf(train_progress, 0.0, total_length)
|
||||
_update_next_stop_index_from_progress()
|
||||
EnvironmentConfig.TrainStartMode.SPECIFIED_STATION:
|
||||
if stop_offset.is_empty():
|
||||
train_progress = wrapf(train_progress, 0.0, total_length)
|
||||
_update_next_stop_index_from_progress()
|
||||
else:
|
||||
var stop_index: int = clampi(environment_config.train_start_stop_index, 0, stop_offset.size() - 1)
|
||||
train_progress = stop_offset[stop_index]
|
||||
_set_next_stop_index_from_current(stop_index)
|
||||
EnvironmentConfig.TrainStartMode.SPECIFIED_POSITION:
|
||||
train_progress = wrapf(environment_config.train_start_position, 0.0, total_length)
|
||||
_update_next_stop_index_from_progress()
|
||||
else:
|
||||
train_progress = wrapf(train_progress, 0.0, total_length)
|
||||
_update_next_stop_index_from_progress()
|
||||
else:
|
||||
var stop_index: int = clampi(train_start_stop_index, 0, stop_offset.size() - 1)
|
||||
train_progress = stop_offset[stop_index]
|
||||
_set_next_stop_index_from_current(stop_index)
|
||||
TrainStartMode.SPECIFIED_POSITION:
|
||||
train_progress = wrapf(train_start_position, 0.0, total_length)
|
||||
_update_next_stop_index_from_progress()
|
||||
|
||||
_snap_train_to_progress()
|
||||
|
||||
@@ -160,11 +146,8 @@ func _apply_train_start_delay() -> void:
|
||||
if not _initial_is_inmotion:
|
||||
return
|
||||
|
||||
var should_start_after_delay: bool = true
|
||||
var start_delay_seconds: float = 0.0
|
||||
if environment_config != null:
|
||||
should_start_after_delay = environment_config.train_start_after_delay
|
||||
start_delay_seconds = maxf(environment_config.train_start_delay_seconds, 0.0)
|
||||
var should_start_after_delay: bool = train_start_after_delay
|
||||
var start_delay_seconds: float = maxf(train_start_delay_seconds, 0.0)
|
||||
if start_delay_seconds <= 0.0:
|
||||
if not should_start_after_delay:
|
||||
is_inmotion = false
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
class_name EnvironmentConfig
|
||||
extends Resource
|
||||
|
||||
enum TrainStartMode { RANDOM_POSITION, SPECIFIED_STATION, SPECIFIED_POSITION }
|
||||
|
||||
@export_group("Day")
|
||||
@export var start_time: float = 0.0 #start time of the day
|
||||
@export var day_duration: float = 300.0 #Duration of a full day cycle in seconds
|
||||
@@ -157,15 +155,6 @@ enum TrainStartMode { RANDOM_POSITION, SPECIFIED_STATION, SPECIFIED_POSITION }
|
||||
@export var godray_spawn_height: float = 5.0 #Y world position where god rays spawn
|
||||
@export var godray_scale: Vector3 = Vector3(2.0, 6.0, 2.0) #Scale of the god ray mesh
|
||||
|
||||
#Train start settings
|
||||
@export_group("Train Start")
|
||||
@export_enum("random_position", "specified_station", "specified_position") var train_start_from_random_position: int = TrainStartMode.RANDOM_POSITION #Train start mode
|
||||
@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_position: float = 0.0 #Offset on the rail curve used when train_start_from_random_position is specified_position
|
||||
@export var train_start_delay_seconds: float = 0.0 #Seconds the train waits before starting at game launch
|
||||
@export var train_start_after_delay: bool = true #When enabled the train starts after train_start_delay_seconds, otherwise it stays stopped
|
||||
@export var train_start_acceleration_seconds: float = 4.0 #Seconds used to progressively reach normal train speed after launch
|
||||
|
||||
#Snow settings
|
||||
@export_group("Snow")
|
||||
@export var snow_amount: float = 0.0 #Initial snow coverage amount (0.0 = none, 1.0 = full)
|
||||
|
||||
Reference in New Issue
Block a user