tidying up
This commit is contained in:
parent
7813756c69
commit
08ab1c582c
24 changed files with 105 additions and 324 deletions
|
|
@ -1,98 +0,0 @@
|
|||
@file:Suppress("ClassName")
|
||||
|
||||
package dev.adamko.kafkatorio.events.schema
|
||||
|
||||
|
||||
import kotlin.jvm.JvmInline
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
/*
|
||||
* The basic types used in the Factorio API. While Lua only supports the `boolean`, `number`,
|
||||
* `string`, and `table` types (as they relate to the types listed below), the API docs will
|
||||
* specify what C++ types these are converted to or from internally.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Tables are enclosed in curly brackets, like this `{}`
|
||||
*
|
||||
* [View documentation](https://lua-api.factorio.com/next/Builtin-Types.html#table)
|
||||
*/
|
||||
typealias F_table = MutableMap<Any, Any>
|
||||
|
||||
sealed interface FBuiltInType {
|
||||
|
||||
sealed interface FNumber {
|
||||
/**
|
||||
* A floating-point number. This is a single-precision floating point number. Whilst Lua only uses double-precision
|
||||
* numbers, when a function takes a float, the game engine will immediately convert the double-precision number to
|
||||
* single-precision.
|
||||
*
|
||||
* [View documentation](https://lua-api.factorio.com/next/Builtin-Types.html#float)
|
||||
*/
|
||||
@Serializable
|
||||
@JvmInline
|
||||
value class F_float(val float: Float) : FNumber
|
||||
/**
|
||||
* A double-precision floating-point number. This is the same data type as all Lua numbers use.
|
||||
*
|
||||
* [View documentation](https://lua-api.factorio.com/next/Builtin-Types.html#double)
|
||||
*/
|
||||
@Serializable
|
||||
@JvmInline
|
||||
value class F_double(val double: Double) : FNumber
|
||||
|
||||
/**
|
||||
* 32-bit signed integer. Possible values are -2,147,483,648 to 2,147,483,647.
|
||||
*
|
||||
* [View documentation](https://lua-api.factorio.com/next/Builtin-Types.html#int)
|
||||
*/
|
||||
@Serializable
|
||||
@JvmInline
|
||||
value class F_int(val int: Int) : FNumber
|
||||
/**
|
||||
* 8-bit signed integer. Possible values are -128 to 127.
|
||||
*
|
||||
* [View documentation](https://lua-api.factorio.com/next/Builtin-Types.html#int8)
|
||||
*/
|
||||
@Serializable
|
||||
@JvmInline
|
||||
value class F_int8(val int8: Byte) : FNumber
|
||||
|
||||
/**
|
||||
* 32-bit unsigned integer. Possible values are 0 to 4,294,967,295.
|
||||
*
|
||||
* [View documentation](https://lua-api.factorio.com/next/Builtin-Types.html#uint)
|
||||
*/
|
||||
@Serializable
|
||||
@JvmInline
|
||||
value class F_uint(val uint: UInt) : FNumber
|
||||
/**
|
||||
* 8-bit unsigned integer. Possible values are 0 to 255.
|
||||
*
|
||||
* [View documentation](https://lua-api.factorio.com/next/Builtin-Types.html#uint8)
|
||||
*/
|
||||
@Serializable
|
||||
@JvmInline
|
||||
value class F_uint8(val uint8: UByte) : FNumber
|
||||
/**
|
||||
* 16-bit unsigned integer. Possible values are 0 to 65535.
|
||||
*
|
||||
* [View documentation](https://lua-api.factorio.com/next/Builtin-Types.html#uint16)
|
||||
*/
|
||||
@Serializable
|
||||
@JvmInline
|
||||
value class F_uint16(val uint16: UShort) : FNumber
|
||||
/**
|
||||
* 64-bit unsigned integer. Possible values are 0 to 18,446,744,073,709,551,615.
|
||||
*
|
||||
* [View documentation](https://lua-api.factorio.com/next/Builtin-Types.html#uint64)
|
||||
*/
|
||||
@Serializable
|
||||
@JvmInline
|
||||
value class F_uint64(val uint64: ULong) : FNumber
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -11,18 +11,13 @@ import kotlinx.serialization.json.JsonClassDiscriminator
|
|||
@Serializable
|
||||
data class FactorioEvent<out T : FactorioObjectData>(
|
||||
/** the initial Factorio event ({defines.events}) trigger */
|
||||
@SerialName("event_type")
|
||||
val eventType: String,
|
||||
@SerialName("event_type") val eventType: String,
|
||||
/** Schema versioning */
|
||||
@SerialName("mod_version")
|
||||
val modVersion: String,
|
||||
@SerialName("factorio_version")
|
||||
val factorioVersion: String,
|
||||
@SerialName("mod_version") val modVersion: String,
|
||||
@SerialName("factorio_version") val factorioVersion: String,
|
||||
/** game time */
|
||||
@SerialName("tick")
|
||||
val tick: UInt,
|
||||
@SerialName("data")
|
||||
val data: T
|
||||
@SerialName("tick") val tick: UInt,
|
||||
@SerialName("data") val data: T
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -58,64 +53,46 @@ sealed class FactorioObjectData {
|
|||
@SerialName("LuaPlayer")
|
||||
data class PlayerData(
|
||||
@Serializable(with = ListAsObjectSerializer::class)
|
||||
@SerialName("associated_characters_unit_numbers")
|
||||
val associatedCharactersUnitNumbers: List<UInt>,
|
||||
@SerialName("character_unit_number")
|
||||
val characterUnitNumber: UInt?,
|
||||
@SerialName("name")
|
||||
val name: String,
|
||||
@SerialName("position")
|
||||
val position: PositionData,
|
||||
@SerialName("associated_characters_unit_numbers") val associatedCharactersUnitNumbers: List<UInt>,
|
||||
@SerialName("character_unit_number") val characterUnitNumber: UInt?,
|
||||
@SerialName("name") val name: String,
|
||||
@SerialName("position") val position: PositionData,
|
||||
) : FactorioObjectData() {
|
||||
@Transient
|
||||
override val objectName: String= "LuaPlayer"
|
||||
override val objectName: String = "LuaPlayer"
|
||||
}
|
||||
|
||||
@Serializable
|
||||
@SerialName("LuaEntity")
|
||||
data class EntityData(
|
||||
@SerialName("active")
|
||||
val active: Boolean,
|
||||
@SerialName("health")
|
||||
val health: Double?,
|
||||
@SerialName("health_ratio")
|
||||
val healthRatio: Double,
|
||||
@SerialName("name")
|
||||
val name: String,
|
||||
@SerialName("position")
|
||||
val position: PositionData,
|
||||
@SerialName("surface_index")
|
||||
val surfaceIndex: Int,
|
||||
@SerialName("type")
|
||||
val type: String,
|
||||
@SerialName("unit_number")
|
||||
val unitNumber: UInt? = null,
|
||||
@SerialName("active") val active: Boolean,
|
||||
@SerialName("health") val health: Double?,
|
||||
@SerialName("health_ratio") val healthRatio: Double,
|
||||
@SerialName("name") val name: String,
|
||||
@SerialName("position") val position: PositionData,
|
||||
@SerialName("surface_index") val surfaceIndex: Int,
|
||||
@SerialName("type") val type: String,
|
||||
@SerialName("unit_number") val unitNumber: UInt? = null,
|
||||
|
||||
@SerialName("player_index")
|
||||
val playerIndex: UInt? = null,
|
||||
@SerialName("player_index") val playerIndex: UInt? = null,
|
||||
) : FactorioObjectData() {
|
||||
@Transient
|
||||
override val objectName: String= "LuaEntity"
|
||||
override val objectName: String = "LuaEntity"
|
||||
}
|
||||
|
||||
@Serializable
|
||||
@SerialName("LuaSurface")
|
||||
data class SurfaceData(
|
||||
@SerialName("daytime")
|
||||
val daytime: Double,
|
||||
@SerialName("index")
|
||||
val index: UInt,
|
||||
@SerialName("name")
|
||||
val name: String,
|
||||
@SerialName("daytime") val daytime: Double,
|
||||
@SerialName("index") val index: UInt,
|
||||
@SerialName("name") val name: String,
|
||||
) : FactorioObjectData() {
|
||||
@Transient
|
||||
override val objectName: String="LuaSurface"
|
||||
override val objectName: String = "LuaSurface"
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class PositionData(
|
||||
@SerialName("x")
|
||||
val x: Double,
|
||||
@SerialName("y")
|
||||
val y: Double,
|
||||
@SerialName("x") val x: Double,
|
||||
@SerialName("y") val y: Double,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@ import me.ntrrgc.tsGenerator.TypeScriptGenerator
|
|||
import me.ntrrgc.tsGenerator.camelCaseToSnakeCase
|
||||
import org.intellij.lang.annotations.Language
|
||||
|
||||
/**
|
||||
* Convert Kotlin classes to Typescript classes, using [TypeScriptGenerator]
|
||||
*/
|
||||
fun main(args: Array<String>) {
|
||||
|
||||
val gen =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue