- add tile deconstruction (concrete tiles can be removed)

- add @SerialName to all packets
- start implementing Entity prototype
- start implementing Entity updates
- clean up some old commented out code
- refactor how debounced events track the triggering events (now include timestamps per event)
- bump tstl
This commit is contained in:
Adam 2022-05-07 20:29:24 +02:00
parent 5656acd350
commit 688b2c7bcb
30 changed files with 650 additions and 553 deletions

View file

@ -2,10 +2,10 @@ package dev.adamko.kafkatorio.processor.topology
import dev.adamko.kafkatorio.processor.serdes.kxsBinary
import dev.adamko.kafkatorio.schema.common.ColourHex
import dev.adamko.kafkatorio.schema.common.FactorioPrototype
import dev.adamko.kafkatorio.schema.common.MapTile
import dev.adamko.kafkatorio.schema.common.toHex
import dev.adamko.kafkatorio.schema.packets.PrototypesUpdate
import dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype
import dev.adamko.kotka.extensions.materializedAs
import dev.adamko.kotka.extensions.repartitionedAs
import dev.adamko.kotka.extensions.streams.filter

View file

@ -17,7 +17,7 @@ import dev.adamko.kafkatorio.schema.packets.KafkatorioPacket
import dev.adamko.kafkatorio.schema.packets.MapChunkUpdate
import dev.adamko.kafkatorio.schema.packets.MapChunkUpdateKey
import dev.adamko.kafkatorio.schema.packets.PrototypesUpdate
import dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype
import dev.adamko.kafkatorio.schema.common.FactorioPrototype
import dev.adamko.kotka.kxs.serde
import io.kotest.assertions.withClue
import io.kotest.core.spec.style.FunSpec
@ -289,7 +289,7 @@ class GroupMapChunksTest : FunSpec({
"modVersion": "0.4.0",
"tick": 36,
"data": {
"type": "dev.adamko.kafkatorio.schema.packets.MapChunkUpdate",
"type": "kafkatorio.packet.keyed.MapChunkUpdate",
"key": {
"chunkPosition": [
-7,
@ -297,8 +297,8 @@ class GroupMapChunksTest : FunSpec({
],
"surfaceIndex": 1
},
"eventCounts": {
"on_chunk_generated": 1
"events": {
"on_chunk_generated": [1]
},
"tileDictionary": {
"tilesXY": {
@ -1407,10 +1407,10 @@ class GroupMapChunksTest : FunSpec({
"modVersion": "0.4.0",
"tick": 4352,
"data": {
"type": "dev.adamko.kafkatorio.schema.packets.PrototypesUpdate",
"type": "kafkatorio.packet.instant.PrototypesUpdate",
"prototypes": [
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "stone-path",
"layer": 60,
"mapColour": [
@ -1426,7 +1426,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": true
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "concrete",
"layer": 61,
"mapColour": [
@ -1442,7 +1442,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": true
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "hazard-concrete-left",
"layer": 62,
"mapColour": [
@ -1458,7 +1458,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": true
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "hazard-concrete-right",
"layer": 62,
"mapColour": [
@ -1474,7 +1474,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": true
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "refined-concrete",
"layer": 64,
"mapColour": [
@ -1490,7 +1490,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": true
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "refined-hazard-concrete-left",
"layer": 65,
"mapColour": [
@ -1506,7 +1506,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": true
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "refined-hazard-concrete-right",
"layer": 65,
"mapColour": [
@ -1522,7 +1522,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": true
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "landfill",
"layer": 57,
"mapColour": [
@ -1538,7 +1538,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "acid-refined-concrete",
"layer": 97,
"mapColour": [
@ -1554,7 +1554,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "black-refined-concrete",
"layer": 88,
"mapColour": [
@ -1570,7 +1570,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "blue-refined-concrete",
"layer": 73,
"mapColour": [
@ -1586,7 +1586,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "brown-refined-concrete",
"layer": 91,
"mapColour": [
@ -1602,7 +1602,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "cyan-refined-concrete",
"layer": 94,
"mapColour": [
@ -1618,7 +1618,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "green-refined-concrete",
"layer": 70,
"mapColour": [
@ -1634,7 +1634,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "orange-refined-concrete",
"layer": 76,
"mapColour": [
@ -1650,7 +1650,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "pink-refined-concrete",
"layer": 82,
"mapColour": [
@ -1666,7 +1666,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "purple-refined-concrete",
"layer": 85,
"mapColour": [
@ -1682,7 +1682,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "red-refined-concrete",
"layer": 67,
"mapColour": [
@ -1698,7 +1698,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "yellow-refined-concrete",
"layer": 79,
"mapColour": [
@ -1714,7 +1714,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "grass-1",
"layer": 26,
"mapColour": [
@ -1730,7 +1730,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "grass-2",
"layer": 28,
"mapColour": [
@ -1746,7 +1746,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "grass-3",
"layer": 29,
"mapColour": [
@ -1762,7 +1762,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "grass-4",
"layer": 30,
"mapColour": [
@ -1778,7 +1778,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "dry-dirt",
"layer": 18,
"mapColour": [
@ -1794,7 +1794,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "dirt-1",
"layer": 19,
"mapColour": [
@ -1810,7 +1810,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "dirt-2",
"layer": 20,
"mapColour": [
@ -1826,7 +1826,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "dirt-3",
"layer": 21,
"mapColour": [
@ -1842,7 +1842,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "dirt-4",
"layer": 22,
"mapColour": [
@ -1858,7 +1858,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "dirt-5",
"layer": 23,
"mapColour": [
@ -1874,7 +1874,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "dirt-6",
"layer": 24,
"mapColour": [
@ -1890,7 +1890,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "dirt-7",
"layer": 25,
"mapColour": [
@ -1906,7 +1906,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "sand-1",
"layer": 8,
"mapColour": [
@ -1922,7 +1922,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "sand-2",
"layer": 9,
"mapColour": [
@ -1938,7 +1938,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "sand-3",
"layer": 10,
"mapColour": [
@ -1954,7 +1954,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "red-desert-0",
"layer": 31,
"mapColour": [
@ -1970,7 +1970,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "red-desert-1",
"layer": 14,
"mapColour": [
@ -1986,7 +1986,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "red-desert-2",
"layer": 15,
"mapColour": [
@ -2002,7 +2002,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "red-desert-3",
"layer": 16,
"mapColour": [
@ -2018,7 +2018,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "water",
"layer": 3,
"mapColour": [
@ -2038,7 +2038,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "deepwater",
"layer": 3,
"mapColour": [
@ -2058,7 +2058,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "water-green",
"layer": 3,
"mapColour": [
@ -2078,7 +2078,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "deepwater-green",
"layer": 3,
"mapColour": [
@ -2098,7 +2098,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "water-shallow",
"layer": 6,
"mapColour": [
@ -2117,7 +2117,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "water-mud",
"layer": 7,
"mapColour": [
@ -2136,7 +2136,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "nuclear-ground",
"layer": 33,
"mapColour": [
@ -2152,7 +2152,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "water-wube",
"layer": 2,
"mapColour": [
@ -2172,7 +2172,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "tile-unknown",
"layer": 0,
"mapColour": [
@ -2186,7 +2186,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "out-of-map",
"layer": 0,
"mapColour": [
@ -2209,7 +2209,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "lab-dark-1",
"layer": 70,
"mapColour": [
@ -2225,7 +2225,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "lab-dark-2",
"layer": 70,
"mapColour": [
@ -2241,7 +2241,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "lab-white",
"layer": 70,
"mapColour": [
@ -2257,7 +2257,7 @@ class GroupMapChunksTest : FunSpec({
"canBeMined": false
},
{
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
"type": "kafkatorio.prototype.MapTile",
"name": "tutorial-grid",
"layer": 55,
"mapColour": [

View file

@ -35,7 +35,6 @@ class SaveMapChunksTest : FunSpec({
test("save tile") {
Scenario().use { scenario ->
val chunkTilesArb = serverMapChunkTilesArb(scenario.serverId)
@ -79,7 +78,7 @@ class SaveMapChunksTest : FunSpec({
Path("build/test/save-map-chunks-${now}")
}
private val topology = saveMapTiles(streamsBuilder, outputDir)
val testDriver: TopologyTestDriver = TopologyTestDriver(topology)
private val testDriver: TopologyTestDriver = TopologyTestDriver(topology)
val groupedMapChunksInputTopic: TestInputTopic<ServerMapChunkId, ServerMapChunkTiles<ColourHex>> =
testDriver.createInputTopic(
@ -99,21 +98,14 @@ class SaveMapChunksTest : FunSpec({
companion object {
fun mapTilePositionArb(
xArb: Arb<Int> = Arb.int(),
yArb: Arb<Int> = Arb.int(),
): Arb<MapTilePosition> = arbitrary {
MapTilePosition(xArb.bind(), yArb.bind())
}
fun mapChunkPositionArb(
private fun mapChunkPositionArb(
xArb: Arb<Int> = Arb.int(-10..10),
yArb: Arb<Int> = Arb.int(-10..10),
): Arb<MapChunkPosition> = arbitrary {
MapChunkPosition(xArb.bind(), yArb.bind())
}
fun colourHexArb(
private fun colourHexArb(
redArb: Arb<UByte> = Arb.uByte(),
greenArb: Arb<UByte> = Arb.uByte(),
blueArb: Arb<UByte> = Arb.uByte(),
@ -123,18 +115,11 @@ class SaveMapChunksTest : FunSpec({
redArb.bind(),
greenArb.bind(),
blueArb.bind(),
// alphaArb.bind(),
255u,
alphaArb.bind(),
)
// ColourHex(
// 255u,
// 0u,
// 0u,
// 255u,
// )
}
fun serverMapChunkIdArb(
private fun serverMapChunkIdArb(
serverId: FactorioServerId,
chunkPosition: Arb<MapChunkPosition> = mapChunkPositionArb(),
surfaceIndex: SurfaceIndex = SurfaceIndex(1u),
@ -148,7 +133,7 @@ class SaveMapChunksTest : FunSpec({
)
}
fun tilesInChunkArb(
private fun tilesInChunkArb(
chunkId: ServerMapChunkId
): Arb<Map<MapTilePosition, ColourHex>> = arbitrary {