trigger tile png reload in browser by sending 'saved tile' events over websocket
- create new EventServerPacket for websocket packet data - move common models to events-schema
This commit is contained in:
parent
b15382660b
commit
8c37a0cef9
19 changed files with 303 additions and 108 deletions
|
|
@ -75,3 +75,10 @@ data class EntityIdentifiersData(
|
|||
override val name: String,
|
||||
override val protoType: String,
|
||||
) : EntityIdentifiers
|
||||
|
||||
|
||||
@JvmInline
|
||||
@Serializable
|
||||
value class FactorioServerId(private val id: String) {
|
||||
override fun toString() = id
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
package dev.adamko.kafkatorio.schema.common
|
||||
|
||||
|
||||
import dev.adamko.kafkatorio.schema.common.MapTileDictionary.PrototypeKey
|
||||
import kotlin.jvm.JvmInline
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
const val MAP_CHUNK_SIZE = 32
|
||||
|
||||
|
||||
|
|
@ -69,3 +69,27 @@ data class MapBoundingBox(
|
|||
val topLeft: MapTilePosition,
|
||||
val bottomRight: MapTilePosition,
|
||||
)
|
||||
|
||||
|
||||
@Serializable
|
||||
data class ServerMapChunkId(
|
||||
val serverId: FactorioServerId,
|
||||
val chunkPosition: MapChunkPosition,
|
||||
val surfaceIndex: SurfaceIndex,
|
||||
val chunkSize: ChunkSize,
|
||||
)
|
||||
|
||||
|
||||
@Serializable
|
||||
@JvmInline
|
||||
value class TilePngFilename(
|
||||
val value: String,
|
||||
) {
|
||||
constructor(id: ServerMapChunkId) : this(buildString {
|
||||
append("s${id.surfaceIndex}")
|
||||
append("/z${id.chunkSize.zoomLevel}")
|
||||
append("/x${id.chunkPosition.x}")
|
||||
append("/y${id.chunkPosition.y}")
|
||||
append(".png")
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
package dev.adamko.kafkatorio.schema.packets
|
||||
|
||||
import dev.adamko.kafkatorio.schema.common.ServerMapChunkId
|
||||
import dev.adamko.kafkatorio.schema.common.TilePngFilename
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@Serializable
|
||||
sealed class EventServerPacket {
|
||||
|
||||
|
||||
@Serializable
|
||||
@SerialName("kafkatorio.event-server-packet.Kafkatorio")
|
||||
data class Kafkatorio(
|
||||
val packet: KafkatorioPacket
|
||||
) : EventServerPacket()
|
||||
|
||||
|
||||
@Serializable
|
||||
@SerialName("kafkatorio.event-server-packet.ChunkTileSaved")
|
||||
data class ChunkTileSaved(
|
||||
val chunkId: ServerMapChunkId,
|
||||
val filename: TilePngFilename,
|
||||
) : EventServerPacket()
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue