make factorio ID value classes, nicer, and remove 'EncodeDefault' from colours
This commit is contained in:
parent
99a7167485
commit
ebb8482201
5 changed files with 17 additions and 19 deletions
|
|
@ -67,13 +67,9 @@ data class MapBoundingBox(
|
|||
*/
|
||||
@Serializable
|
||||
data class Colour(
|
||||
@EncodeDefault // remove encode default?
|
||||
val red: Float = 0f,
|
||||
@EncodeDefault
|
||||
val green: Float = 0f,
|
||||
@EncodeDefault
|
||||
val blue: Float = 0f,
|
||||
@EncodeDefault
|
||||
val alpha: Float = 1f,
|
||||
)
|
||||
|
||||
|
|
@ -81,13 +77,9 @@ data class Colour(
|
|||
/** Size-efficient version of [Colour] (`4*4` bytes vs `4*1` bytes) */
|
||||
@Serializable
|
||||
data class ColourHex(
|
||||
@EncodeDefault // remove encode default?
|
||||
val red: UByte = UByte.MIN_VALUE,
|
||||
@EncodeDefault
|
||||
val green: UByte = UByte.MIN_VALUE,
|
||||
@EncodeDefault
|
||||
val blue: UByte = UByte.MIN_VALUE,
|
||||
@EncodeDefault
|
||||
val alpha: UByte = UByte.MAX_VALUE,
|
||||
) {
|
||||
companion object {
|
||||
|
|
|
|||
|
|
@ -11,26 +11,36 @@ import kotlinx.serialization.Serializable
|
|||
*/
|
||||
@Serializable
|
||||
@JvmInline
|
||||
value class SurfaceIndex(val value: UInt)
|
||||
value class SurfaceIndex(private val id: UInt) {
|
||||
override fun toString(): String = "$id"
|
||||
}
|
||||
|
||||
|
||||
@Serializable
|
||||
@JvmInline
|
||||
value class ForceIndex(val value: UInt)
|
||||
value class ForceIndex(private val id: UInt) {
|
||||
override fun toString(): String = "$id"
|
||||
}
|
||||
|
||||
|
||||
/** The player's index in `LuaGameScript::players` */
|
||||
@Serializable
|
||||
@JvmInline
|
||||
value class PlayerIndex(val value: UInt)
|
||||
value class PlayerIndex(private val id: UInt) {
|
||||
override fun toString(): String = "$id"
|
||||
}
|
||||
|
||||
|
||||
/** This is universally unique for every entity that has one, for the lifetime of a whole game. */
|
||||
@Serializable
|
||||
@JvmInline
|
||||
value class UnitNumber(val value: UInt)
|
||||
value class UnitNumber(private val id: UInt) {
|
||||
override fun toString(): String = "$id"
|
||||
}
|
||||
|
||||
|
||||
@Serializable
|
||||
@JvmInline
|
||||
value class PrototypeName(val value: String)
|
||||
value class PrototypeName(private val id: String) {
|
||||
override fun toString(): String = id
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,8 +33,7 @@ class FactorioEventTest : FunSpec({
|
|||
"chatColour": {
|
||||
"red": 1,
|
||||
"green": 0.62,
|
||||
"blue": 0.25,
|
||||
"alpha": 1
|
||||
"blue": 0.25
|
||||
},
|
||||
"lastOnline": 2287061
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue