fix typescript after updates
This commit is contained in:
parent
4d94e2f395
commit
4d2f574827
5 changed files with 20 additions and 20 deletions
|
|
@ -6,14 +6,6 @@ interface FactorioObjectData {
|
|||
objectName: ObjectName;
|
||||
}
|
||||
|
||||
interface FactorioEvent<T extends FactorioObjectData> extends KafkatorioPacket {
|
||||
data: T;
|
||||
eventType: string;
|
||||
modVersion: string;
|
||||
packetType: PacketType;
|
||||
tick: uint;
|
||||
}
|
||||
|
||||
interface PlayerData extends FactorioObjectData {
|
||||
associatedCharactersUnitNumbers: uint[];
|
||||
characterUnitNumber: uint | null;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
type PrototypeObjectName = "LuaTilePrototype";
|
||||
|
||||
interface FactorioPrototype {
|
||||
objectName: PrototypeObjectName;
|
||||
prototypeObjectName: PrototypeObjectName;
|
||||
}
|
||||
|
||||
interface FactorioMapTilePrototype extends FactorioPrototype {
|
||||
|
|
@ -12,6 +12,6 @@ interface FactorioMapTilePrototype extends FactorioPrototype {
|
|||
layer: uint;
|
||||
mapColor: Colour;
|
||||
name: string;
|
||||
objectName: PrototypeObjectName;
|
||||
order: string;
|
||||
prototypeObjectName: PrototypeObjectName;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,14 @@ interface KafkatorioPacket {
|
|||
packetType: PacketType;
|
||||
}
|
||||
|
||||
interface FactorioEvent extends KafkatorioPacket {
|
||||
data: FactorioObjectData;
|
||||
eventType: string;
|
||||
modVersion: string;
|
||||
packetType: PacketType;
|
||||
tick: uint;
|
||||
}
|
||||
|
||||
interface Colour {
|
||||
alpha: float;
|
||||
blue: float;
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@ export function convertPrototypes(): FactorioPrototype[] {
|
|||
|
||||
function getMapTilePrototypes(): FactorioMapTilePrototype[] {
|
||||
let tiles: FactorioMapTilePrototype[] = []
|
||||
for (let [_, tile] of pairs(game.tile_prototypes)) {
|
||||
for (let [, tile] of pairs(game.tile_prototypes)) {
|
||||
tiles.push(
|
||||
<FactorioMapTilePrototype>{
|
||||
objectName: tile.object_name,
|
||||
prototypeObjectName: tile.object_name,
|
||||
|
||||
name: tile.name,
|
||||
order: tile.order,
|
||||
|
|
@ -29,7 +29,7 @@ function getMapTilePrototypes(): FactorioMapTilePrototype[] {
|
|||
|
||||
function convertCollisionMaskToNames(cm: CollisionMask): string[] {
|
||||
let masks: string[] = []
|
||||
for (let [name, _] of pairs(cm)) {
|
||||
for (let [name] of pairs(cm)) {
|
||||
masks.push(name)
|
||||
}
|
||||
return masks
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ import kotlinx.serialization.json.jsonPrimitive
|
|||
@Serializable(with = FactorioPrototypeSerializer::class)
|
||||
sealed class FactorioPrototype {
|
||||
@EncodeDefault
|
||||
abstract val objectName: ObjectName
|
||||
abstract val prototypeObjectName: PrototypeObjectName
|
||||
|
||||
enum class ObjectName {
|
||||
enum class PrototypeObjectName {
|
||||
LuaTilePrototype
|
||||
}
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@ sealed class FactorioPrototype {
|
|||
object FactorioPrototypeSerializer : JsonContentPolymorphicSerializer<FactorioPrototype>(
|
||||
FactorioPrototype::class
|
||||
) {
|
||||
private val key = FactorioPrototype::objectName.name
|
||||
private val key = FactorioPrototype::prototypeObjectName.name
|
||||
|
||||
override fun selectDeserializer(element: JsonElement): DeserializationStrategy<out FactorioPrototype> {
|
||||
|
||||
|
|
@ -32,12 +32,12 @@ object FactorioPrototypeSerializer : JsonContentPolymorphicSerializer<FactorioPr
|
|||
?.jsonPrimitive
|
||||
?.contentOrNull
|
||||
?.let { json ->
|
||||
FactorioPrototype.ObjectName.values().firstOrNull { it.name == json }
|
||||
FactorioPrototype.PrototypeObjectName.values().firstOrNull { it.name == json }
|
||||
}
|
||||
|
||||
return when (type) {
|
||||
FactorioPrototype.ObjectName.LuaTilePrototype -> FactorioMapTilePrototype.serializer()
|
||||
null ->
|
||||
FactorioPrototype.PrototypeObjectName.LuaTilePrototype -> FactorioMapTilePrototype.serializer()
|
||||
null ->
|
||||
throw Exception("Unknown FactorioPrototype $key: '$type' ")
|
||||
}
|
||||
}
|
||||
|
|
@ -55,5 +55,5 @@ data class FactorioMapTilePrototype(
|
|||
val canBeMined: Boolean,
|
||||
) : FactorioPrototype() {
|
||||
@EncodeDefault
|
||||
override val objectName: ObjectName = ObjectName.LuaTilePrototype
|
||||
override val prototypeObjectName: PrototypeObjectName = PrototypeObjectName.LuaTilePrototype
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue