finish fixing the schema
This commit is contained in:
parent
524aa218fc
commit
4d94e2f395
6 changed files with 32 additions and 28 deletions
|
|
@ -1,5 +1,6 @@
|
|||
package dev.adamko.kafkatorio.events.schema
|
||||
|
||||
import kotlinx.serialization.EncodeDefault
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
|
|
@ -22,12 +23,16 @@ enum class PositionType {
|
|||
*/
|
||||
@Serializable
|
||||
data class Colour(
|
||||
@EncodeDefault
|
||||
val red: Float = 0f,
|
||||
@EncodeDefault
|
||||
val green: Float = 0f,
|
||||
@EncodeDefault
|
||||
val blue: Float = 0f,
|
||||
@EncodeDefault
|
||||
val alpha: Float = 1f,
|
||||
) {
|
||||
|
||||
|
||||
/** True if any value is greater than 1, so the values are hexadecimal. */
|
||||
fun isDecimal(): Boolean {
|
||||
return red > 1f
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@ data class FactorioMapTilePrototype(
|
|||
val mapColor: Colour,
|
||||
val collisionMasks: List<String>,
|
||||
val order: String,
|
||||
|
||||
/** Can the tile be mined for resources? */
|
||||
val canBeMined: Boolean,
|
||||
) : FactorioPrototype() {
|
||||
|
|
|
|||
|
|
@ -20,19 +20,19 @@ class FactorioEventTest : FunSpec({
|
|||
"associatedCharactersUnitNumbers": {},
|
||||
"position": {
|
||||
"type": "MAP",
|
||||
"x": 30.65625,
|
||||
"y": 84.07421875
|
||||
"x": 30.6,
|
||||
"y": 84.1
|
||||
},
|
||||
"colour": {
|
||||
"red": 0.869000017642974853515625,
|
||||
"red": 0.86,
|
||||
"green": 0.5,
|
||||
"blue": 0.12999999523162841796875,
|
||||
"blue": 0.12,
|
||||
"alpha": 0.5
|
||||
},
|
||||
"chatColour": {
|
||||
"red": 1,
|
||||
"green": 0.62999999523162841796875,
|
||||
"blue": 0.259000003337860107421875,
|
||||
"green": 0.62,
|
||||
"blue": 0.25,
|
||||
"alpha": 1
|
||||
},
|
||||
"lastOnline": 2287061
|
||||
|
|
@ -55,19 +55,19 @@ class FactorioEventTest : FunSpec({
|
|||
associatedCharactersUnitNumbers = emptyList(),
|
||||
position = PositionData(
|
||||
type = PositionType.MAP,
|
||||
x = 30.65625,
|
||||
y = 84.07421875,
|
||||
x = 30.6,
|
||||
y = 84.1,
|
||||
),
|
||||
colour = Colour(
|
||||
red = 0.869000017642974853515625f,
|
||||
red = 0.86f,
|
||||
green = 0.5f,
|
||||
blue = 0.12999999523162841796875f,
|
||||
blue = 0.12f,
|
||||
alpha = 0.5f
|
||||
),
|
||||
chatColour = Colour(
|
||||
red = 1f,
|
||||
green = 0.62999999523162841796875f,
|
||||
blue = 0.259000003337860107421875f,
|
||||
green = 0.62f,
|
||||
blue = 0.25f,
|
||||
alpha = 1f
|
||||
),
|
||||
lastOnline = 2287061u
|
||||
|
|
@ -97,7 +97,7 @@ class FactorioEventTest : FunSpec({
|
|||
"objectName": "LuaSurface",
|
||||
"name": "nauvis",
|
||||
"index": 1,
|
||||
"daytime": 0.749480000092057618843455202295444905757904052734375
|
||||
"daytime": 0.745
|
||||
},
|
||||
"packetType": "EVENT",
|
||||
"eventType": "on_tick",
|
||||
|
|
@ -115,7 +115,7 @@ class FactorioEventTest : FunSpec({
|
|||
data = SurfaceData(
|
||||
name = "nauvis",
|
||||
index = 1u,
|
||||
daytime = 0.749480000092057618843455202295444905757904052734375
|
||||
daytime = 0.745
|
||||
),
|
||||
eventType = "on_tick",
|
||||
modVersion = "0.2.1",
|
||||
|
|
@ -149,8 +149,8 @@ class FactorioEventTest : FunSpec({
|
|||
"unitNumber": 1,
|
||||
"position": {
|
||||
"type": "MAP",
|
||||
"x": 37.859375,
|
||||
"y": 81.14453125
|
||||
"x": 37.5,
|
||||
"y": 81.1
|
||||
}
|
||||
},
|
||||
"packetType": "EVENT",
|
||||
|
|
@ -175,8 +175,8 @@ class FactorioEventTest : FunSpec({
|
|||
unitNumber = 1u,
|
||||
playerIndex = null,
|
||||
position = PositionData(
|
||||
x = 37.859375,
|
||||
y = 81.14453125,
|
||||
x = 37.5,
|
||||
y = 81.1,
|
||||
type = PositionType.MAP,
|
||||
)
|
||||
),
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class KafkatorioTopology(
|
|||
{ _, value, _ ->
|
||||
// println("[$key] sending event:${value.eventType} to topic:${value.data.objectName()}")
|
||||
when (value) {
|
||||
is FactorioEvent<*> ->
|
||||
is FactorioEvent ->
|
||||
"kafkatorio.${value.packetType.name}.${value.data.objectName.name}"
|
||||
is FactorioConfigurationUpdate ->
|
||||
"kafkatorio.${value.packetType.name}"
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ data class FactorioGameState(
|
|||
|
||||
|
||||
sealed class FactorioUpdate : RAction {
|
||||
data class PlayerUpdate(val event: FactorioEvent<*>, val playerData: PlayerData) :
|
||||
data class PlayerUpdate(val event: FactorioEvent, val playerData: PlayerData) :
|
||||
FactorioUpdate()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ import dev.adamko.kafkatorio.events.schema.ConsoleChatMessage
|
|||
import dev.adamko.kafkatorio.events.schema.EntityData
|
||||
import dev.adamko.kafkatorio.events.schema.FactorioConfigurationUpdate
|
||||
import dev.adamko.kafkatorio.events.schema.FactorioEvent
|
||||
import dev.adamko.kafkatorio.events.schema.KafkatorioPacket
|
||||
import dev.adamko.kafkatorio.events.schema.MapChunk
|
||||
import dev.adamko.kafkatorio.events.schema.MapTile
|
||||
import dev.adamko.kafkatorio.events.schema.KafkatorioPacket
|
||||
import dev.adamko.kafkatorio.events.schema.PlayerData
|
||||
import dev.adamko.kafkatorio.events.schema.SurfaceData
|
||||
import io.kvision.redux.ReduxStore
|
||||
|
|
@ -37,15 +37,15 @@ class WebsocketService(
|
|||
println(data.replace('\n', ' '))
|
||||
|
||||
when (val event: KafkatorioPacket = jsonMapper.decodeFromString(data)) {
|
||||
is FactorioEvent<*> -> {
|
||||
is FactorioEvent -> {
|
||||
when (val eventData = event.data) {
|
||||
is PlayerData ->
|
||||
reduxStore.dispatch(FactorioUpdate.PlayerUpdate(event, eventData))
|
||||
is ConsoleChatMessage -> {}
|
||||
is EntityData -> {}
|
||||
is MapChunk -> {}
|
||||
is MapTile -> {}
|
||||
is SurfaceData -> {}
|
||||
is EntityData -> {}
|
||||
is MapChunk -> {}
|
||||
is MapTile -> {}
|
||||
is SurfaceData -> {}
|
||||
}
|
||||
}
|
||||
is FactorioConfigurationUpdate -> {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue