improve event-schema polymorphism with enums
This commit is contained in:
parent
3875b9c309
commit
51e0aff823
18 changed files with 120 additions and 67 deletions
|
|
@ -15,5 +15,6 @@ interface FactorioConfigurationUpdate extends KafkatorioPacket {
|
|||
allMods: FactorioModInfo[];
|
||||
factorioData: FactorioGameDataUpdate;
|
||||
modVersion: string;
|
||||
packetType: PacketType;
|
||||
prototypes: FactorioPrototype[];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,16 @@
|
|||
// Generated by TypeScriptGenerator - do not edit this file manually
|
||||
|
||||
type ObjectName = "LuaPlayer" | "LuaEntity" | "LuaSurface" | "FactorioMapChunk" | "LuaTile" | "ConsoleChatMessage";
|
||||
|
||||
interface FactorioObjectData {
|
||||
objectName: string;
|
||||
objectName: ObjectName;
|
||||
}
|
||||
|
||||
interface FactorioEvent<T extends FactorioObjectData> extends KafkatorioPacket {
|
||||
data: T;
|
||||
eventType: string;
|
||||
modVersion: string;
|
||||
packetType: PacketType;
|
||||
tick: uint;
|
||||
}
|
||||
|
||||
|
|
@ -18,7 +21,7 @@ interface PlayerData extends FactorioObjectData {
|
|||
colour: Colour;
|
||||
lastOnline: uint;
|
||||
name: string;
|
||||
objectName: string;
|
||||
objectName: ObjectName;
|
||||
position: PositionData;
|
||||
}
|
||||
|
||||
|
|
@ -27,7 +30,7 @@ interface EntityData extends FactorioObjectData {
|
|||
health: double | null;
|
||||
healthRatio: double;
|
||||
name: string;
|
||||
objectName: string;
|
||||
objectName: ObjectName;
|
||||
playerIndex: uint | null;
|
||||
position: PositionData;
|
||||
surfaceIndex: int;
|
||||
|
|
@ -39,23 +42,23 @@ interface SurfaceData extends FactorioObjectData {
|
|||
daytime: double;
|
||||
index: uint;
|
||||
name: string;
|
||||
objectName: string;
|
||||
objectName: ObjectName;
|
||||
}
|
||||
|
||||
interface FactorioMapTile extends FactorioObjectData {
|
||||
objectName: string;
|
||||
objectName: ObjectName;
|
||||
position: PositionData;
|
||||
prototypeName: string;
|
||||
surfaceIndex: int;
|
||||
}
|
||||
|
||||
interface FactorioMapChunk extends FactorioObjectData {
|
||||
objectName: string;
|
||||
objectName: ObjectName;
|
||||
tiles: FactorioMapTile[];
|
||||
}
|
||||
|
||||
interface ConsoleChatMessage extends FactorioObjectData {
|
||||
authorPlayerIndex: uint | null;
|
||||
content: string;
|
||||
objectName: string;
|
||||
objectName: ObjectName;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
// Generated by TypeScriptGenerator - do not edit this file manually
|
||||
|
||||
interface FactorioPrototype {
|
||||
objectName: string;
|
||||
}
|
||||
type PrototypeObjectName = "LuaTilePrototype";
|
||||
|
||||
interface FactorioPrototypes<T extends FactorioPrototype> extends KafkatorioPacket {
|
||||
modVersion: string;
|
||||
prototypes: T[];
|
||||
interface FactorioPrototype {
|
||||
objectName: PrototypeObjectName;
|
||||
}
|
||||
|
||||
interface FactorioMapTilePrototype extends FactorioPrototype {
|
||||
|
|
@ -15,6 +12,6 @@ interface FactorioMapTilePrototype extends FactorioPrototype {
|
|||
layer: uint;
|
||||
mapColor: Colour;
|
||||
name: string;
|
||||
objectName: string;
|
||||
objectName: PrototypeObjectName;
|
||||
order: string;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
// Generated by TypeScriptGenerator - do not edit this file manually
|
||||
|
||||
type PacketType = "EVENT" | "CONFIG";
|
||||
|
||||
interface KafkatorioPacket {
|
||||
modVersion: string;
|
||||
packetType: PacketType;
|
||||
}
|
||||
|
||||
interface Colour {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ export function handleConfigurationUpdate(changeData: ConfigurationChangedData)
|
|||
|
||||
emitPacket<FactorioConfigurationUpdate>({
|
||||
modVersion: global.MOD_VERSION,
|
||||
packetType: "CONFIG",
|
||||
allMods: allMods(changeData),
|
||||
factorioData: factorioData(changeData),
|
||||
prototypes: convertPrototypes()
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import {emitPacket} from "../emitKafkatorioPacket";
|
|||
export function emitEvent<T extends FactorioObjectData>(eventData: T, tick: uint, eventType: string) {
|
||||
emitPacket({
|
||||
data: eventData,
|
||||
packetType: "EVENT",
|
||||
eventType: eventType,
|
||||
modVersion: global.MOD_VERSION,
|
||||
tick: tick
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue