generate new main menu screen
This commit is contained in:
@@ -126,15 +126,22 @@ func _apply_initial_train_start() -> void:
|
||||
if total_length <= 0.0:
|
||||
return
|
||||
|
||||
#start from a random position
|
||||
if environment_config != null and environment_config.train_start_from_random_position:
|
||||
train_progress = randf() * total_length
|
||||
_update_next_stop_index_from_progress()
|
||||
elif environment_config != null and not stop_offset.is_empty():
|
||||
#start from a specific stop
|
||||
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)
|
||||
if environment_config != null:
|
||||
match environment_config.train_start_from_random_position:
|
||||
EnvironmentConfig.TrainStartMode.RANDOM_POSITION:
|
||||
train_progress = randf() * 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()
|
||||
@@ -145,16 +152,22 @@ 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)
|
||||
if start_delay_seconds <= 0.0:
|
||||
if not should_start_after_delay:
|
||||
is_inmotion = false
|
||||
return
|
||||
|
||||
is_inmotion = false
|
||||
await get_tree().create_timer(start_delay_seconds).timeout
|
||||
if not is_inside_tree():
|
||||
return
|
||||
if not should_start_after_delay:
|
||||
return
|
||||
|
||||
is_inmotion = _initial_is_inmotion
|
||||
|
||||
@@ -285,6 +298,9 @@ func _plan_stops() -> void:
|
||||
stops_position.append(data["position"])
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if EnvironmentManagerRoot.is_keyboard_input_blocked(get_tree()):
|
||||
return
|
||||
|
||||
if event is InputEventKey and event.pressed and not event.echo:
|
||||
if event.keycode == KEY_T:
|
||||
_goto_next_stop()
|
||||
@@ -323,6 +339,7 @@ func _physics_process(delta: float) -> void:
|
||||
|
||||
func input_controls_management(delta: float) -> void:
|
||||
if not is_inmotion: return
|
||||
if EnvironmentManagerRoot.is_keyboard_input_blocked(get_tree()): return
|
||||
if Input.is_action_pressed("ui_up"):
|
||||
train_speed += manual_acceleration * delta
|
||||
elif Input.is_action_pressed("ui_down"):
|
||||
|
||||
Reference in New Issue
Block a user