Reference
ToolTopology
Track traversal using observed distances and connections.
Usage context
| Module | Package | SDK source |
|---|---|---|
| Kotlin/Native | nimby | kotlin/src/nimby/ToolTopology.kt |
Public API for SDK 0.9.0-alpha.2. Each entry provides the Kotlin signature and its contract: what the value means, conditions of use and effects to understand. Choose imports from the module shown above.
import nimby.ToolTrackEnd
import nimby.ToolTrackConnection
import nimby.ToolRouteTrack
import nimby.ToolTopology
import nimby.topologyToolTrackEnd
enum class ToolTrackEnd {
A,
B
}Geometric end of a track, independent of a train’s current direction.
ToolTrackEnd.A
AGeometric origin: fraction zero and distance zero. A traversal entering at A continues towards B.
ToolTrackEnd.B
BOther end: fraction one and distance equal to the length. A traversal entering at B continues towards A.
ToolTrackConnection
sealed interface ToolTrackConnectionTyped observed-connection result: usable Join, explicitly handled Junction, or Unknown. Selects no junction branch.
ToolTrackConnection.Unknown
data object Unknown : ToolTrackConnectionInsufficiently known, absent or ambiguous connection, or one leading to a track without usable length. Does not mean a dead end; stop traversal.
ToolTrackConnection.Junction
data object Junction : ToolTrackConnectionA junction occupies this end. The SDK does not select a branch; your tool must stop or apply an explicit routing policy.
ToolTrackConnection.Join
data class Join(val trackId: Long, val entry: ToolTrackEnd) : ToolTrackConnectionReciprocal connection to a known track with usable length. entry identifies the arrival end on that other track.
ToolTrackConnection.Join.trackId
val trackId: LongIdentifier of the next track in this topology, resolved with track(trackId).
ToolTrackConnection.Join.entry
val entry: ToolTrackEndEnd through which traversal enters the next track. A implies movement towards B, and conversely.
ToolRouteTrack
data class ToolRouteTrack(
val id: Long,
val lengthM: Double,
val a: ToolTrackConnection,
val b: ToolTrackConnection,
val junctionOffsetsM: List<Double>,
)Track view usable for distance calculation: known length, typed connections and junction positions. Interior junctions must also be checked.
ToolRouteTrack.id
val id: LongIdentifier stable within the topology copy; does not authorize building in the world’s current state.
ToolRouteTrack.lengthM
val lengthM: DoubleFinite, strictly positive length in metres; tracks without known length are excluded from this view.
ToolRouteTrack.a
val a: ToolTrackConnectionTyped connection at end A; also inspect junctionOffsetsM before reaching that end.
ToolRouteTrack.b
val b: ToolTrackConnectionTyped connection at end B; no branch is selected implicitly.
ToolRouteTrack.junctionOffsetsM
val junctionOffsetsM: List<Double>Sorted junction positions in metres from A, including trailing connections. An empty list describes this copy only.
ToolRouteTrack.connection
fun connection(end: ToolTrackEnd): ToolTrackConnectionReturns a or b for the requested end without rereading the network or selecting a branch.
ToolTopology
class ToolTopologyIndexed copy obtained through ToolNetwork.topology. Omits tracks without known length and their signals, leaving connections unknown. Reuse it for calculation, then reread before mutation; construction is reserved for the SDK.
ToolTopology.worldId
val worldId: StringWorld identity of the original copy. Compare it with the context before reusing a plan.
ToolTopology.generation
val generation: LongTopology session generation, retained from ToolNetwork.
ToolTopology.tracks
val tracks: List<ToolRouteTrack>Known-length tracks with typed connections. For a short route, prefer track(id) to repeatedly searching the entire list.
ToolTopology.signals
val signals: List<ToolSignal>Signals attached to usable tracks in this topology; those on omitted tracks are not retained here.
ToolTopology.track
fun track(id: Long): ToolRouteTrack?Looks up a track by ID in the copy; null if absent or without known length. Triggers no game read.
ToolTopology.signal
fun signal(id: Long): ToolSignal?Looks up a retained signal in the copy; null if absent or attached to an omitted track. Does not prove in-game deletion.
topology
fun ToolNetwork.topology(): ToolTopologyValidates the copy and prepares distance, junction and connection lookups. Rejects duplicate identities and invalid lengths, fractions or directions. Absent or ambiguous links become Unknown; takes no additional capture.