feat: working on train labels
This commit is contained in:
parent
2e473e4b4e
commit
2ceb9216e0
|
|
@ -52,6 +52,8 @@ signal train_left(track : Dolly)
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
reset()
|
reset()
|
||||||
|
|
||||||
|
func set_line(line: StringName):
|
||||||
|
subway.set_line(line)
|
||||||
|
|
||||||
## One arrival and departure
|
## One arrival and departure
|
||||||
func cycle() -> void:
|
func cycle() -> void:
|
||||||
|
|
|
||||||
|
|
@ -26,29 +26,28 @@ func _set_signage_texts(group: StringName, message: String) -> void:
|
||||||
await get_tree().create_timer(0.05).timeout
|
await get_tree().create_timer(0.05).timeout
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
var x : Station = $hirschfeld
|
|
||||||
print(x.name)
|
|
||||||
await get_tree().process_frame
|
await get_tree().process_frame
|
||||||
|
|
||||||
tracks[0].train_left.connect(_player_train_left)
|
tracks[0].train_left.connect(_player_train_left)
|
||||||
tracks[1].train_left.connect(_player_train_left)
|
tracks[1].train_left.connect(_player_train_left)
|
||||||
_unparent_all_stations_except($hirschfeld)
|
_unparent_all_stations_except($hirschfeld)
|
||||||
enter_station(current_station)
|
enter_station(current)
|
||||||
|
|
||||||
|
|
||||||
var current_station : Station = null
|
## The current station
|
||||||
|
var current : Station
|
||||||
var stop := false
|
var stop := false
|
||||||
|
|
||||||
var destinations : Array[Station] = [null, null]
|
var destinations : Array[Station] = [null, null]
|
||||||
|
|
||||||
## Begins the scheduled traffic (looping through the list of destinations) on a given track
|
## Begins the scheduled traffic (looping through the list of destinations) on a given track
|
||||||
func _begin_traffic_loop(track: Dolly, cancel: Array) -> void:
|
func _begin_traffic_loop(track: Dolly, cancel: Array) -> void:
|
||||||
if not track.player_on_board and fahrplan[current_station][track.index] == null: # empty trains dont arrive at endstation
|
if not track.player_on_board and fahrplan[current][track.index] == null: # empty trains dont arrive at endstation
|
||||||
track.arrive(true)
|
track.arrive(true)
|
||||||
_set_signage_texts(track.signage_group, "Endstation")
|
_set_signage_texts(track.signage_group, "Endstation")
|
||||||
return
|
return
|
||||||
|
|
||||||
var routes : Array = fahrplan[current_station][track.index]
|
var routes : Array = fahrplan[current][track.index]
|
||||||
if routes.is_empty():
|
if routes.is_empty():
|
||||||
_set_signage_texts(track.signage_group, "Verkehr z. Zt.\nunregelmäßig")
|
_set_signage_texts(track.signage_group, "Verkehr z. Zt.\nunregelmäßig")
|
||||||
return
|
return
|
||||||
|
|
@ -56,11 +55,15 @@ func _begin_traffic_loop(track: Dolly, cancel: Array) -> void:
|
||||||
while true:
|
while true:
|
||||||
if cancel.is_empty(): return # abort the loop
|
if cancel.is_empty(): return # abort the loop
|
||||||
|
|
||||||
var next : Node = routes.pop_front()
|
var line : StringName = routes.pop_front()
|
||||||
|
var next : Station = routes.pop_front()
|
||||||
|
|
||||||
|
routes.append(line) # It's a ring buffer
|
||||||
routes.append(next) # It's a ring buffer
|
routes.append(next) # It's a ring buffer
|
||||||
|
|
||||||
destinations[track.index] = next
|
destinations[track.index] = next
|
||||||
_set_signage_texts(track.signage_group, next.name) # TODO: load nice string
|
track.set_line(line)
|
||||||
|
_set_signage_texts(track.signage_group, current.get_label(line, next)) # TODO: load nice string
|
||||||
|
|
||||||
# Vary our schedule a little by making empty trains wait a random amount of time
|
# Vary our schedule a little by making empty trains wait a random amount of time
|
||||||
if not track.player_on_board:
|
if not track.player_on_board:
|
||||||
|
|
@ -72,11 +75,11 @@ func _begin_traffic_loop(track: Dolly, cancel: Array) -> void:
|
||||||
|
|
||||||
var cancellation_token : Array
|
var cancellation_token : Array
|
||||||
|
|
||||||
func enter_station(station: Node):
|
func enter_station(station: Station):
|
||||||
prints("------------", "ENTER STATION", station, station.name, "------------")
|
prints("------------", "ENTER STATION", station, station.name, "------------")
|
||||||
remove_child(current_station)
|
remove_child(current)
|
||||||
current_station = station
|
current = station
|
||||||
add_child(current_station)
|
add_child(station)
|
||||||
|
|
||||||
cancellation_token = ["go"] # Allocate a new stopping token
|
cancellation_token = ["go"] # Allocate a new stopping token
|
||||||
_begin_traffic_loop(tracks[0], cancellation_token)
|
_begin_traffic_loop(tracks[0], cancellation_token)
|
||||||
|
|
@ -89,9 +92,9 @@ func _player_train_left(track: Dolly) -> void:
|
||||||
|
|
||||||
func _unparent_all_stations_except(except : Node3D):
|
func _unparent_all_stations_except(except : Node3D):
|
||||||
for station in stations:
|
for station in stations:
|
||||||
if station == except:
|
|
||||||
current_station = station
|
|
||||||
continue
|
|
||||||
assert(station.get_parent() == self, "A station that isn't a child of Fahrplan is in the Fahrplan: %s" % station.name)
|
assert(station.get_parent() == self, "A station that isn't a child of Fahrplan is in the Fahrplan: %s" % station.name)
|
||||||
remove_child(station)
|
|
||||||
station.visible = true # Make visible by default, parenting handles visibility and collision
|
station.visible = true # Make visible by default, parenting handles visibility and collision
|
||||||
|
if station == except:
|
||||||
|
current = station
|
||||||
|
continue
|
||||||
|
remove_child(station)
|
||||||
|
|
|
||||||
|
|
@ -3,3 +3,6 @@ class_name Station
|
||||||
|
|
||||||
@export var i18n_key : StringName
|
@export var i18n_key : StringName
|
||||||
@export var train_labels : Dictionary[StringName,String] = {}
|
@export var train_labels : Dictionary[StringName,String] = {}
|
||||||
|
|
||||||
|
func get_label(line: StringName, next_stop: Station) -> String:
|
||||||
|
return train_labels.get(line+next_stop.name, line+next_stop.name)
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
extends Room
|
extends Room
|
||||||
class_name SubwaySequence
|
class_name SubwaySequence
|
||||||
|
|
||||||
@export var all_stations: Dictionary[Station.id, Station]
|
|
||||||
@export var all_lines: Dictionary[TrainLine.id, TrainLine]
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
id = State.rooms.TRANSITION
|
id = State.rooms.TRANSITION
|
||||||
super._ready()
|
super._ready()
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
extends Node3D
|
extends Node3D
|
||||||
class_name SubwayTrain
|
class_name SubwayTrain
|
||||||
|
|
||||||
|
@export var materials : Dictionary[StringName, Material] = {}
|
||||||
|
|
||||||
@export var door_open: bool:
|
@export var door_open: bool:
|
||||||
set(open):
|
set(open):
|
||||||
if door_open == open: return
|
if door_open == open: return
|
||||||
|
|
@ -11,3 +13,9 @@ class_name SubwayTrain
|
||||||
%TrainModel/AnimationPlayer.play("door_close")
|
%TrainModel/AnimationPlayer.play("door_close")
|
||||||
|
|
||||||
%FrontWallClosed.disabled = door_open
|
%FrontWallClosed.disabled = door_open
|
||||||
|
|
||||||
|
|
||||||
|
func set_line(line : StringName):
|
||||||
|
$TrainModel/traun_hull.material_overlay = materials[line]
|
||||||
|
get_tree().call_group("labels", "set_text", line.to_upper())
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
class_name TrainLine extends Resource
|
|
||||||
|
|
||||||
enum id {
|
|
||||||
NONE,
|
|
||||||
RING,
|
|
||||||
U2,
|
|
||||||
U3,
|
|
||||||
U8
|
|
||||||
}
|
|
||||||
|
|
||||||
@export var train_id: id = id.NONE
|
|
||||||
@export var destination: StringName = ""
|
|
||||||
@export var via: StringName = ""
|
|
||||||
@export var stops: Dictionary[Station, float]
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
uid://dfkq0djtygmma
|
|
||||||
|
|
@ -233,14 +233,14 @@ signage_group = "signage1"
|
||||||
script = ExtResource("4_yfan7")
|
script = ExtResource("4_yfan7")
|
||||||
metadata/_custom_type_script = "uid://bi4cwmajhpa5f"
|
metadata/_custom_type_script = "uid://bi4cwmajhpa5f"
|
||||||
|
|
||||||
[node name="hirschfeld" parent="Logic/Fahrplan" instance=ExtResource("5_rum2v")]
|
[node name="hirschfeld" parent="Logic/Fahrplan" groups=["signage1"] instance=ExtResource("5_rum2v")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.015596004, 0.007891655, -0.018885009)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.015596004, 0.007891655, -0.018885009)
|
||||||
script = ExtResource("10_iq74k")
|
script = ExtResource("10_iq74k")
|
||||||
i18n_key = &"Hirschfeld-Str."
|
i18n_key = &"Hirschfeld-Str."
|
||||||
train_labels = Dictionary[StringName, String]({
|
train_labels = Dictionary[StringName, String]({
|
||||||
&"u1lise_meitner": "U1 Ring ↺",
|
&"u1lise_meitner": "U1 Ring ↺",
|
||||||
&"u1parity_square": "U1 Ring ↻",
|
&"u1parity_square": "U1 Ring ↻",
|
||||||
&"u2station_university_mens": "U2 Ambitz"
|
&"u2uni_mensa": "U2 Ambitz"
|
||||||
})
|
})
|
||||||
|
|
||||||
[node name="VoxelGI" type="VoxelGI" parent="Logic/Fahrplan/hirschfeld"]
|
[node name="VoxelGI" type="VoxelGI" parent="Logic/Fahrplan/hirschfeld"]
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,15 @@
|
||||||
[gd_scene load_steps=25 format=3 uid="uid://df3ur5wll8vx7"]
|
[gd_scene load_steps=31 format=3 uid="uid://df3ur5wll8vx7"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://4j1tlhfm3p40" path="res://base-environments/transition/subway_train.tscn" id="1_2h2xx"]
|
[ext_resource type="PackedScene" uid="uid://4j1tlhfm3p40" path="res://base-environments/transition/subway_train.tscn" id="1_2h2xx"]
|
||||||
[ext_resource type="Script" uid="uid://dgfje4druu3sw" path="res://base-environments/transition/code/dolly.gd" id="1_5jpg8"]
|
[ext_resource type="Script" uid="uid://dgfje4druu3sw" path="res://base-environments/transition/code/dolly.gd" id="1_5jpg8"]
|
||||||
[ext_resource type="Script" uid="uid://cyohujvfoiof7" path="res://base-environments/transition/code/subway_train.gd" id="2_aacjs"]
|
[ext_resource type="Script" uid="uid://cyohujvfoiof7" path="res://base-environments/transition/code/subway_train.gd" id="2_aacjs"]
|
||||||
[ext_resource type="AudioStream" uid="uid://cwfr6sgcwg7sl" path="res://base-environments/transition/audio/450918__kyles__metro-subway-montreal-verdun-station-arrive-and-leave-semidistant-from-bridge-over-tracks-overpass.ogg" id="3_4h0n7"]
|
[ext_resource type="AudioStream" uid="uid://cwfr6sgcwg7sl" path="res://base-environments/transition/audio/450918__kyles__metro-subway-montreal-verdun-station-arrive-and-leave-semidistant-from-bridge-over-tracks-overpass.ogg" id="3_4h0n7"]
|
||||||
|
[ext_resource type="Material" uid="uid://cl7e6lpjalm0c" path="res://base-environments/transition/shaders/u1.material" id="3_j8pin"]
|
||||||
|
[ext_resource type="Material" uid="uid://c0baqy42xdxtg" path="res://base-environments/transition/shaders/u2.material" id="4_3w708"]
|
||||||
|
[ext_resource type="Material" uid="uid://bw4y5b5lnw3cn" path="res://base-environments/transition/shaders/u4.material" id="5_3x5rc"]
|
||||||
|
[ext_resource type="Material" uid="uid://cor0uho8hnfqc" path="res://base-environments/transition/shaders/u7.material" id="6_ckebf"]
|
||||||
|
[ext_resource type="Material" uid="uid://d0kk76pja0orj" path="res://base-environments/transition/shaders/u8.material" id="7_dyyau"]
|
||||||
|
[ext_resource type="FontFile" uid="uid://b231f0liphck" path="res://import/fonts/AtkinsonHyperlegible-Regular.ttf" id="10_3w708"]
|
||||||
|
|
||||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_aacjs"]
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_aacjs"]
|
||||||
shading_mode = 0
|
shading_mode = 0
|
||||||
|
|
@ -122,6 +128,13 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -150)
|
||||||
|
|
||||||
[node name="Subway" type="Node3D" parent="."]
|
[node name="Subway" type="Node3D" parent="."]
|
||||||
script = ExtResource("2_aacjs")
|
script = ExtResource("2_aacjs")
|
||||||
|
materials = Dictionary[StringName, Material]({
|
||||||
|
&"u1": ExtResource("3_j8pin"),
|
||||||
|
&"u2": ExtResource("4_3w708"),
|
||||||
|
&"u4": ExtResource("5_3x5rc"),
|
||||||
|
&"u7": ExtResource("6_ckebf"),
|
||||||
|
&"u8": ExtResource("7_dyyau")
|
||||||
|
})
|
||||||
metadata/_custom_type_script = "uid://cyohujvfoiof7"
|
metadata/_custom_type_script = "uid://cyohujvfoiof7"
|
||||||
|
|
||||||
[node name="WarpEffecScreen" type="MeshInstance3D" parent="Subway"]
|
[node name="WarpEffecScreen" type="MeshInstance3D" parent="Subway"]
|
||||||
|
|
@ -174,7 +187,18 @@ playback_type = 1
|
||||||
[node name="TrainModel" parent="Subway" instance=ExtResource("1_2h2xx")]
|
[node name="TrainModel" parent="Subway" instance=ExtResource("1_2h2xx")]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -3.4114173e-08, 0, -0.7804413)
|
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -3.4114173e-08, 0, -0.7804413)
|
||||||
script = null
|
|
||||||
|
[node name="Label3D" type="Label3D" parent="Subway/TrainModel" groups=["labels"]]
|
||||||
|
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, -15.413577, 2.7434583, -6.737489e-07)
|
||||||
|
text = "U0"
|
||||||
|
font = ExtResource("10_3w708")
|
||||||
|
font_size = 64
|
||||||
|
|
||||||
|
[node name="Label3D2" type="Label3D" parent="Subway/TrainModel" groups=["labels"]]
|
||||||
|
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 15.410003, 2.7434583, 6.9981036e-07)
|
||||||
|
text = "U0"
|
||||||
|
font = ExtResource("10_3w708")
|
||||||
|
font_size = 64
|
||||||
|
|
||||||
[node name="Collider" type="AnimatableBody3D" parent="Subway"]
|
[node name="Collider" type="AnimatableBody3D" parent="Subway"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
[gd_scene load_steps=15 format=4 uid="uid://4j1tlhfm3p40"]
|
[gd_scene load_steps=14 format=4 uid="uid://4j1tlhfm3p40"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://dmh8tmuvftqus" path="res://base-environments/transition/import/subway_train.glb" id="1_8e51f"]
|
[ext_resource type="PackedScene" uid="uid://dmh8tmuvftqus" path="res://base-environments/transition/import/subway_train.glb" id="1_8e51f"]
|
||||||
[ext_resource type="Material" uid="uid://dchm78gv31r6a" path="res://base-environments/transition/shaders/timetravel.tres" id="2_g5p57"]
|
[ext_resource type="Material" uid="uid://dchm78gv31r6a" path="res://base-environments/transition/shaders/timetravel.tres" id="2_g5p57"]
|
||||||
[ext_resource type="Script" uid="uid://cyohujvfoiof7" path="res://base-environments/transition/code/subway_train.gd" id="2_skiem"]
|
|
||||||
[ext_resource type="Material" uid="uid://ddw7mob1qmlbj" path="res://base-environments/transition/shaders/u0.material" id="3_81crm"]
|
[ext_resource type="Material" uid="uid://ddw7mob1qmlbj" path="res://base-environments/transition/shaders/u0.material" id="3_81crm"]
|
||||||
[ext_resource type="Material" uid="uid://rh1lc61j6qd8" path="res://base-environments/transition/import/textures/roof_greeble.tres" id="3_q0ort"]
|
[ext_resource type="Material" uid="uid://rh1lc61j6qd8" path="res://base-environments/transition/import/textures/roof_greeble.tres" id="3_q0ort"]
|
||||||
[ext_resource type="Texture2D" uid="uid://bewykr0twbplg" path="res://base-environments/transition/import/textures/LateralTren_baseColor_upscayl_2x_realesrgan-x4plus-anime.png" id="5_6pwip"]
|
[ext_resource type="Texture2D" uid="uid://bewykr0twbplg" path="res://base-environments/transition/import/textures/LateralTren_baseColor_upscayl_2x_realesrgan-x4plus-anime.png" id="5_6pwip"]
|
||||||
|
|
@ -137,7 +136,6 @@ _data = {
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="subway_train" instance=ExtResource("1_8e51f")]
|
[node name="subway_train" instance=ExtResource("1_8e51f")]
|
||||||
script = ExtResource("2_skiem")
|
|
||||||
|
|
||||||
[node name="traun_hull" parent="." index="0"]
|
[node name="traun_hull" parent="." index="0"]
|
||||||
transform = Transform3D(-1, 0, -8.742278e-08, 0, 1, 0, 8.742278e-08, 0, -1, 0, 0, 0)
|
transform = Transform3D(-1, 0, -8.742278e-08, 0, 1, 0, 8.742278e-08, 0, -1, 0, 0, 0)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue