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