kotlin data model experiment

This commit is contained in:
Adam 2021-10-20 23:27:31 +02:00
parent 2e15f83c90
commit a70b2935f3
3 changed files with 64 additions and 0 deletions

View file

@ -0,0 +1,8 @@
plugins {
id("dev.adamko.factoriowebmap.archetype.kotlin-js")
}
val projectId: String by project.extra
val buildDir: Directory = layout.buildDirectory.dir(projectId).get()
val nodeModulesDir: Directory by project.extra

View file

@ -0,0 +1,55 @@
interface Identifiable<T> {
val id: T
}
interface IndexedModel {
val index: UInt
}
interface NamedModel {
val name: String
}
data class SurfaceModel(
override val name: String,
override val index: UInt,
val daytime: Float,
val darkness: Float,
val wind_speed: Double,
) : IndexedModel, NamedModel
/** Player/Entity shared props */
interface ControlModel {
val driving: Boolean
val forces: List<ForceModel>
}
//data class PlayerModel(
// val index: UInt,
// val characters: List<EntityModel>
//) : Identifiable<UInt> {
// override val id: UInt = index
//}
//data class EntityModel(
// val unit_number: Int,
// override val name: String,
// val type: String,
// val active: Boolean,
// val minable: Boolean,
// val health: Boolean,
// val speed: Float, override val driving: Boolean,
//) : ControlModel, NamedModel
data class ForceModel(
val index: UInt,
override val name: String,
val research_progress: Double,
) : Identifiable<UInt>, NamedModel {
override val id: UInt = index
}

View file

@ -6,6 +6,7 @@ include(
":modules:server", ":modules:server",
":modules:kt-rcon", ":modules:kt-rcon",
":modules:kafka", ":modules:kafka",
":modules:data-model",
) )
enableFeaturePreview("VERSION_CATALOGS") enableFeaturePreview("VERSION_CATALOGS")