start tidying up after schema->schema2 migration
This commit is contained in:
parent
448dd4a5b8
commit
8bf393f9c3
10 changed files with 507 additions and 499 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
// Generated by TypeScriptGenerator - do not edit this file manually
|
// Generated by kxs-ts-gen - do not edit this file manually
|
||||||
|
|
||||||
export interface KafkatorioPacket2 {
|
export interface KafkatorioPacket2 {
|
||||||
modVersion: string;
|
modVersion: string;
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,8 @@
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "~14.19.1"
|
"node": "~14.19.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {},
|
"devDependencies": {
|
||||||
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"lua-types": "^2.11.0",
|
"lua-types": "^2.11.0",
|
||||||
"typescript-to-lua": "1.4.3",
|
"typescript-to-lua": "1.4.3",
|
||||||
|
|
@ -18,7 +19,10 @@
|
||||||
},
|
},
|
||||||
"// @types/node": "^12.0.8",
|
"// @types/node": "^12.0.8",
|
||||||
"license": "UNLICENSED",
|
"license": "UNLICENSED",
|
||||||
"peerDependencies": {},
|
"peerDependencies": {
|
||||||
"optionalDependencies": {},
|
},
|
||||||
"bundledDependencies": []
|
"optionalDependencies": {
|
||||||
|
},
|
||||||
|
"bundledDependencies": [
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,68 +1,68 @@
|
||||||
package dev.adamko.kafkatorio.schema.events
|
package dev.adamko.kafkatorio.schema.events
|
||||||
|
//
|
||||||
import dev.adamko.kafkatorio.schema.SerializerProvider
|
//import dev.adamko.kafkatorio.schema.SerializerProvider
|
||||||
import dev.adamko.kafkatorio.schema.SerializerProviderDeserializer
|
//import dev.adamko.kafkatorio.schema.SerializerProviderDeserializer
|
||||||
import dev.adamko.kafkatorio.schema.common.Tick
|
//import dev.adamko.kafkatorio.schema.common.Tick
|
||||||
import kotlin.reflect.KClass
|
//import kotlin.reflect.KClass
|
||||||
import kotlin.reflect.KType
|
//import kotlin.reflect.KType
|
||||||
import kotlin.reflect.typeOf
|
//import kotlin.reflect.typeOf
|
||||||
import kotlinx.serialization.KSerializer
|
//import kotlinx.serialization.KSerializer
|
||||||
import kotlinx.serialization.Serializable
|
//import kotlinx.serialization.Serializable
|
||||||
|
//
|
||||||
|
//
|
||||||
|
////@Serializable
|
||||||
|
////data class KafkatorioPacket(
|
||||||
|
//// val modVersion: String,
|
||||||
|
//// val tick: Tick,
|
||||||
|
//// val data: KafkatorioPacketData,
|
||||||
|
////)
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//@Serializable(with = KafkatorioPacketData.JsonSerializer::class)
|
||||||
|
//sealed class KafkatorioPacketData {
|
||||||
|
// abstract val updateType: KafkatorioPacketDataType
|
||||||
|
//
|
||||||
|
// object JsonSerializer : SerializerProviderDeserializer<KafkatorioPacketData>(
|
||||||
|
// KafkatorioPacketData::class,
|
||||||
|
// KafkatorioPacketData::updateType.name,
|
||||||
|
// { json -> KafkatorioPacketDataType.entries.firstOrNull { it.name == json } }
|
||||||
|
// )
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
|
///** Discriminator for [KafkatorioPacketData] */
|
||||||
//@Serializable
|
//@Serializable
|
||||||
//data class KafkatorioPacket(
|
//enum class KafkatorioPacketDataType(
|
||||||
// val modVersion: String,
|
// override val serializer: KSerializer<out KafkatorioPacketData>
|
||||||
// val tick: Tick,
|
//) : SerializerProvider<KafkatorioPacketData> {
|
||||||
// val data: KafkatorioPacketData,
|
//
|
||||||
//)
|
// // non-keyed
|
||||||
|
// CONFIG(ConfigurationUpdate.serializer()),
|
||||||
|
// CONSOLE_CHAT(ConsoleChatUpdate.serializer()),
|
||||||
@Serializable(with = KafkatorioPacketData.JsonSerializer::class)
|
// CONSOLE_COMMAND(ConsoleCommandUpdate.serializer()),
|
||||||
sealed class KafkatorioPacketData {
|
// PROTOTYPES(PrototypesUpdate.serializer()),
|
||||||
abstract val updateType: KafkatorioPacketDataType
|
// SURFACE(SurfaceUpdate.serializer()),
|
||||||
|
//
|
||||||
object JsonSerializer : SerializerProviderDeserializer<KafkatorioPacketData>(
|
// // keyed
|
||||||
KafkatorioPacketData::class,
|
// ENTITY(EntityUpdate.serializer()),
|
||||||
KafkatorioPacketData::updateType.name,
|
// MAP_CHUNK(MapChunkUpdate.serializer()),
|
||||||
{ json -> KafkatorioPacketDataType.entries.firstOrNull { it.name == json } }
|
// PLAYER(PlayerUpdate.serializer()),
|
||||||
)
|
// ;
|
||||||
}
|
//
|
||||||
|
// companion object {
|
||||||
|
// val entries: Set<KafkatorioPacketDataType> = values().toSet()
|
||||||
/** Discriminator for [KafkatorioPacketData] */
|
|
||||||
@Serializable
|
|
||||||
enum class KafkatorioPacketDataType(
|
|
||||||
override val serializer: KSerializer<out KafkatorioPacketData>
|
|
||||||
) : SerializerProvider<KafkatorioPacketData> {
|
|
||||||
|
|
||||||
// non-keyed
|
|
||||||
CONFIG(ConfigurationUpdate.serializer()),
|
|
||||||
CONSOLE_CHAT(ConsoleChatUpdate.serializer()),
|
|
||||||
CONSOLE_COMMAND(ConsoleCommandUpdate.serializer()),
|
|
||||||
PROTOTYPES(PrototypesUpdate.serializer()),
|
|
||||||
SURFACE(SurfaceUpdate.serializer()),
|
|
||||||
|
|
||||||
// keyed
|
|
||||||
ENTITY(EntityUpdate.serializer()),
|
|
||||||
MAP_CHUNK(MapChunkUpdate.serializer()),
|
|
||||||
PLAYER(PlayerUpdate.serializer()),
|
|
||||||
;
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
val entries: Set<KafkatorioPacketDataType> = values().toSet()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//inline fun <reified T: KafkatorioPacketData> KafkatorioPacketDataType.isType (): KClass<out T> {
|
|
||||||
// return when (this) {
|
|
||||||
// KafkatorioPacketDataType.CONFIG -> ConfigurationUpdate::class
|
|
||||||
// KafkatorioPacketDataType.CONSOLE_CHAT -> ConsoleChatUpdate::class
|
|
||||||
// KafkatorioPacketDataType.CONSOLE_COMMAND -> ConsoleCommandUpdate::class
|
|
||||||
// KafkatorioPacketDataType.PROTOTYPES -> PrototypesUpdate::class
|
|
||||||
// KafkatorioPacketDataType.SURFACE -> SurfaceUpdate::class
|
|
||||||
// KafkatorioPacketDataType.ENTITY -> EntityUpdate::class
|
|
||||||
// KafkatorioPacketDataType.MAP_CHUNK -> MapChunkUpdate::class
|
|
||||||
// KafkatorioPacketDataType.PLAYER -> PlayerUpdate::class
|
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
//
|
||||||
|
////inline fun <reified T: KafkatorioPacketData> KafkatorioPacketDataType.isType (): KClass<out T> {
|
||||||
|
//// return when (this) {
|
||||||
|
//// KafkatorioPacketDataType.CONFIG -> ConfigurationUpdate::class
|
||||||
|
//// KafkatorioPacketDataType.CONSOLE_CHAT -> ConsoleChatUpdate::class
|
||||||
|
//// KafkatorioPacketDataType.CONSOLE_COMMAND -> ConsoleCommandUpdate::class
|
||||||
|
//// KafkatorioPacketDataType.PROTOTYPES -> PrototypesUpdate::class
|
||||||
|
//// KafkatorioPacketDataType.SURFACE -> SurfaceUpdate::class
|
||||||
|
//// KafkatorioPacketDataType.ENTITY -> EntityUpdate::class
|
||||||
|
//// KafkatorioPacketDataType.MAP_CHUNK -> MapChunkUpdate::class
|
||||||
|
//// KafkatorioPacketDataType.PLAYER -> PlayerUpdate::class
|
||||||
|
//// }
|
||||||
|
////}
|
||||||
|
|
|
||||||
|
|
@ -1,95 +1,95 @@
|
||||||
package dev.adamko.kafkatorio.schema.events
|
package dev.adamko.kafkatorio.schema.events
|
||||||
|
//
|
||||||
import dev.adamko.kafkatorio.schema.common.PlayerIndex
|
//import dev.adamko.kafkatorio.schema.common.PlayerIndex
|
||||||
import dev.adamko.kafkatorio.schema.common.SurfaceIndex
|
//import dev.adamko.kafkatorio.schema.common.SurfaceIndex
|
||||||
import dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype
|
//import dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype
|
||||||
import kotlinx.serialization.EncodeDefault
|
//import kotlinx.serialization.EncodeDefault
|
||||||
import kotlinx.serialization.Serializable
|
//import kotlinx.serialization.Serializable
|
||||||
|
//
|
||||||
|
//
|
||||||
/** No key, no caching. Must be sent instantly. */
|
///** No key, no caching. Must be sent instantly. */
|
||||||
sealed class KafkatorioInstantPacketData : KafkatorioPacketData()
|
//sealed class KafkatorioInstantPacketData : KafkatorioPacketData()
|
||||||
|
//
|
||||||
|
//
|
||||||
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
|
///* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
|
||||||
|
//
|
||||||
|
//
|
||||||
@Serializable
|
//@Serializable
|
||||||
data class ConfigurationUpdate(
|
//data class ConfigurationUpdate(
|
||||||
val factorioData: ConfigurationUpdateGameData,
|
// val factorioData: ConfigurationUpdateGameData,
|
||||||
val allMods: List<ConfigurationUpdateModData>,
|
// val allMods: List<ConfigurationUpdateModData>,
|
||||||
val modStartupSettingsChange: Boolean,
|
// val modStartupSettingsChange: Boolean,
|
||||||
val migrationApplied: Boolean,
|
// val migrationApplied: Boolean,
|
||||||
) : KafkatorioInstantPacketData() {
|
//) : KafkatorioInstantPacketData() {
|
||||||
@EncodeDefault
|
// @EncodeDefault
|
||||||
override val updateType: KafkatorioPacketDataType = KafkatorioPacketDataType.CONFIG
|
// override val updateType: KafkatorioPacketDataType = KafkatorioPacketDataType.CONFIG
|
||||||
|
//
|
||||||
@Serializable
|
// @Serializable
|
||||||
data class ConfigurationUpdateGameData(
|
// data class ConfigurationUpdateGameData(
|
||||||
val oldVersion: String? = null,
|
// val oldVersion: String? = null,
|
||||||
val newVersion: String? = null,
|
// val newVersion: String? = null,
|
||||||
)
|
// )
|
||||||
|
//
|
||||||
@Serializable
|
// @Serializable
|
||||||
data class ConfigurationUpdateModData(
|
// data class ConfigurationUpdateModData(
|
||||||
val modName: String,
|
// val modName: String,
|
||||||
val currentVersion: String? = null,
|
// val currentVersion: String? = null,
|
||||||
val previousVersion: String? = null,
|
// val previousVersion: String? = null,
|
||||||
)
|
// )
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
|
///* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
|
||||||
|
//
|
||||||
|
//
|
||||||
@Serializable
|
//@Serializable
|
||||||
data class ConsoleChatUpdate(
|
//data class ConsoleChatUpdate(
|
||||||
val authorPlayerIndex: PlayerIndex?,
|
// val authorPlayerIndex: PlayerIndex?,
|
||||||
val content: String,
|
// val content: String,
|
||||||
) : KafkatorioInstantPacketData() {
|
//) : KafkatorioInstantPacketData() {
|
||||||
@EncodeDefault
|
// @EncodeDefault
|
||||||
override val updateType: KafkatorioPacketDataType = KafkatorioPacketDataType.CONSOLE_CHAT
|
// override val updateType: KafkatorioPacketDataType = KafkatorioPacketDataType.CONSOLE_CHAT
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
|
///* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
|
||||||
|
//
|
||||||
|
//
|
||||||
@Serializable
|
//@Serializable
|
||||||
data class ConsoleCommandUpdate(
|
//data class ConsoleCommandUpdate(
|
||||||
val authorPlayerIndex: PlayerIndex?,
|
// val authorPlayerIndex: PlayerIndex?,
|
||||||
val command: String,
|
// val command: String,
|
||||||
val parameters: String,
|
// val parameters: String,
|
||||||
) : KafkatorioInstantPacketData() {
|
//) : KafkatorioInstantPacketData() {
|
||||||
@EncodeDefault
|
// @EncodeDefault
|
||||||
override val updateType: KafkatorioPacketDataType = KafkatorioPacketDataType.CONSOLE_COMMAND
|
// override val updateType: KafkatorioPacketDataType = KafkatorioPacketDataType.CONSOLE_COMMAND
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
|
///* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
|
||||||
|
//
|
||||||
|
//
|
||||||
@Serializable
|
//@Serializable
|
||||||
data class PrototypesUpdate(
|
//data class PrototypesUpdate(
|
||||||
val prototypes: List<FactorioPrototype>,
|
// val prototypes: List<FactorioPrototype>,
|
||||||
) : KafkatorioInstantPacketData() {
|
//) : KafkatorioInstantPacketData() {
|
||||||
@EncodeDefault
|
// @EncodeDefault
|
||||||
override val updateType: KafkatorioPacketDataType = KafkatorioPacketDataType.PROTOTYPES
|
// override val updateType: KafkatorioPacketDataType = KafkatorioPacketDataType.PROTOTYPES
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
|
///* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
|
||||||
|
//
|
||||||
|
//
|
||||||
@Serializable
|
//@Serializable
|
||||||
data class SurfaceUpdate(
|
//data class SurfaceUpdate(
|
||||||
val index: SurfaceIndex,
|
// val index: SurfaceIndex,
|
||||||
val daytime: Double,
|
// val daytime: Double,
|
||||||
val name: String,
|
// val name: String,
|
||||||
) : KafkatorioInstantPacketData() {
|
//) : KafkatorioInstantPacketData() {
|
||||||
@EncodeDefault
|
// @EncodeDefault
|
||||||
override val updateType: KafkatorioPacketDataType = KafkatorioPacketDataType.SURFACE
|
// override val updateType: KafkatorioPacketDataType = KafkatorioPacketDataType.SURFACE
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
|
///* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
|
||||||
|
|
|
||||||
|
|
@ -1,135 +1,135 @@
|
||||||
package dev.adamko.kafkatorio.schema.events
|
package dev.adamko.kafkatorio.schema.events
|
||||||
|
|
||||||
import dev.adamko.kafkatorio.schema.common.Colour
|
//import dev.adamko.kafkatorio.schema.common.Colour
|
||||||
import dev.adamko.kafkatorio.schema.common.EntityIdentifiers
|
//import dev.adamko.kafkatorio.schema.common.EntityIdentifiers
|
||||||
import dev.adamko.kafkatorio.schema.common.EntityIdentifiersData
|
//import dev.adamko.kafkatorio.schema.common.EntityIdentifiersData
|
||||||
import dev.adamko.kafkatorio.schema.common.ForceIndex
|
//import dev.adamko.kafkatorio.schema.common.ForceIndex
|
||||||
import dev.adamko.kafkatorio.schema.common.MapChunkPosition
|
//import dev.adamko.kafkatorio.schema.common.MapChunkPosition
|
||||||
import dev.adamko.kafkatorio.schema.common.MapEntityPosition
|
//import dev.adamko.kafkatorio.schema.common.MapEntityPosition
|
||||||
import dev.adamko.kafkatorio.schema.common.MapTileDictionary
|
//import dev.adamko.kafkatorio.schema.common.MapTileDictionary
|
||||||
import dev.adamko.kafkatorio.schema.common.PlayerIndex
|
//import dev.adamko.kafkatorio.schema.common.PlayerIndex
|
||||||
import dev.adamko.kafkatorio.schema.common.PrototypeName
|
//import dev.adamko.kafkatorio.schema.common.PrototypeName
|
||||||
import dev.adamko.kafkatorio.schema.common.SurfaceIndex
|
//import dev.adamko.kafkatorio.schema.common.SurfaceIndex
|
||||||
import dev.adamko.kafkatorio.schema.common.Tick
|
//import dev.adamko.kafkatorio.schema.common.Tick
|
||||||
import dev.adamko.kafkatorio.schema.common.UnitNumber
|
//import dev.adamko.kafkatorio.schema.common.UnitNumber
|
||||||
import kotlinx.serialization.EncodeDefault
|
//import kotlinx.serialization.EncodeDefault
|
||||||
import kotlinx.serialization.Serializable
|
//import kotlinx.serialization.Serializable
|
||||||
|
//
|
||||||
|
//
|
||||||
sealed interface KafkatorioKeyedPacketKey
|
//sealed interface KafkatorioKeyedPacketKey
|
||||||
|
//
|
||||||
|
//
|
||||||
/** Has a key, so it can be debounced */
|
///** Has a key, so it can be debounced */
|
||||||
sealed class KafkatorioKeyedPacketData : KafkatorioPacketData() {
|
//sealed class KafkatorioKeyedPacketData : KafkatorioPacketData() {
|
||||||
/** Count how many events this packet is aggregating data from */
|
// /** Count how many events this packet is aggregating data from */
|
||||||
abstract val eventCounts: Map<String, UInt>?
|
// abstract val eventCounts: Map<String, UInt>?
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
|
///* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
|
||||||
|
//
|
||||||
|
//
|
||||||
sealed interface EntityUpdateKey : EntityIdentifiers, KafkatorioKeyedPacketKey {
|
//sealed interface EntityUpdateKey : EntityIdentifiers, KafkatorioKeyedPacketKey {
|
||||||
/** A [unitNumber] is required for caching */
|
// /** A [unitNumber] is required for caching */
|
||||||
override val unitNumber: UnitNumber
|
// override val unitNumber: UnitNumber
|
||||||
override val name: String
|
// override val name: String
|
||||||
override val protoType: String
|
// override val protoType: String
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
@Serializable
|
//@Serializable
|
||||||
data class EntityUpdate(
|
//data class EntityUpdate(
|
||||||
override val unitNumber: UnitNumber,
|
// override val unitNumber: UnitNumber,
|
||||||
override val name: String,
|
// override val name: String,
|
||||||
override val protoType: String,
|
// override val protoType: String,
|
||||||
|
//
|
||||||
override val eventCounts: Map<String, UInt>? = null,
|
// override val eventCounts: Map<String, UInt>? = null,
|
||||||
|
//
|
||||||
val chunkPosition: MapChunkPosition? = null,
|
// val chunkPosition: MapChunkPosition? = null,
|
||||||
val graphicsVariation: UByte? = null,
|
// val graphicsVariation: UByte? = null,
|
||||||
val health: Float? = null,
|
// val health: Float? = null,
|
||||||
val isActive: Boolean? = null,
|
// val isActive: Boolean? = null,
|
||||||
val isRotatable: Boolean? = null,
|
// val isRotatable: Boolean? = null,
|
||||||
val lastUser: UInt? = null,
|
// val lastUser: UInt? = null,
|
||||||
val localisedDescription: String? = null,
|
// val localisedDescription: String? = null,
|
||||||
val localisedName: String? = null,
|
// val localisedName: String? = null,
|
||||||
val prototype: PrototypeName? = null,
|
// val prototype: PrototypeName? = null,
|
||||||
) : KafkatorioKeyedPacketData(), EntityUpdateKey {
|
//) : KafkatorioKeyedPacketData(), EntityUpdateKey {
|
||||||
@EncodeDefault
|
// @EncodeDefault
|
||||||
override val updateType: KafkatorioPacketDataType = KafkatorioPacketDataType.ENTITY
|
// override val updateType: KafkatorioPacketDataType = KafkatorioPacketDataType.ENTITY
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
|
///* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
|
||||||
|
//
|
||||||
|
//
|
||||||
sealed interface MapChunkUpdateKey : KafkatorioKeyedPacketKey {
|
//sealed interface MapChunkUpdateKey : KafkatorioKeyedPacketKey {
|
||||||
val chunkPosition: MapChunkPosition
|
// val chunkPosition: MapChunkPosition
|
||||||
val surfaceIndex: SurfaceIndex
|
// val surfaceIndex: SurfaceIndex
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
@Serializable
|
//@Serializable
|
||||||
data class MapChunkUpdate(
|
//data class MapChunkUpdate(
|
||||||
override val chunkPosition: MapChunkPosition,
|
// override val chunkPosition: MapChunkPosition,
|
||||||
override val surfaceIndex: SurfaceIndex,
|
// override val surfaceIndex: SurfaceIndex,
|
||||||
|
//
|
||||||
override val eventCounts: Map<String, UInt>? = null,
|
// override val eventCounts: Map<String, UInt>? = null,
|
||||||
|
//
|
||||||
val player: PlayerIndex? = null,
|
// val player: PlayerIndex? = null,
|
||||||
val robot: EntityIdentifiersData? = null,
|
// val robot: EntityIdentifiersData? = null,
|
||||||
val force: ForceIndex? = null,
|
// val force: ForceIndex? = null,
|
||||||
/** updated tiles - might be partial and not all tiles in the chunk */
|
// /** updated tiles - might be partial and not all tiles in the chunk */
|
||||||
val tileDictionary: MapTileDictionary? = null,
|
// val tileDictionary: MapTileDictionary? = null,
|
||||||
val isDeleted: Boolean? = null,
|
// val isDeleted: Boolean? = null,
|
||||||
) : KafkatorioKeyedPacketData(), MapChunkUpdateKey {
|
//) : KafkatorioKeyedPacketData(), MapChunkUpdateKey {
|
||||||
@EncodeDefault
|
// @EncodeDefault
|
||||||
override val updateType: KafkatorioPacketDataType = KafkatorioPacketDataType.MAP_CHUNK
|
// override val updateType: KafkatorioPacketDataType = KafkatorioPacketDataType.MAP_CHUNK
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
|
///* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
|
||||||
|
//
|
||||||
|
//
|
||||||
sealed interface PlayerUpdateKey : KafkatorioKeyedPacketKey {
|
//sealed interface PlayerUpdateKey : KafkatorioKeyedPacketKey {
|
||||||
val index: PlayerIndex
|
// val index: PlayerIndex
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
@Serializable
|
//@Serializable
|
||||||
data class PlayerUpdate(
|
//data class PlayerUpdate(
|
||||||
override val index: PlayerIndex,
|
// override val index: PlayerIndex,
|
||||||
|
//
|
||||||
override val eventCounts: Map<String, UInt>? = null,
|
// override val eventCounts: Map<String, UInt>? = null,
|
||||||
|
//
|
||||||
val characterUnitNumber: UnitNumber? = null,
|
// val characterUnitNumber: UnitNumber? = null,
|
||||||
val chatColour: Colour? = null,
|
// val chatColour: Colour? = null,
|
||||||
val colour: Colour? = null,
|
// val colour: Colour? = null,
|
||||||
val name: String? = null,
|
// val name: String? = null,
|
||||||
|
//
|
||||||
val afkTime: Tick? = null,
|
// val afkTime: Tick? = null,
|
||||||
val ticksToRespawn: Tick? = null,
|
// val ticksToRespawn: Tick? = null,
|
||||||
val forceIndex: ForceIndex? = null,
|
// val forceIndex: ForceIndex? = null,
|
||||||
val isAdmin: Boolean? = null,
|
// val isAdmin: Boolean? = null,
|
||||||
val isConnected: Boolean? = null,
|
// val isConnected: Boolean? = null,
|
||||||
val isShowOnMap: Boolean? = null,
|
// val isShowOnMap: Boolean? = null,
|
||||||
val isSpectator: Boolean? = null,
|
// val isSpectator: Boolean? = null,
|
||||||
val lastOnline: Tick? = null,
|
// val lastOnline: Tick? = null,
|
||||||
val onlineTime: Tick? = null,
|
// val onlineTime: Tick? = null,
|
||||||
val position: MapEntityPosition? = null,
|
// val position: MapEntityPosition? = null,
|
||||||
val surfaceIndex: SurfaceIndex? = null,
|
// val surfaceIndex: SurfaceIndex? = null,
|
||||||
val tag: String? = null,
|
// val tag: String? = null,
|
||||||
val diedCause: EntityIdentifiersData? = null,
|
// val diedCause: EntityIdentifiersData? = null,
|
||||||
|
//
|
||||||
val bannedReason: String? = null,
|
// val bannedReason: String? = null,
|
||||||
val kickedReason: String? = null,
|
// val kickedReason: String? = null,
|
||||||
val disconnectReason: String? = null,
|
// val disconnectReason: String? = null,
|
||||||
/** `true` when a player is removed (deleted) from the game */
|
// /** `true` when a player is removed (deleted) from the game */
|
||||||
val isRemoved: Boolean? = null,
|
// val isRemoved: Boolean? = null,
|
||||||
) : KafkatorioKeyedPacketData(), PlayerUpdateKey {
|
//) : KafkatorioKeyedPacketData(), PlayerUpdateKey {
|
||||||
@EncodeDefault
|
// @EncodeDefault
|
||||||
override val updateType: KafkatorioPacketDataType = KafkatorioPacketDataType.PLAYER
|
// override val updateType: KafkatorioPacketDataType = KafkatorioPacketDataType.PLAYER
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
|
///* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
|
||||||
|
|
|
||||||
|
|
@ -1,58 +1,58 @@
|
||||||
package dev.adamko.kafkatorio.schema.prototypes
|
package dev.adamko.kafkatorio.schema.prototypes
|
||||||
|
//
|
||||||
import dev.adamko.kafkatorio.schema.SerializerProvider
|
//import dev.adamko.kafkatorio.schema.SerializerProvider
|
||||||
import dev.adamko.kafkatorio.schema.SerializerProviderDeserializer
|
//import dev.adamko.kafkatorio.schema.SerializerProviderDeserializer
|
||||||
import dev.adamko.kafkatorio.schema.common.Colour
|
//import dev.adamko.kafkatorio.schema.common.Colour
|
||||||
import dev.adamko.kafkatorio.schema.common.PrototypeName
|
//import dev.adamko.kafkatorio.schema.common.PrototypeName
|
||||||
import dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.PrototypeObjectName
|
//import dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.PrototypeObjectName
|
||||||
import kotlinx.serialization.Contextual
|
//import kotlinx.serialization.Contextual
|
||||||
import kotlinx.serialization.DeserializationStrategy
|
//import kotlinx.serialization.DeserializationStrategy
|
||||||
import kotlinx.serialization.EncodeDefault
|
//import kotlinx.serialization.EncodeDefault
|
||||||
import kotlinx.serialization.KSerializer
|
//import kotlinx.serialization.KSerializer
|
||||||
import kotlinx.serialization.Serializable
|
//import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.json.JsonContentPolymorphicSerializer
|
//import kotlinx.serialization.json.JsonContentPolymorphicSerializer
|
||||||
import kotlinx.serialization.json.JsonElement
|
//import kotlinx.serialization.json.JsonElement
|
||||||
import kotlinx.serialization.json.contentOrNull
|
//import kotlinx.serialization.json.contentOrNull
|
||||||
import kotlinx.serialization.json.jsonObject
|
//import kotlinx.serialization.json.jsonObject
|
||||||
import kotlinx.serialization.json.jsonPrimitive
|
//import kotlinx.serialization.json.jsonPrimitive
|
||||||
|
//
|
||||||
|
//
|
||||||
@Serializable(with = FactorioPrototype.JsonSerializer::class)
|
//@Serializable(with = FactorioPrototype.JsonSerializer::class)
|
||||||
sealed class FactorioPrototype {
|
//sealed class FactorioPrototype {
|
||||||
@EncodeDefault
|
// @EncodeDefault
|
||||||
abstract val prototypeObjectName: PrototypeObjectName
|
// abstract val prototypeObjectName: PrototypeObjectName
|
||||||
|
//
|
||||||
enum class PrototypeObjectName(
|
// enum class PrototypeObjectName(
|
||||||
override val serializer: KSerializer<out FactorioPrototype>
|
// override val serializer: KSerializer<out FactorioPrototype>
|
||||||
) : SerializerProvider<FactorioPrototype> {
|
// ) : SerializerProvider<FactorioPrototype> {
|
||||||
LuaTilePrototype(MapTilePrototype.serializer()),
|
// LuaTilePrototype(MapTilePrototype.serializer()),
|
||||||
;
|
// ;
|
||||||
|
//
|
||||||
companion object {
|
// companion object {
|
||||||
val entries: Set<PrototypeObjectName> = values().toSet()
|
// val entries: Set<PrototypeObjectName> = values().toSet()
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
object JsonSerializer : SerializerProviderDeserializer<FactorioPrototype>(
|
// object JsonSerializer : SerializerProviderDeserializer<FactorioPrototype>(
|
||||||
FactorioPrototype::class,
|
// FactorioPrototype::class,
|
||||||
FactorioPrototype::prototypeObjectName.name,
|
// FactorioPrototype::prototypeObjectName.name,
|
||||||
{ json -> PrototypeObjectName.entries.firstOrNull { it.name == json } }
|
// { json -> PrototypeObjectName.entries.firstOrNull { it.name == json } }
|
||||||
)
|
// )
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
@Serializable
|
//@Serializable
|
||||||
data class MapTilePrototype(
|
//data class MapTilePrototype(
|
||||||
val name: PrototypeName,
|
// val name: PrototypeName,
|
||||||
val layer: UInt,
|
// val layer: UInt,
|
||||||
val mapColour: Colour,
|
// val mapColour: Colour,
|
||||||
@Contextual
|
// @Contextual
|
||||||
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() {
|
||||||
@EncodeDefault
|
// @EncodeDefault
|
||||||
override val prototypeObjectName: PrototypeObjectName = PrototypeObjectName.LuaTilePrototype
|
// override val prototypeObjectName: PrototypeObjectName = PrototypeObjectName.LuaTilePrototype
|
||||||
}
|
//}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package dev.adamko.kafkatorio.schema2
|
||||||
|
|
||||||
import dev.adamko.kafkatorio.schema.common.PlayerIndex
|
import dev.adamko.kafkatorio.schema.common.PlayerIndex
|
||||||
import dev.adamko.kafkatorio.schema.common.SurfaceIndex
|
import dev.adamko.kafkatorio.schema.common.SurfaceIndex
|
||||||
import dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype
|
|
||||||
import dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2
|
import dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,147 +1,147 @@
|
||||||
package dev.adamko.kafkatorio.events.schema
|
package dev.adamko.kafkatorio.events.schema
|
||||||
|
|
||||||
import dev.adamko.kafkatorio.schema.events.KafkatorioInstantPacketData
|
//import dev.adamko.kafkatorio.schema.events.KafkatorioInstantPacketData
|
||||||
import dev.adamko.kafkatorio.schema.events.KafkatorioKeyedPacketData
|
//import dev.adamko.kafkatorio.schema.events.KafkatorioKeyedPacketData
|
||||||
import dev.adamko.kafkatorio.schema.events.KafkatorioKeyedPacketKey
|
//import dev.adamko.kafkatorio.schema.events.KafkatorioKeyedPacketKey
|
||||||
//import dev.adamko.kafkatorio.schema.events.KafkatorioPacket
|
////import dev.adamko.kafkatorio.schema.events.KafkatorioPacket
|
||||||
import dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype
|
//import dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype
|
||||||
import kotlin.io.path.Path
|
//import kotlin.io.path.Path
|
||||||
import kotlin.io.path.createDirectories
|
//import kotlin.io.path.createDirectories
|
||||||
import me.ntrrgc.tsGenerator.TypeScriptGenerator
|
//import me.ntrrgc.tsGenerator.TypeScriptGenerator
|
||||||
import org.intellij.lang.annotations.Language
|
//import org.intellij.lang.annotations.Language
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* Convert Kotlin classes to Typescript classes, using [TypeScriptGenerator]
|
// * Convert Kotlin classes to Typescript classes, using [TypeScriptGenerator]
|
||||||
*/
|
// */
|
||||||
fun main(args: Array<String>) {
|
//fun main(args: Array<String>) {
|
||||||
|
//
|
||||||
val gen = TypeScriptGenerator(
|
// val gen = TypeScriptGenerator(
|
||||||
rootClasses = buildSet {
|
// rootClasses = buildSet {
|
||||||
// add(KafkatorioPacket::class)
|
//// add(KafkatorioPacket::class)
|
||||||
// addAll(KafkatorioPacket::class.sealedSubclasses)
|
//// addAll(KafkatorioPacket::class.sealedSubclasses)
|
||||||
|
//
|
||||||
add(KafkatorioInstantPacketData::class)
|
// add(KafkatorioInstantPacketData::class)
|
||||||
addAll(KafkatorioInstantPacketData::class.sealedSubclasses)
|
// addAll(KafkatorioInstantPacketData::class.sealedSubclasses)
|
||||||
|
//
|
||||||
add(KafkatorioKeyedPacketData::class)
|
// add(KafkatorioKeyedPacketData::class)
|
||||||
addAll(KafkatorioKeyedPacketData::class.sealedSubclasses)
|
// addAll(KafkatorioKeyedPacketData::class.sealedSubclasses)
|
||||||
addAll(KafkatorioKeyedPacketKey::class.sealedSubclasses)
|
// addAll(KafkatorioKeyedPacketKey::class.sealedSubclasses)
|
||||||
|
//
|
||||||
add(FactorioPrototype::class)
|
// add(FactorioPrototype::class)
|
||||||
addAll(FactorioPrototype::class.sealedSubclasses)
|
// addAll(FactorioPrototype::class.sealedSubclasses)
|
||||||
},
|
// },
|
||||||
mappings = mapOf(
|
// mappings = mapOf(
|
||||||
// builtin Factorio numeric types > `typed-factorio/generated/builtin-types.d.ts`
|
// // builtin Factorio numeric types > `typed-factorio/generated/builtin-types.d.ts`
|
||||||
Float::class to "float",
|
// Float::class to "float",
|
||||||
Double::class to "double",
|
// Double::class to "double",
|
||||||
Int::class to "int",
|
// Int::class to "int",
|
||||||
Byte::class to "int8",
|
// Byte::class to "int8",
|
||||||
UInt::class to "uint",
|
// UInt::class to "uint",
|
||||||
UByte::class to "uint8",
|
// UByte::class to "uint8",
|
||||||
UShort::class to "uint16",
|
// UShort::class to "uint16",
|
||||||
ULong::class to "uint64",
|
// ULong::class to "uint64",
|
||||||
),
|
// ),
|
||||||
classTransformers = listOf(
|
// classTransformers = listOf(
|
||||||
ValueClassTransformer,
|
// ValueClassTransformer,
|
||||||
// PropertyNameTransformer,
|
//// PropertyNameTransformer,
|
||||||
),
|
// ),
|
||||||
// voidType = VoidType.UNDEFINED,
|
//// voidType = VoidType.UNDEFINED,
|
||||||
)
|
// )
|
||||||
|
//
|
||||||
val definitions = gen.definitionsText
|
// val definitions = gen.definitionsText
|
||||||
|
//
|
||||||
when (val filename = args.firstOrNull()) {
|
// when (val filename = args.firstOrNull()) {
|
||||||
null -> println(definitions)
|
// null -> println(definitions)
|
||||||
else -> {
|
// else -> {
|
||||||
val outPath = Path(filename)
|
// val outPath = Path(filename)
|
||||||
outPath.createDirectories()
|
// outPath.createDirectories()
|
||||||
|
//
|
||||||
splitDefinitions(definitions)
|
// splitDefinitions(definitions)
|
||||||
.forEach { (defFile, def) ->
|
// .forEach { (defFile, def) ->
|
||||||
val outFile = outPath.resolve(defFile).toFile()
|
// val outFile = outPath.resolve(defFile).toFile()
|
||||||
outFile.printWriter().use {
|
// outFile.printWriter().use {
|
||||||
it.println(kt2tsHeader)
|
// it.println(kt2tsHeader)
|
||||||
it.print(def)
|
// it.print(def)
|
||||||
}
|
// }
|
||||||
println("Generated file: $outFile")
|
// println("Generated file: $outFile")
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** Split the TypeScript interfaces into different files */
|
|
||||||
private fun splitDefinitions(definitions: String): Map<String, String> {
|
|
||||||
return definitions
|
|
||||||
.split("\n\n")
|
|
||||||
.groupBy { def ->
|
|
||||||
|
|
||||||
when {
|
|
||||||
def isInterface "KafkatorioPacket"
|
|
||||||
|| def extendsAny listOf("KafkatorioPacket")
|
|
||||||
|| def isType "KafkatorioPacketDataType"
|
|
||||||
-> "kafkatorio-packet.d.ts"
|
|
||||||
|
|
||||||
def isInterface "KafkatorioInstantPacketData"
|
|
||||||
|| def extends "KafkatorioInstantPacketData"
|
|
||||||
|| def isType "KafkatorioInstantPacketDataType"
|
|
||||||
|
|
||||||
|| def isInterface "ConfigurationUpdateGameData"
|
|
||||||
|| def isInterface "ConfigurationUpdateModData"
|
|
||||||
-> "kafkatorio-instant-packet.d.ts"
|
|
||||||
|
|
||||||
def isInterface "KafkatorioKeyedPacket"
|
|
||||||
|| def isInterface "KafkatorioKeyedPacketData"
|
|
||||||
|| def extends "KafkatorioKeyedPacket"
|
|
||||||
|| def isType "KafkatorioKeyedPacketDataType"
|
|
||||||
|
|
||||||
|| def isInterface "KafkatorioKeyedPacketKey"
|
|
||||||
-> "kafkatorio-keyed-packet.d.ts"
|
|
||||||
|
|
||||||
def isInterface "FactorioPrototypes"
|
|
||||||
|| def isInterface "FactorioPrototype"
|
|
||||||
|| def extends "FactorioPrototype"
|
|
||||||
|| def isType "PrototypeObjectName"
|
|
||||||
-> "prototype.d.ts"
|
|
||||||
|
|
||||||
else -> "schema.d.ts"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.mapValues { (_, def) ->
|
|
||||||
def
|
|
||||||
.sorted()
|
|
||||||
.joinToString("\n\n", postfix = "\n")
|
|
||||||
.replace(" ", " ")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Language("TypeScript")
|
|
||||||
val kt2tsHeader = """
|
|
||||||
|// Generated by TypeScriptGenerator - do not edit this file manually
|
|
||||||
|
|
|
||||||
""".trimMargin()
|
|
||||||
|
|
||||||
private infix fun String.extends(types: String): Boolean =
|
|
||||||
contains(Regex(".+extends.*(${types})"))
|
|
||||||
|
|
||||||
private infix fun String.extendsAny(types: List<String>): Boolean =
|
|
||||||
extends(types.joinToString("|") { "$it,".replaceAfterLast(',', "") })
|
|
||||||
|
|
||||||
private infix fun String.isInterface(type: String): Boolean =
|
|
||||||
contains(Regex("interface $type.*"))
|
|
||||||
|
|
||||||
|
|
||||||
private infix fun String.isType(type: String): Boolean =
|
|
||||||
contains(Regex("type $type.*"))
|
|
||||||
|
|
||||||
|
|
||||||
//object PropertyNameTransformer : ClassTransformer {
|
|
||||||
// override fun transformPropertyName(
|
|
||||||
// propertyName: String,
|
|
||||||
// property: KProperty<*>,
|
|
||||||
// klass: KClass<*>
|
|
||||||
// ): String {
|
|
||||||
// return camelCaseToSnakeCase(propertyName)
|
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
|
///** Split the TypeScript interfaces into different files */
|
||||||
|
//private fun splitDefinitions(definitions: String): Map<String, String> {
|
||||||
|
// return definitions
|
||||||
|
// .split("\n\n")
|
||||||
|
// .groupBy { def ->
|
||||||
|
//
|
||||||
|
// when {
|
||||||
|
// def isInterface "KafkatorioPacket"
|
||||||
|
// || def extendsAny listOf("KafkatorioPacket")
|
||||||
|
// || def isType "KafkatorioPacketDataType"
|
||||||
|
// -> "kafkatorio-packet.d.ts"
|
||||||
|
//
|
||||||
|
// def isInterface "KafkatorioInstantPacketData"
|
||||||
|
// || def extends "KafkatorioInstantPacketData"
|
||||||
|
// || def isType "KafkatorioInstantPacketDataType"
|
||||||
|
//
|
||||||
|
// || def isInterface "ConfigurationUpdateGameData"
|
||||||
|
// || def isInterface "ConfigurationUpdateModData"
|
||||||
|
// -> "kafkatorio-instant-packet.d.ts"
|
||||||
|
//
|
||||||
|
// def isInterface "KafkatorioKeyedPacket"
|
||||||
|
// || def isInterface "KafkatorioKeyedPacketData"
|
||||||
|
// || def extends "KafkatorioKeyedPacket"
|
||||||
|
// || def isType "KafkatorioKeyedPacketDataType"
|
||||||
|
//
|
||||||
|
// || def isInterface "KafkatorioKeyedPacketKey"
|
||||||
|
// -> "kafkatorio-keyed-packet.d.ts"
|
||||||
|
//
|
||||||
|
// def isInterface "FactorioPrototypes"
|
||||||
|
// || def isInterface "FactorioPrototype"
|
||||||
|
// || def extends "FactorioPrototype"
|
||||||
|
// || def isType "PrototypeObjectName"
|
||||||
|
// -> "prototype.d.ts"
|
||||||
|
//
|
||||||
|
// else -> "schema.d.ts"
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// .mapValues { (_, def) ->
|
||||||
|
// def
|
||||||
|
// .sorted()
|
||||||
|
// .joinToString("\n\n", postfix = "\n")
|
||||||
|
// .replace(" ", " ")
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//@Language("TypeScript")
|
||||||
|
//val kt2tsHeader = """
|
||||||
|
// |// Generated by TypeScriptGenerator - do not edit this file manually
|
||||||
|
// |
|
||||||
|
//""".trimMargin()
|
||||||
|
//
|
||||||
|
//private infix fun String.extends(types: String): Boolean =
|
||||||
|
// contains(Regex(".+extends.*(${types})"))
|
||||||
|
//
|
||||||
|
//private infix fun String.extendsAny(types: List<String>): Boolean =
|
||||||
|
// extends(types.joinToString("|") { "$it,".replaceAfterLast(',', "") })
|
||||||
|
//
|
||||||
|
//private infix fun String.isInterface(type: String): Boolean =
|
||||||
|
// contains(Regex("interface $type.*"))
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//private infix fun String.isType(type: String): Boolean =
|
||||||
|
// contains(Regex("type $type.*"))
|
||||||
|
//
|
||||||
|
//
|
||||||
|
////object PropertyNameTransformer : ClassTransformer {
|
||||||
|
//// override fun transformPropertyName(
|
||||||
|
//// propertyName: String,
|
||||||
|
//// property: KProperty<*>,
|
||||||
|
//// klass: KClass<*>
|
||||||
|
//// ): String {
|
||||||
|
//// return camelCaseToSnakeCase(propertyName)
|
||||||
|
//// }
|
||||||
|
////}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import dev.adamko.kxstsgen.core.TsTypeRef
|
||||||
import kotlin.io.path.Path
|
import kotlin.io.path.Path
|
||||||
import kotlin.io.path.createDirectories
|
import kotlin.io.path.createDirectories
|
||||||
import kotlinx.serialization.builtins.serializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
import org.intellij.lang.annotations.Language
|
||||||
|
|
||||||
|
|
||||||
@ExperimentalUnsignedTypes
|
@ExperimentalUnsignedTypes
|
||||||
|
|
@ -53,3 +54,9 @@ fun main(args: Array<String>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Language("TypeScript")
|
||||||
|
val kt2tsHeader = """
|
||||||
|
|// Generated by kxs-ts-gen - do not edit this file manually
|
||||||
|
|
|
||||||
|
""".trimMargin()
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import dev.adamko.kafkatorio.schema.common.ColourHex
|
||||||
import dev.adamko.kafkatorio.schema.common.MapTile
|
import dev.adamko.kafkatorio.schema.common.MapTile
|
||||||
import dev.adamko.kafkatorio.schema.common.toHex
|
import dev.adamko.kafkatorio.schema.common.toHex
|
||||||
import dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2
|
import dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2
|
||||||
import dev.adamko.kafkatorio.schema.prototypes.MapTilePrototype
|
|
||||||
import dev.adamko.kafkatorio.schema2.PrototypesUpdate
|
import dev.adamko.kafkatorio.schema2.PrototypesUpdate
|
||||||
import dev.adamko.kotka.extensions.materializedAs
|
import dev.adamko.kotka.extensions.materializedAs
|
||||||
import dev.adamko.kotka.extensions.streams.filter
|
import dev.adamko.kotka.extensions.streams.filter
|
||||||
|
|
@ -21,7 +20,6 @@ import org.apache.kafka.streams.kstream.KTable
|
||||||
@JvmInline
|
@JvmInline
|
||||||
@Serializable
|
@Serializable
|
||||||
value class TileProtoHashCode private constructor(val code: Int) {
|
value class TileProtoHashCode private constructor(val code: Int) {
|
||||||
constructor(prototype: MapTilePrototype) : this(prototype.name.hashCode())
|
|
||||||
constructor(tile: MapTile) : this(tile.proto.hashCode())
|
constructor(tile: MapTile) : this(tile.proto.hashCode())
|
||||||
constructor(tile: FactorioPrototype2.MapTile) : this(tile.name.hashCode())
|
constructor(tile: FactorioPrototype2.MapTile) : this(tile.name.hashCode())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue