Version: Beta ⚠️
Path Streams
PathStreams visually guide players to important locations within the game world.
If you have key (dynamic) locations you want players to easily find, you can integrate with the PathStream system.
Setting up a PathStream
There are two methods for setting up a PathStream, depending on the number of target positions you need to display.
Single PathStream
If you only have a single (dynamic) target position, use the SinglePathStream component.
PathStreamBasics.kt
class SingleDisplayEntry(
override val id: String = "",
override val name: String = "",
private val road: Ref<RoadNetworkEntry> = emptyRef(),
private val display: Ref<PathStreamDisplayEntry> = emptyRef(),
val target: Position = Position.ORIGIN,
) : AudienceEntry {
override suspend fun display(): AudienceDisplay =
SinglePathStreamDisplay(
road,
{ display },
endPosition = { target }
)
}
Multi PathStream
For multiple (dynamic) target positions, use the MultiPathStream component.
PathStreamBasics.kt
class MultiDisplayEntry(
override val id: String = "",
override val name: String = "",
private val road: Ref<RoadNetworkEntry> = emptyRef(),
private val display: Ref<PathStreamDisplayEntry> = emptyRef(),
private val targets: List<Position> = emptyList(),
) : AudienceEntry {
override suspend fun display(): AudienceDisplay =
MultiPathStreamDisplay(road) { player ->
targets.mapIndexed { index, target ->
StreamProducer(
// ID must stay consistent between calls to this supplier.
// It is used to efficiently manage the display.
id = "$index",
display,
// Though the location itself can change, even dynamically,
endPosition = { target }
)
}
}
}
warning
The MultiPathStream component's callback function is invoked every tick to determine if the targets should still be displayed.
Ensure this call is efficient! Pre-calculate as much information as possible using lazy properties.