move from schema2 to schema
This commit is contained in:
parent
6bfcd30558
commit
b0a6151c36
30 changed files with 256 additions and 318 deletions
|
|
@ -1,37 +1,37 @@
|
|||
// Generated by kxs-ts-gen - do not edit this file manually
|
||||
|
||||
export interface KafkatorioPacket2 {
|
||||
export interface KafkatorioPacket {
|
||||
modVersion: string;
|
||||
tick: Tick;
|
||||
data: KafkatorioPacketData2;
|
||||
data: KafkatorioPacketData;
|
||||
}
|
||||
|
||||
export type Tick = UInt;
|
||||
|
||||
export type KafkatorioPacketData2 =
|
||||
| KafkatorioPacketData2.ConfigurationUpdate
|
||||
| KafkatorioPacketData2.ConsoleChatUpdate
|
||||
| KafkatorioPacketData2.ConsoleCommandUpdate
|
||||
| KafkatorioPacketData2.EntityUpdate
|
||||
| KafkatorioPacketData2.MapChunkUpdate
|
||||
| KafkatorioPacketData2.PlayerUpdate
|
||||
| KafkatorioPacketData2.PrototypesUpdate
|
||||
| KafkatorioPacketData2.SurfaceUpdate;
|
||||
export type KafkatorioPacketData =
|
||||
| KafkatorioPacketData.ConfigurationUpdate
|
||||
| KafkatorioPacketData.ConsoleChatUpdate
|
||||
| KafkatorioPacketData.ConsoleCommandUpdate
|
||||
| KafkatorioPacketData.EntityUpdate
|
||||
| KafkatorioPacketData.MapChunkUpdate
|
||||
| KafkatorioPacketData.PlayerUpdate
|
||||
| KafkatorioPacketData.PrototypesUpdate
|
||||
| KafkatorioPacketData.SurfaceUpdate;
|
||||
|
||||
export namespace KafkatorioPacketData2 {
|
||||
export namespace KafkatorioPacketData {
|
||||
export enum Type {
|
||||
ConfigurationUpdate = "dev.adamko.kafkatorio.schema2.ConfigurationUpdate",
|
||||
ConsoleChatUpdate = "dev.adamko.kafkatorio.schema2.ConsoleChatUpdate",
|
||||
ConsoleCommandUpdate = "dev.adamko.kafkatorio.schema2.ConsoleCommandUpdate",
|
||||
PrototypesUpdate = "dev.adamko.kafkatorio.schema2.PrototypesUpdate",
|
||||
SurfaceUpdate = "dev.adamko.kafkatorio.schema2.SurfaceUpdate",
|
||||
EntityUpdate = "dev.adamko.kafkatorio.schema2.EntityUpdate",
|
||||
MapChunkUpdate = "dev.adamko.kafkatorio.schema2.MapChunkUpdate",
|
||||
PlayerUpdate = "dev.adamko.kafkatorio.schema2.PlayerUpdate",
|
||||
ConfigurationUpdate = "dev.adamko.kafkatorio.schema.packets.ConfigurationUpdate",
|
||||
ConsoleChatUpdate = "dev.adamko.kafkatorio.schema.packets.ConsoleChatUpdate",
|
||||
ConsoleCommandUpdate = "dev.adamko.kafkatorio.schema.packets.ConsoleCommandUpdate",
|
||||
PrototypesUpdate = "dev.adamko.kafkatorio.schema.packets.PrototypesUpdate",
|
||||
SurfaceUpdate = "dev.adamko.kafkatorio.schema.packets.SurfaceUpdate",
|
||||
EntityUpdate = "dev.adamko.kafkatorio.schema.packets.EntityUpdate",
|
||||
MapChunkUpdate = "dev.adamko.kafkatorio.schema.packets.MapChunkUpdate",
|
||||
PlayerUpdate = "dev.adamko.kafkatorio.schema.packets.PlayerUpdate",
|
||||
}
|
||||
|
||||
export interface ConfigurationUpdate {
|
||||
type: KafkatorioPacketData2.Type.ConfigurationUpdate;
|
||||
type: KafkatorioPacketData.Type.ConfigurationUpdate;
|
||||
factorioData: ConfigurationUpdateGameData;
|
||||
allMods: ConfigurationUpdateModData[];
|
||||
modStartupSettingsChange: boolean;
|
||||
|
|
@ -39,32 +39,32 @@ export namespace KafkatorioPacketData2 {
|
|||
}
|
||||
|
||||
export interface ConsoleChatUpdate {
|
||||
type: KafkatorioPacketData2.Type.ConsoleChatUpdate;
|
||||
type: KafkatorioPacketData.Type.ConsoleChatUpdate;
|
||||
authorPlayerIndex: PlayerIndex | null;
|
||||
content: string;
|
||||
}
|
||||
|
||||
export interface ConsoleCommandUpdate {
|
||||
type: KafkatorioPacketData2.Type.ConsoleCommandUpdate;
|
||||
type: KafkatorioPacketData.Type.ConsoleCommandUpdate;
|
||||
authorPlayerIndex: PlayerIndex | null;
|
||||
command: string;
|
||||
parameters: string;
|
||||
}
|
||||
|
||||
export interface PrototypesUpdate {
|
||||
type: KafkatorioPacketData2.Type.PrototypesUpdate;
|
||||
prototypes: FactorioPrototype2[];
|
||||
type: KafkatorioPacketData.Type.PrototypesUpdate;
|
||||
prototypes: FactorioPrototype[];
|
||||
}
|
||||
|
||||
export interface SurfaceUpdate {
|
||||
type: KafkatorioPacketData2.Type.SurfaceUpdate;
|
||||
type: KafkatorioPacketData.Type.SurfaceUpdate;
|
||||
index: SurfaceIndex;
|
||||
daytime: Double;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface EntityUpdate {
|
||||
type: KafkatorioPacketData2.Type.EntityUpdate;
|
||||
type: KafkatorioPacketData.Type.EntityUpdate;
|
||||
key: EntityUpdateKey;
|
||||
eventCounts?: { [key: string]: UInt } | null;
|
||||
chunkPosition?: MapChunkPosition | null;
|
||||
|
|
@ -79,7 +79,7 @@ export namespace KafkatorioPacketData2 {
|
|||
}
|
||||
|
||||
export interface MapChunkUpdate {
|
||||
type: KafkatorioPacketData2.Type.MapChunkUpdate;
|
||||
type: KafkatorioPacketData.Type.MapChunkUpdate;
|
||||
key: MapChunkUpdateKey;
|
||||
eventCounts?: { [key: string]: UInt } | null;
|
||||
player?: PlayerIndex | null;
|
||||
|
|
@ -90,7 +90,7 @@ export namespace KafkatorioPacketData2 {
|
|||
}
|
||||
|
||||
export interface PlayerUpdate {
|
||||
type: KafkatorioPacketData2.Type.PlayerUpdate;
|
||||
type: KafkatorioPacketData.Type.PlayerUpdate;
|
||||
key: PlayerUpdateKey;
|
||||
eventCounts?: { [key: string]: UInt } | null;
|
||||
characterUnitNumber?: UnitNumber | null;
|
||||
|
|
@ -191,16 +191,16 @@ export interface ConfigurationUpdateModData {
|
|||
previousVersion?: string | null;
|
||||
}
|
||||
|
||||
export type FactorioPrototype2 =
|
||||
| FactorioPrototype2.MapTile;
|
||||
export type FactorioPrototype =
|
||||
| FactorioPrototype.MapTile;
|
||||
|
||||
export namespace FactorioPrototype2 {
|
||||
export namespace FactorioPrototype {
|
||||
export enum Type {
|
||||
MapTile = "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
MapTile = "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
}
|
||||
|
||||
export interface MapTile {
|
||||
type: FactorioPrototype2.Type.MapTile;
|
||||
type: FactorioPrototype.Type.MapTile;
|
||||
name: PrototypeName;
|
||||
layer: UInt;
|
||||
mapColour: Colour;
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
import {
|
||||
KafkatorioPacket2,
|
||||
KafkatorioPacketData2
|
||||
KafkatorioPacket,
|
||||
KafkatorioPacketData
|
||||
} from "../generated/kafkatorio-schema/kafkatorio-schema";
|
||||
import {KafkatorioKeyedPacketData} from "./types";
|
||||
|
||||
export class KafkatorioPacketEmitter {
|
||||
|
||||
emitInstantPacket<DATA extends KafkatorioPacketData2>(
|
||||
emitInstantPacket<DATA extends KafkatorioPacketData>(
|
||||
data: DATA,
|
||||
) {
|
||||
KafkatorioPacketEmitter.emitPacket<KafkatorioPacket2>({
|
||||
KafkatorioPacketEmitter.emitPacket<KafkatorioPacket>({
|
||||
data: data,
|
||||
modVersion: global.MOD_VERSION,
|
||||
tick: game.tick,
|
||||
|
|
@ -19,7 +19,7 @@ export class KafkatorioPacketEmitter {
|
|||
emitKeyedPacket<DATA extends KafkatorioKeyedPacketData>(
|
||||
data: DATA,
|
||||
) {
|
||||
KafkatorioPacketEmitter.emitPacket<KafkatorioPacket2>({
|
||||
KafkatorioPacketEmitter.emitPacket<KafkatorioPacket>({
|
||||
data: data,
|
||||
modVersion: global.MOD_VERSION,
|
||||
tick: game.tick,
|
||||
|
|
@ -27,7 +27,7 @@ export class KafkatorioPacketEmitter {
|
|||
}
|
||||
|
||||
/** Emit a serialised KafkatorioPacket */
|
||||
private static emitPacket<T extends KafkatorioPacket2>(packet: T) {
|
||||
private static emitPacket<T extends KafkatorioPacket>(packet: T) {
|
||||
let data = game.table_to_json(packet)
|
||||
localised_print(`KafkatorioPacket: ${data}`)
|
||||
// rcon.print(`KafkatorioPacket: ${data}`)
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ import PacketEmitter from "../PacketEmitter";
|
|||
import {
|
||||
ConfigurationUpdateGameData,
|
||||
ConfigurationUpdateModData,
|
||||
KafkatorioPacketData2
|
||||
KafkatorioPacketData
|
||||
} from "../../generated/kafkatorio-schema/kafkatorio-schema";
|
||||
import Type = KafkatorioPacketData2.Type;
|
||||
import ConfigurationUpdate = KafkatorioPacketData2.ConfigurationUpdate;
|
||||
import Type = KafkatorioPacketData.Type;
|
||||
import ConfigurationUpdate = KafkatorioPacketData.ConfigurationUpdate;
|
||||
|
||||
export function emitConfigurationUpdate(changeData: ConfigurationChangedData) {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import {Converters} from "../events/converters";
|
||||
import PacketEmitter from "../PacketEmitter";
|
||||
import {
|
||||
FactorioPrototype2,
|
||||
KafkatorioPacketData2
|
||||
FactorioPrototype,
|
||||
KafkatorioPacketData
|
||||
} from "../../generated/kafkatorio-schema/kafkatorio-schema";
|
||||
import Type = KafkatorioPacketData2.Type;
|
||||
import PrototypesUpdate = KafkatorioPacketData2.PrototypesUpdate;
|
||||
import Type = KafkatorioPacketData.Type;
|
||||
import PrototypesUpdate = KafkatorioPacketData.PrototypesUpdate;
|
||||
|
||||
|
||||
export function emitPrototypes() {
|
||||
|
|
@ -18,20 +18,20 @@ export function emitPrototypes() {
|
|||
PacketEmitter.emitInstantPacket(data)
|
||||
}
|
||||
|
||||
function prototypes(): FactorioPrototype2[] {
|
||||
let prototypes: FactorioPrototype2[] = []
|
||||
function prototypes(): FactorioPrototype[] {
|
||||
let prototypes: FactorioPrototype[] = []
|
||||
|
||||
prototypes.push(...getMapTilePrototypes())
|
||||
|
||||
return prototypes
|
||||
}
|
||||
|
||||
function getMapTilePrototypes(): FactorioPrototype2.MapTile[] {
|
||||
let tiles: FactorioPrototype2.MapTile[] = []
|
||||
function getMapTilePrototypes(): FactorioPrototype.MapTile[] {
|
||||
let tiles: FactorioPrototype.MapTile[] = []
|
||||
for (let [, tile] of game.tile_prototypes) {
|
||||
tiles.push(
|
||||
<FactorioPrototype2.MapTile>{
|
||||
type: FactorioPrototype2.Type.MapTile,
|
||||
<FactorioPrototype.MapTile>{
|
||||
type: FactorioPrototype.Type.MapTile,
|
||||
|
||||
name: tile.name,
|
||||
order: tile.order,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import PacketEmitter from "../PacketEmitter";
|
||||
import {KafkatorioPacketData2} from "../../generated/kafkatorio-schema/kafkatorio-schema";
|
||||
import Type = KafkatorioPacketData2.Type;
|
||||
import {KafkatorioPacketData} from "../../generated/kafkatorio-schema/kafkatorio-schema";
|
||||
import Type = KafkatorioPacketData.Type;
|
||||
|
||||
// export function handlePlayerUpdate(tick: uint, eventType: string, playerIndex: uint) {
|
||||
// let player: LuaPlayer = game.players[playerIndex]
|
||||
|
|
@ -36,7 +36,7 @@ export function handleSurfaceUpdate(
|
|||
eventType: string,
|
||||
surface: LuaSurface,
|
||||
) {
|
||||
const update: KafkatorioPacketData2.SurfaceUpdate = {
|
||||
const update: KafkatorioPacketData.SurfaceUpdate = {
|
||||
type: Type.SurfaceUpdate,
|
||||
|
||||
name: surface.name,
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import PacketEmitter from "../PacketEmitter";
|
||||
import {KafkatorioPacketData2} from "../../generated/kafkatorio-schema/kafkatorio-schema";
|
||||
import Type = KafkatorioPacketData2.Type;
|
||||
import {KafkatorioPacketData} from "../../generated/kafkatorio-schema/kafkatorio-schema";
|
||||
import Type = KafkatorioPacketData.Type;
|
||||
|
||||
script.on_event(
|
||||
defines.events.on_console_chat,
|
||||
(event: OnConsoleChatEvent) => {
|
||||
const update: KafkatorioPacketData2.ConsoleChatUpdate = {
|
||||
const update: KafkatorioPacketData.ConsoleChatUpdate = {
|
||||
type: Type.ConsoleChatUpdate,
|
||||
|
||||
authorPlayerIndex: event.player_index ?? null,
|
||||
|
|
@ -18,7 +18,7 @@ script.on_event(
|
|||
script.on_event(
|
||||
defines.events.on_console_command,
|
||||
(event: OnConsoleCommandEvent) => {
|
||||
const update: KafkatorioPacketData2.ConsoleCommandUpdate = {
|
||||
const update: KafkatorioPacketData.ConsoleCommandUpdate = {
|
||||
type: Type.ConsoleCommandUpdate,
|
||||
|
||||
authorPlayerIndex: event.player_index ?? null,
|
||||
|
|
|
|||
|
|
@ -2,15 +2,15 @@ import {isEventType} from "./eventTypeCheck";
|
|||
import {Converters} from "./converters";
|
||||
import EventUpdatesManager, {EventUpdates} from "../cache/EventDataCache";
|
||||
import {
|
||||
KafkatorioPacketData2,
|
||||
KafkatorioPacketData,
|
||||
MapChunkPosition,
|
||||
MapTileDictionary
|
||||
} from "../../generated/kafkatorio-schema/kafkatorio-schema";
|
||||
import CacheKey = EventUpdates.PacketKey;
|
||||
import Type = KafkatorioPacketData2.Type;
|
||||
import Type = KafkatorioPacketData.Type;
|
||||
|
||||
|
||||
type MapChunkUpdater = (data: KafkatorioPacketData2.MapChunkUpdate) => void
|
||||
type MapChunkUpdater = (data: KafkatorioPacketData.MapChunkUpdate) => void
|
||||
|
||||
|
||||
const mapProtoNameToKey: { [key: string]: uint } = {}
|
||||
|
|
@ -38,12 +38,12 @@ function mapTilesUpdateDebounce(
|
|||
return
|
||||
}
|
||||
|
||||
const key: KafkatorioPacketData2.MapChunkUpdate["key"] = {
|
||||
const key: KafkatorioPacketData.MapChunkUpdate["key"] = {
|
||||
surfaceIndex: surface.index,
|
||||
chunkPosition: chunkPosition,
|
||||
}
|
||||
|
||||
EventUpdatesManager.debounce<KafkatorioPacketData2.MapChunkUpdate>(
|
||||
EventUpdatesManager.debounce<KafkatorioPacketData.MapChunkUpdate>(
|
||||
key,
|
||||
Type.MapChunkUpdate,
|
||||
data => {
|
||||
|
|
@ -267,12 +267,12 @@ script.on_event(
|
|||
}
|
||||
|
||||
for (const position of e.positions) {
|
||||
const key: CacheKey<KafkatorioPacketData2.MapChunkUpdate> = {
|
||||
const key: CacheKey<KafkatorioPacketData.MapChunkUpdate> = {
|
||||
surfaceIndex: surface.index,
|
||||
chunkPosition: [position.x, position.y],
|
||||
}
|
||||
|
||||
EventUpdatesManager.debounce<KafkatorioPacketData2.MapChunkUpdate>(
|
||||
EventUpdatesManager.debounce<KafkatorioPacketData.MapChunkUpdate>(
|
||||
key,
|
||||
Type.MapChunkUpdate,
|
||||
data => data.isDeleted = true,
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import {Converters} from "./converters";
|
||||
import EventUpdatesManager from "../cache/EventDataCache";
|
||||
import {KafkatorioPacketData2} from "../../generated/kafkatorio-schema/kafkatorio-schema";
|
||||
import Type = KafkatorioPacketData2.Type;
|
||||
import {KafkatorioPacketData} from "../../generated/kafkatorio-schema/kafkatorio-schema";
|
||||
import Type = KafkatorioPacketData.Type;
|
||||
|
||||
|
||||
type PlayerUpdater = (player: LuaPlayer, data: KafkatorioPacketData2.PlayerUpdate) => void
|
||||
type PlayerUpdater = (player: LuaPlayer, data: KafkatorioPacketData.PlayerUpdate) => void
|
||||
|
||||
function playerUpdateThrottle(
|
||||
playerIndex: uint,
|
||||
|
|
@ -12,7 +12,7 @@ function playerUpdateThrottle(
|
|||
mutate: PlayerUpdater,
|
||||
) {
|
||||
|
||||
EventUpdatesManager.throttle<KafkatorioPacketData2.PlayerUpdate>(
|
||||
EventUpdatesManager.throttle<KafkatorioPacketData.PlayerUpdate>(
|
||||
{index: playerIndex},
|
||||
Type.PlayerUpdate,
|
||||
data => {
|
||||
|
|
@ -39,7 +39,7 @@ function playerUpdateThrottle(
|
|||
// )
|
||||
// }
|
||||
|
||||
function playerOnlineInfo(player: LuaPlayer, data: KafkatorioPacketData2.PlayerUpdate) {
|
||||
function playerOnlineInfo(player: LuaPlayer, data: KafkatorioPacketData.PlayerUpdate) {
|
||||
data.lastOnline = player.last_online
|
||||
data.onlineTime = player.online_time
|
||||
data.afkTime = player.afk_time
|
||||
|
|
|
|||
|
|
@ -1,24 +1,24 @@
|
|||
import {Data, DoubleSettingDefinition} from "typed-factorio/settings/types"
|
||||
import {KafkatorioKeyedPacketData, KafkatorioKeyedPacketTypes} from "../types";
|
||||
import {KafkatorioPacketData2} from "../../generated/kafkatorio-schema/kafkatorio-schema";
|
||||
import {KafkatorioPacketData} from "../../generated/kafkatorio-schema/kafkatorio-schema";
|
||||
|
||||
export class KafkatorioSettingsConfig {
|
||||
|
||||
|
||||
private static eventCacheExpirationDefaultSeconds: Record<KafkatorioKeyedPacketTypes, double> = {
|
||||
"dev.adamko.kafkatorio.schema2.PlayerUpdate": 0.5,
|
||||
"dev.adamko.kafkatorio.schema2.MapChunkUpdate": 30,
|
||||
"dev.adamko.kafkatorio.schema2.EntityUpdate": 5,
|
||||
"dev.adamko.kafkatorio.schema.packets.PlayerUpdate": 0.5,
|
||||
"dev.adamko.kafkatorio.schema.packets.MapChunkUpdate": 30,
|
||||
"dev.adamko.kafkatorio.schema.packets.EntityUpdate": 5,
|
||||
}
|
||||
|
||||
|
||||
private eventCacheExpirationTicks: Record<KafkatorioKeyedPacketTypes, double> = {
|
||||
"dev.adamko.kafkatorio.schema2.PlayerUpdate":
|
||||
KafkatorioSettingsConfig.eventCacheExpirationDefaultSeconds[KafkatorioPacketData2.Type.PlayerUpdate],
|
||||
"dev.adamko.kafkatorio.schema2.MapChunkUpdate":
|
||||
KafkatorioSettingsConfig.eventCacheExpirationDefaultSeconds[KafkatorioPacketData2.Type.MapChunkUpdate],
|
||||
"dev.adamko.kafkatorio.schema2.EntityUpdate":
|
||||
KafkatorioSettingsConfig.eventCacheExpirationDefaultSeconds[KafkatorioPacketData2.Type.EntityUpdate],
|
||||
"dev.adamko.kafkatorio.schema.packets.PlayerUpdate":
|
||||
KafkatorioSettingsConfig.eventCacheExpirationDefaultSeconds[KafkatorioPacketData.Type.PlayerUpdate],
|
||||
"dev.adamko.kafkatorio.schema.packets.MapChunkUpdate":
|
||||
KafkatorioSettingsConfig.eventCacheExpirationDefaultSeconds[KafkatorioPacketData.Type.MapChunkUpdate],
|
||||
"dev.adamko.kafkatorio.schema.packets.EntityUpdate":
|
||||
KafkatorioSettingsConfig.eventCacheExpirationDefaultSeconds[KafkatorioPacketData.Type.EntityUpdate],
|
||||
}
|
||||
|
||||
public getEventCacheExpirationTicks(packet: KafkatorioKeyedPacketData): uint {
|
||||
|
|
@ -26,9 +26,9 @@ export class KafkatorioSettingsConfig {
|
|||
}
|
||||
|
||||
private static types: KafkatorioKeyedPacketTypes[] = [
|
||||
KafkatorioPacketData2.Type.PlayerUpdate,
|
||||
KafkatorioPacketData2.Type.MapChunkUpdate,
|
||||
KafkatorioPacketData2.Type.EntityUpdate,
|
||||
KafkatorioPacketData.Type.PlayerUpdate,
|
||||
KafkatorioPacketData.Type.MapChunkUpdate,
|
||||
KafkatorioPacketData.Type.EntityUpdate,
|
||||
]
|
||||
|
||||
public loadSettings(): void {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import {KafkatorioPacketData2} from "../generated/kafkatorio-schema/kafkatorio-schema";
|
||||
import {KafkatorioPacketData} from "../generated/kafkatorio-schema/kafkatorio-schema";
|
||||
|
||||
export type EventName = keyof typeof defines.events
|
||||
|
||||
|
|
@ -19,7 +19,7 @@ type NonNullableKeys<TYPE> = {
|
|||
}
|
||||
|
||||
|
||||
type KafkatorioKeyedPacketData = Extract<KafkatorioPacketData2, { key: object }>
|
||||
type KafkatorioKeyedPacketData = Extract<KafkatorioPacketData, { key: object }>
|
||||
|
||||
type KafkatorioKeyedPacketTypes = KafkatorioKeyedPacketData["type"];
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@
|
|||
"engines": {
|
||||
"node": "~14.19.1"
|
||||
},
|
||||
"devDependencies": {},
|
||||
"devDependencies": {
|
||||
},
|
||||
"dependencies": {
|
||||
"lua-types": "^2.11.0",
|
||||
"typescript-to-lua": "1.4.3",
|
||||
|
|
@ -18,7 +19,10 @@
|
|||
},
|
||||
"// @types/node": "^12.0.8",
|
||||
"license": "UNLICENSED",
|
||||
"peerDependencies": {},
|
||||
"optionalDependencies": {},
|
||||
"bundledDependencies": []
|
||||
"peerDependencies": {
|
||||
},
|
||||
"optionalDependencies": {
|
||||
},
|
||||
"bundledDependencies": [
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
package dev.adamko.kafkatorio.schema2
|
||||
package dev.adamko.kafkatorio.schema.packets
|
||||
|
||||
import dev.adamko.kafkatorio.schema.common.Tick
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@Serializable
|
||||
data class KafkatorioPacket2(
|
||||
data class KafkatorioPacket(
|
||||
val modVersion: String,
|
||||
val tick: Tick,
|
||||
val data: KafkatorioPacketData2,
|
||||
val data: KafkatorioPacketData,
|
||||
)
|
||||
|
||||
|
||||
@Serializable
|
||||
sealed class KafkatorioPacketData2
|
||||
sealed class KafkatorioPacketData
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
package dev.adamko.kafkatorio.schema2
|
||||
package dev.adamko.kafkatorio.schema.packets
|
||||
|
||||
import dev.adamko.kafkatorio.schema.common.PlayerIndex
|
||||
import dev.adamko.kafkatorio.schema.common.SurfaceIndex
|
||||
import dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2
|
||||
import dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
/** No key, no caching. Must be sent instantly. */
|
||||
@Serializable
|
||||
sealed class KafkatorioInstantPacketData2 : KafkatorioPacketData2()
|
||||
sealed class KafkatorioInstantPacketData : KafkatorioPacketData()
|
||||
|
||||
|
||||
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
|
||||
|
|
@ -20,7 +20,7 @@ data class ConfigurationUpdate(
|
|||
val allMods: List<ConfigurationUpdateModData>,
|
||||
val modStartupSettingsChange: Boolean,
|
||||
val migrationApplied: Boolean,
|
||||
) : KafkatorioInstantPacketData2() {
|
||||
) : KafkatorioInstantPacketData() {
|
||||
|
||||
@Serializable
|
||||
data class ConfigurationUpdateGameData(
|
||||
|
|
@ -41,7 +41,7 @@ data class ConfigurationUpdate(
|
|||
data class ConsoleChatUpdate(
|
||||
val authorPlayerIndex: PlayerIndex?,
|
||||
val content: String,
|
||||
) : KafkatorioInstantPacketData2()
|
||||
) : KafkatorioInstantPacketData()
|
||||
|
||||
|
||||
@Serializable
|
||||
|
|
@ -49,13 +49,13 @@ data class ConsoleCommandUpdate(
|
|||
val authorPlayerIndex: PlayerIndex?,
|
||||
val command: String,
|
||||
val parameters: String,
|
||||
) : KafkatorioInstantPacketData2()
|
||||
) : KafkatorioInstantPacketData()
|
||||
|
||||
|
||||
@Serializable
|
||||
data class PrototypesUpdate(
|
||||
val prototypes: List<FactorioPrototype2>,
|
||||
) : KafkatorioInstantPacketData2()
|
||||
val prototypes: List<FactorioPrototype>,
|
||||
) : KafkatorioInstantPacketData()
|
||||
|
||||
|
||||
@Serializable
|
||||
|
|
@ -63,7 +63,7 @@ data class SurfaceUpdate(
|
|||
val index: SurfaceIndex,
|
||||
val daytime: Double,
|
||||
val name: String,
|
||||
) : KafkatorioInstantPacketData2()
|
||||
) : KafkatorioInstantPacketData()
|
||||
|
||||
|
||||
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package dev.adamko.kafkatorio.schema2
|
||||
package dev.adamko.kafkatorio.schema.packets
|
||||
|
||||
import dev.adamko.kafkatorio.schema.common.Colour
|
||||
import dev.adamko.kafkatorio.schema.common.EntityIdentifiers
|
||||
|
|
@ -17,7 +17,7 @@ import kotlinx.serialization.Serializable
|
|||
|
||||
/** Has a key, so it can be debounced */
|
||||
@Serializable
|
||||
sealed class KafkatorioKeyedPacketData2 : KafkatorioPacketData2() {
|
||||
sealed class KafkatorioKeyedPacketData : KafkatorioPacketData() {
|
||||
/** Count how many events this packet is aggregating data from */
|
||||
abstract val key: KafkatorioKeyedPacketKey2
|
||||
abstract val eventCounts: Map<String, UInt>?
|
||||
|
|
@ -54,7 +54,7 @@ data class EntityUpdate(
|
|||
val localisedDescription: String? = null,
|
||||
val localisedName: String? = null,
|
||||
val prototype: PrototypeName? = null,
|
||||
) : KafkatorioKeyedPacketData2()
|
||||
) : KafkatorioKeyedPacketData()
|
||||
|
||||
|
||||
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
|
||||
|
|
@ -79,7 +79,7 @@ data class MapChunkUpdate(
|
|||
/** updated tiles - might be partial and not all tiles in the chunk */
|
||||
val tileDictionary: MapTileDictionary? = null,
|
||||
val isDeleted: Boolean? = null,
|
||||
) : KafkatorioKeyedPacketData2()
|
||||
) : KafkatorioKeyedPacketData()
|
||||
|
||||
|
||||
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
|
||||
|
|
@ -120,7 +120,7 @@ data class PlayerUpdate(
|
|||
val disconnectReason: String? = null,
|
||||
/** `true` when a player is removed (deleted) from the game */
|
||||
val isRemoved: Boolean? = null,
|
||||
) : KafkatorioKeyedPacketData2()
|
||||
) : KafkatorioKeyedPacketData()
|
||||
|
||||
|
||||
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
|
||||
|
|
@ -7,7 +7,7 @@ import kotlinx.serialization.Serializable
|
|||
|
||||
|
||||
@Serializable
|
||||
sealed class FactorioPrototype2 {
|
||||
sealed class FactorioPrototype {
|
||||
|
||||
@Serializable
|
||||
data class MapTile(
|
||||
|
|
@ -19,5 +19,5 @@ sealed class FactorioPrototype2 {
|
|||
val order: String,
|
||||
/** Can the tile be mined for resources? */
|
||||
val canBeMined: Boolean,
|
||||
) : FactorioPrototype2()
|
||||
) : FactorioPrototype()
|
||||
}
|
||||
|
|
@ -6,14 +6,12 @@ import dev.adamko.kafkatorio.schema.common.PrototypeName
|
|||
import dev.adamko.kafkatorio.schema.common.SurfaceIndex
|
||||
import dev.adamko.kafkatorio.schema.common.Tick
|
||||
import dev.adamko.kafkatorio.schema.jsonMapperKafkatorio
|
||||
import dev.adamko.kafkatorio.schema2.KafkatorioPacket2
|
||||
import dev.adamko.kafkatorio.schema2.MapChunkUpdate
|
||||
import dev.adamko.kafkatorio.schema2.MapChunkUpdateKey
|
||||
import dev.adamko.kafkatorio.schema.packets.KafkatorioPacket
|
||||
import dev.adamko.kafkatorio.schema.packets.MapChunkUpdate
|
||||
import dev.adamko.kafkatorio.schema.packets.MapChunkUpdateKey
|
||||
import io.kotest.core.spec.style.FunSpec
|
||||
import io.kotest.matchers.shouldBe
|
||||
import kotlin.math.exp
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.encodeToString
|
||||
|
||||
class MapChunkUpdateTest : FunSpec({
|
||||
|
||||
|
|
@ -22,7 +20,7 @@ class MapChunkUpdateTest : FunSpec({
|
|||
val json = """
|
||||
{
|
||||
"data": {
|
||||
"type": "dev.adamko.kafkatorio.schema2.MapChunkUpdate",
|
||||
"type": "dev.adamko.kafkatorio.schema.packets.MapChunkUpdate",
|
||||
"key": {
|
||||
"surfaceIndex": 1,
|
||||
"chunkPosition": [
|
||||
|
|
@ -57,7 +55,7 @@ class MapChunkUpdateTest : FunSpec({
|
|||
}
|
||||
""".trimIndent()
|
||||
|
||||
val expected = KafkatorioPacket2(
|
||||
val expected = KafkatorioPacket(
|
||||
tick = Tick(36u),
|
||||
modVersion = "0.4.0",
|
||||
data = MapChunkUpdate(
|
||||
|
|
@ -86,7 +84,7 @@ class MapChunkUpdateTest : FunSpec({
|
|||
)
|
||||
|
||||
test("decode") {
|
||||
val packet: KafkatorioPacket2 = jsonMapperKafkatorio.decodeFromString(json)
|
||||
val packet: KafkatorioPacket = jsonMapperKafkatorio.decodeFromString(json)
|
||||
packet shouldBe expected
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@ package dev.adamko.kafkatorio.events.schema
|
|||
import dev.adamko.kafkatorio.schema.common.Colour
|
||||
import dev.adamko.kafkatorio.schema.common.PrototypeName
|
||||
import dev.adamko.kafkatorio.schema.jsonMapperKafkatorio
|
||||
import dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2
|
||||
import dev.adamko.kafkatorio.schema2.KafkatorioPacket2
|
||||
import dev.adamko.kafkatorio.schema2.PrototypesUpdate
|
||||
import dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype
|
||||
import dev.adamko.kafkatorio.schema.packets.KafkatorioPacket
|
||||
import dev.adamko.kafkatorio.schema.packets.PrototypesUpdate
|
||||
import io.kotest.core.spec.style.BehaviorSpec
|
||||
import io.kotest.inspectors.forOne
|
||||
import io.kotest.matchers.shouldBe
|
||||
|
|
@ -20,10 +20,10 @@ class PrototypesTest : BehaviorSpec({
|
|||
"modVersion": "0.2.4",
|
||||
"tick": 534,
|
||||
"data": {
|
||||
"type": "dev.adamko.kafkatorio.schema2.PrototypesUpdate",
|
||||
"type": "dev.adamko.kafkatorio.schema.packets.PrototypesUpdate",
|
||||
"prototypes": [
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "tile-unknown",
|
||||
"order": "z-a",
|
||||
"layer": 0,
|
||||
|
|
@ -37,7 +37,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
""".trimIndent()
|
||||
|
||||
Then("expect can be parsed") {
|
||||
val data = jsonMapperKafkatorio.decodeFromString<KafkatorioPacket2>(raw)
|
||||
val data = jsonMapperKafkatorio.decodeFromString<KafkatorioPacket>(raw)
|
||||
println(data)
|
||||
}
|
||||
|
||||
|
|
@ -50,10 +50,10 @@ class PrototypesTest : BehaviorSpec({
|
|||
"modVersion": "0.3.2",
|
||||
"tick": 534,
|
||||
"data": {
|
||||
"type": "dev.adamko.kafkatorio.schema2.PrototypesUpdate",
|
||||
"type": "dev.adamko.kafkatorio.schema.packets.PrototypesUpdate",
|
||||
"prototypes": [
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "stone-path",
|
||||
"order": "a[artificial]-a[tier-1]-a[stone-path]",
|
||||
"layer": 60,
|
||||
|
|
@ -64,7 +64,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": true
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "concrete",
|
||||
"order": "a[artificial]-b[tier-2]-a[concrete]",
|
||||
"layer": 61,
|
||||
|
|
@ -75,7 +75,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": true
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "hazard-concrete-left",
|
||||
"order": "a[artificial]-b[tier-2]-b[hazard-concrete-left]",
|
||||
"layer": 62,
|
||||
|
|
@ -86,7 +86,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": true
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "hazard-concrete-right",
|
||||
"order": "a[artificial]-b[tier-2]-c[hazard-concrete-right]",
|
||||
"layer": 62,
|
||||
|
|
@ -97,7 +97,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": true
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "refined-concrete",
|
||||
"order": "a[artificial]-c[tier-3]-a[refined-concrete]",
|
||||
"layer": 64,
|
||||
|
|
@ -108,7 +108,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": true
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "refined-hazard-concrete-left",
|
||||
"order": "a[artificial]-c[tier-3]-b[refined-hazard-concrete-left]",
|
||||
"layer": 65,
|
||||
|
|
@ -119,7 +119,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": true
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "refined-hazard-concrete-right",
|
||||
"order": "a[artificial]-c[tier-3]-c[refined-hazard-concrete-right]",
|
||||
"layer": 65,
|
||||
|
|
@ -130,7 +130,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": true
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "landfill",
|
||||
"order": "a[artificial]-d[utility]-a[landfill]",
|
||||
"layer": 57,
|
||||
|
|
@ -141,7 +141,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "acid-refined-concrete",
|
||||
"order": "a[artificial]-e[color-concrete]-acid",
|
||||
"layer": 97,
|
||||
|
|
@ -152,7 +152,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "black-refined-concrete",
|
||||
"order": "a[artificial]-e[color-concrete]-black",
|
||||
"layer": 88,
|
||||
|
|
@ -163,7 +163,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "blue-refined-concrete",
|
||||
"order": "a[artificial]-e[color-concrete]-blue",
|
||||
"layer": 73,
|
||||
|
|
@ -174,7 +174,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "brown-refined-concrete",
|
||||
"order": "a[artificial]-e[color-concrete]-brown",
|
||||
"layer": 91,
|
||||
|
|
@ -185,7 +185,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "cyan-refined-concrete",
|
||||
"order": "a[artificial]-e[color-concrete]-cyan",
|
||||
"layer": 94,
|
||||
|
|
@ -196,7 +196,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "green-refined-concrete",
|
||||
"order": "a[artificial]-e[color-concrete]-green",
|
||||
"layer": 70,
|
||||
|
|
@ -207,7 +207,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "orange-refined-concrete",
|
||||
"order": "a[artificial]-e[color-concrete]-orange",
|
||||
"layer": 76,
|
||||
|
|
@ -218,7 +218,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "pink-refined-concrete",
|
||||
"order": "a[artificial]-e[color-concrete]-pink",
|
||||
"layer": 82,
|
||||
|
|
@ -229,7 +229,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "purple-refined-concrete",
|
||||
"order": "a[artificial]-e[color-concrete]-purple",
|
||||
"layer": 85,
|
||||
|
|
@ -240,7 +240,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "red-refined-concrete",
|
||||
"order": "a[artificial]-e[color-concrete]-red",
|
||||
"layer": 67,
|
||||
|
|
@ -251,7 +251,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "yellow-refined-concrete",
|
||||
"order": "a[artificial]-e[color-concrete]-yellow",
|
||||
"layer": 79,
|
||||
|
|
@ -262,7 +262,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "grass-1",
|
||||
"order": "b[natural]-a[grass]-a[grass-1]",
|
||||
"layer": 26,
|
||||
|
|
@ -273,7 +273,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "grass-2",
|
||||
"order": "b[natural]-a[grass]-b[grass-2]",
|
||||
"layer": 28,
|
||||
|
|
@ -284,7 +284,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "grass-3",
|
||||
"order": "b[natural]-a[grass]-c[grass-3]",
|
||||
"layer": 29,
|
||||
|
|
@ -295,7 +295,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "grass-4",
|
||||
"order": "b[natural]-a[grass]-d[grass-4]",
|
||||
"layer": 30,
|
||||
|
|
@ -306,7 +306,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "dry-dirt",
|
||||
"order": "b[natural]-b[dirt]-a[dry-dirt]",
|
||||
"layer": 18,
|
||||
|
|
@ -317,7 +317,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "dirt-1",
|
||||
"order": "b[natural]-b[dirt]-b[dirt-1]",
|
||||
"layer": 19,
|
||||
|
|
@ -328,7 +328,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "dirt-2",
|
||||
"order": "b[natural]-b[dirt]-c[dirt-2]",
|
||||
"layer": 20,
|
||||
|
|
@ -339,7 +339,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "dirt-3",
|
||||
"order": "b[natural]-b[dirt]-d[dirt-3]",
|
||||
"layer": 21,
|
||||
|
|
@ -350,7 +350,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "dirt-4",
|
||||
"order": "b[natural]-b[dirt]-e[dirt-4]",
|
||||
"layer": 22,
|
||||
|
|
@ -361,7 +361,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "dirt-5",
|
||||
"order": "b[natural]-b[dirt]-f[dirt-5]",
|
||||
"layer": 23,
|
||||
|
|
@ -372,7 +372,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "dirt-6",
|
||||
"order": "b[natural]-b[dirt]-g[dirt-6]",
|
||||
"layer": 24,
|
||||
|
|
@ -383,7 +383,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "dirt-7",
|
||||
"order": "b[natural]-b[dirt]-h[dirt-7]",
|
||||
"layer": 25,
|
||||
|
|
@ -394,7 +394,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "sand-1",
|
||||
"order": "b[natural]-c[sand]-a[sand-1]",
|
||||
"layer": 8,
|
||||
|
|
@ -405,7 +405,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "sand-2",
|
||||
"order": "b[natural]-c[sand]-b[sand-2]",
|
||||
"layer": 9,
|
||||
|
|
@ -416,7 +416,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "sand-3",
|
||||
"order": "b[natural]-c[sand]-c[sand-3]",
|
||||
"layer": 10,
|
||||
|
|
@ -427,7 +427,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "red-desert-0",
|
||||
"order": "b[natural]-d[red-desert]-a[red-desert-0]",
|
||||
"layer": 31,
|
||||
|
|
@ -438,7 +438,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "red-desert-1",
|
||||
"order": "b[natural]-d[red-desert]-b[red-desert-1]",
|
||||
"layer": 14,
|
||||
|
|
@ -449,7 +449,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "red-desert-2",
|
||||
"order": "b[natural]-d[red-desert]-c[red-desert-2]",
|
||||
"layer": 15,
|
||||
|
|
@ -460,7 +460,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "red-desert-3",
|
||||
"order": "b[natural]-d[red-desert]-d[red-desert-3]",
|
||||
"layer": 16,
|
||||
|
|
@ -471,7 +471,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "water",
|
||||
"order": "c[water]-a[water]",
|
||||
"layer": 3,
|
||||
|
|
@ -486,7 +486,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "deepwater",
|
||||
"order": "c[water]-b[deep-water]",
|
||||
"layer": 3,
|
||||
|
|
@ -501,7 +501,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "water-green",
|
||||
"order": "c[water]-c[water-green]",
|
||||
"layer": 3,
|
||||
|
|
@ -516,7 +516,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "deepwater-green",
|
||||
"order": "c[water]-d[deepwater-green]",
|
||||
"layer": 3,
|
||||
|
|
@ -531,7 +531,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "water-shallow",
|
||||
"order": "c[water]-e[water-shallow]",
|
||||
"layer": 6,
|
||||
|
|
@ -545,7 +545,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "water-mud",
|
||||
"order": "c[water]-g[water-mud]",
|
||||
"layer": 7,
|
||||
|
|
@ -559,7 +559,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "nuclear-ground",
|
||||
"order": "d[destruction]-a[nuclear]-a[nuclear-ground]",
|
||||
"layer": 33,
|
||||
|
|
@ -570,7 +570,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "water-wube",
|
||||
"order": "x[wube]-a[water-wube]",
|
||||
"layer": 2,
|
||||
|
|
@ -585,7 +585,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "tile-unknown",
|
||||
"order": "z-a",
|
||||
"layer": 0,
|
||||
|
|
@ -595,7 +595,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "out-of-map",
|
||||
"order": "z[other]-a[out-of-map]",
|
||||
"layer": 0,
|
||||
|
|
@ -613,7 +613,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "lab-dark-1",
|
||||
"order": "z[other]-b[lab]-a[lab-dark-1]",
|
||||
"layer": 70,
|
||||
|
|
@ -624,7 +624,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "lab-dark-2",
|
||||
"order": "z[other]-b[lab]-b[lab-dark-2]",
|
||||
"layer": 70,
|
||||
|
|
@ -635,7 +635,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "lab-white",
|
||||
"order": "z[other]-b[lab]-c[lab-white]",
|
||||
"layer": 70,
|
||||
|
|
@ -646,7 +646,7 @@ class PrototypesTest : BehaviorSpec({
|
|||
"canBeMined": false
|
||||
},
|
||||
{
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype.MapTile",
|
||||
"name": "tutorial-grid",
|
||||
"order": "z[other]-c[tutorial]-a[tutorial-grid]",
|
||||
"layer": 55,
|
||||
|
|
@ -662,13 +662,13 @@ class PrototypesTest : BehaviorSpec({
|
|||
""".trimIndent()
|
||||
|
||||
Then("expect can be parsed") {
|
||||
val packet: KafkatorioPacket2 = jsonMapperKafkatorio.decodeFromString(raw)
|
||||
val packet: KafkatorioPacket = jsonMapperKafkatorio.decodeFromString(raw)
|
||||
// println(packet)
|
||||
|
||||
packet.data.shouldBeInstanceOf<PrototypesUpdate>()
|
||||
.prototypes
|
||||
.forOne {
|
||||
it.shouldBeInstanceOf<FactorioPrototype2.MapTile>()
|
||||
it.shouldBeInstanceOf<FactorioPrototype.MapTile>()
|
||||
it.name shouldBe PrototypeName("tutorial-grid")
|
||||
it.order shouldBe "z[other]-c[tutorial]-a[tutorial-grid]"
|
||||
it.layer shouldBe 55u
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ import dev.adamko.kafkatorio.schema.common.SurfaceIndex
|
|||
import dev.adamko.kafkatorio.schema.common.Tick
|
||||
import dev.adamko.kafkatorio.schema.common.UnitNumber
|
||||
import dev.adamko.kafkatorio.schema.jsonMapperKafkatorio
|
||||
import dev.adamko.kafkatorio.schema2.KafkatorioPacket2
|
||||
import dev.adamko.kafkatorio.schema2.PlayerUpdate
|
||||
import dev.adamko.kafkatorio.schema2.PlayerUpdateKey
|
||||
import dev.adamko.kafkatorio.schema2.SurfaceUpdate
|
||||
import dev.adamko.kafkatorio.schema.packets.KafkatorioPacket
|
||||
import dev.adamko.kafkatorio.schema.packets.PlayerUpdate
|
||||
import dev.adamko.kafkatorio.schema.packets.PlayerUpdateKey
|
||||
import dev.adamko.kafkatorio.schema.packets.SurfaceUpdate
|
||||
import io.kotest.core.spec.style.FunSpec
|
||||
import io.kotest.matchers.shouldBe
|
||||
import kotlinx.serialization.decodeFromString
|
||||
|
|
@ -27,7 +27,7 @@ class UpdatePacketsTest : FunSpec({
|
|||
"tick": 66,
|
||||
"modVersion": "0.3.2",
|
||||
"data": {
|
||||
"type": "dev.adamko.kafkatorio.schema2.PlayerUpdate",
|
||||
"type": "dev.adamko.kafkatorio.schema.packets.PlayerUpdate",
|
||||
"key": {"index": 1},
|
||||
"afkTime": 0,
|
||||
"chatColour": [1, 0.4, 0.6, 1],
|
||||
|
|
@ -54,9 +54,9 @@ class UpdatePacketsTest : FunSpec({
|
|||
""".trimIndent()
|
||||
|
||||
test("decode") {
|
||||
val packet: KafkatorioPacket2 = jsonMapperKafkatorio.decodeFromString(json)
|
||||
val packet: KafkatorioPacket = jsonMapperKafkatorio.decodeFromString(json)
|
||||
|
||||
packet shouldBe KafkatorioPacket2(
|
||||
packet shouldBe KafkatorioPacket(
|
||||
modVersion = "0.3.2",
|
||||
tick = Tick(66u),
|
||||
data = PlayerUpdate(
|
||||
|
|
@ -88,7 +88,7 @@ class UpdatePacketsTest : FunSpec({
|
|||
}
|
||||
|
||||
test("encode") {
|
||||
val v = KafkatorioPacket2(
|
||||
val v = KafkatorioPacket(
|
||||
modVersion = "0.3.2",
|
||||
tick = Tick(66u),
|
||||
data = PlayerUpdate(
|
||||
|
|
@ -124,7 +124,7 @@ class UpdatePacketsTest : FunSpec({
|
|||
"modVersion": "0.3.2",
|
||||
"tick": 66,
|
||||
"data": {
|
||||
"type": "dev.adamko.kafkatorio.schema2.PlayerUpdate",
|
||||
"type": "dev.adamko.kafkatorio.schema.packets.PlayerUpdate",
|
||||
"key": {
|
||||
"index": 1
|
||||
},
|
||||
|
|
@ -151,7 +151,7 @@ class UpdatePacketsTest : FunSpec({
|
|||
"tick": 227934,
|
||||
"modVersion": "0.3.2",
|
||||
"data": {
|
||||
"type": "dev.adamko.kafkatorio.schema2.PlayerUpdate",
|
||||
"type": "dev.adamko.kafkatorio.schema.packets.PlayerUpdate",
|
||||
"key": {
|
||||
"index": 1
|
||||
},
|
||||
|
|
@ -172,9 +172,9 @@ class UpdatePacketsTest : FunSpec({
|
|||
""".trimIndent()
|
||||
|
||||
test("decode") {
|
||||
val packet: KafkatorioPacket2 = jsonMapperKafkatorio.decodeFromString(json)
|
||||
val packet: KafkatorioPacket = jsonMapperKafkatorio.decodeFromString(json)
|
||||
|
||||
packet shouldBe KafkatorioPacket2(
|
||||
packet shouldBe KafkatorioPacket(
|
||||
modVersion = "0.3.2",
|
||||
tick = Tick(227934u),
|
||||
data = PlayerUpdate(
|
||||
|
|
@ -215,7 +215,7 @@ class UpdatePacketsTest : FunSpec({
|
|||
val json = """
|
||||
{
|
||||
"data": {
|
||||
"type": "dev.adamko.kafkatorio.schema2.SurfaceUpdate",
|
||||
"type": "dev.adamko.kafkatorio.schema.packets.SurfaceUpdate",
|
||||
"name": "nauvis",
|
||||
"index": 1,
|
||||
"daytime": 0.73
|
||||
|
|
@ -225,7 +225,7 @@ class UpdatePacketsTest : FunSpec({
|
|||
}
|
||||
""".trimIndent()
|
||||
|
||||
val expected = KafkatorioPacket2(
|
||||
val expected = KafkatorioPacket(
|
||||
tick = Tick(176000u),
|
||||
modVersion = "0.3.2",
|
||||
data = SurfaceUpdate(
|
||||
|
|
@ -238,7 +238,7 @@ class UpdatePacketsTest : FunSpec({
|
|||
println(jsonMapperKafkatorio.encodeToString(expected))
|
||||
|
||||
test("decode") {
|
||||
val packet: KafkatorioPacket2 = jsonMapperKafkatorio.decodeFromString(json)
|
||||
val packet: KafkatorioPacket = jsonMapperKafkatorio.decodeFromString(json)
|
||||
packet shouldBe expected
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package dev.adamko.kafkatorio.events.schema
|
||||
|
||||
import dev.adamko.kafkatorio.schema2.KafkatorioPacket2
|
||||
import dev.adamko.kafkatorio.schema.packets.KafkatorioPacket
|
||||
import dev.adamko.kxstsgen.KxsTsConfig
|
||||
import dev.adamko.kxstsgen.KxsTsGenerator
|
||||
import dev.adamko.kxstsgen.core.TsDeclaration.TsTypeAlias
|
||||
|
|
@ -36,7 +36,7 @@ fun main(args: Array<String>) {
|
|||
)
|
||||
|
||||
val definitions = gen2.generate(
|
||||
KafkatorioPacket2.serializer(),
|
||||
KafkatorioPacket.serializer(),
|
||||
// KafkatorioKeyedPacketKey2.serializer(),
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
package dev.adamko.kafkatorio.processor.admin
|
||||
|
||||
import dev.adamko.kafkatorio.schema2.ConfigurationUpdate
|
||||
import dev.adamko.kafkatorio.schema2.ConsoleChatUpdate
|
||||
import dev.adamko.kafkatorio.schema2.ConsoleCommandUpdate
|
||||
import dev.adamko.kafkatorio.schema2.EntityUpdate
|
||||
import dev.adamko.kafkatorio.schema2.KafkatorioPacketData2
|
||||
import dev.adamko.kafkatorio.schema2.MapChunkUpdate
|
||||
import dev.adamko.kafkatorio.schema2.PlayerUpdate
|
||||
import dev.adamko.kafkatorio.schema2.PrototypesUpdate
|
||||
import dev.adamko.kafkatorio.schema2.SurfaceUpdate
|
||||
import dev.adamko.kafkatorio.schema.packets.ConfigurationUpdate
|
||||
import dev.adamko.kafkatorio.schema.packets.ConsoleChatUpdate
|
||||
import dev.adamko.kafkatorio.schema.packets.ConsoleCommandUpdate
|
||||
import dev.adamko.kafkatorio.schema.packets.EntityUpdate
|
||||
import dev.adamko.kafkatorio.schema.packets.KafkatorioPacketData
|
||||
import dev.adamko.kafkatorio.schema.packets.MapChunkUpdate
|
||||
import dev.adamko.kafkatorio.schema.packets.PlayerUpdate
|
||||
import dev.adamko.kafkatorio.schema.packets.PrototypesUpdate
|
||||
import dev.adamko.kafkatorio.schema.packets.SurfaceUpdate
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
|
||||
|
|
@ -16,7 +16,7 @@ private const val DOMAIN = "kafkatorio"
|
|||
|
||||
|
||||
const val TOPIC_SRC_SERVER_LOG = "$DOMAIN.src.server-log"
|
||||
// "factorio-server-log"
|
||||
|
||||
const val TOPIC_GROUPED_MAP_CHUNKS_STATE = "$DOMAIN.state.map-chunks.grouped"
|
||||
|
||||
|
||||
|
|
@ -27,12 +27,7 @@ fun allTopics(): Set<String> = buildSet {
|
|||
addAll(packetTopicNames.values)
|
||||
}
|
||||
|
||||
//fun KafkatorioPacket2.topicName(): String = data.topicName()
|
||||
|
||||
//fun KafkatorioPacketData2.topicName(): String = "$DOMAIN.packet.${topicName}"
|
||||
|
||||
|
||||
val KafkatorioPacketData2.topicName: String
|
||||
val KafkatorioPacketData.topicName: String
|
||||
get() = when (this) {
|
||||
is ConfigurationUpdate -> packetTopicNames.getValue(ConfigurationUpdate::class)
|
||||
is ConsoleChatUpdate -> packetTopicNames.getValue(ConsoleChatUpdate::class)
|
||||
|
|
@ -45,7 +40,7 @@ val KafkatorioPacketData2.topicName: String
|
|||
}
|
||||
|
||||
|
||||
private val packetTopicNames: Map<KClass<out KafkatorioPacketData2>, String> = mapOf(
|
||||
private val packetTopicNames: Map<KClass<out KafkatorioPacketData>, String> = mapOf(
|
||||
ConfigurationUpdate::class to "configuration",
|
||||
ConsoleChatUpdate::class to "console-chat",
|
||||
ConsoleCommandUpdate::class to "console-command",
|
||||
|
|
@ -58,47 +53,5 @@ private val packetTopicNames: Map<KClass<out KafkatorioPacketData2>, String> = m
|
|||
"$DOMAIN.packet.$v"
|
||||
}
|
||||
|
||||
val KClass<out KafkatorioPacketData2>.topicName: String
|
||||
val KClass<out KafkatorioPacketData>.topicName: String
|
||||
get() = packetTopicNames.getValue(this)
|
||||
|
||||
//fun packetTopic(
|
||||
// dataType: KafkatorioKeyedPacketData.KafkatorioKeyedPacketDataType,
|
||||
//): String = packetTopic(KafkatorioPacketType.KEYED, dataType.name.lowercase())
|
||||
//
|
||||
//private fun packetTopic(
|
||||
// packetType: KafkatorioPacketType,
|
||||
// dataType: String,
|
||||
//): String {
|
||||
// return "$DOMAIN.packet.$packetType.$dataType"
|
||||
//}
|
||||
|
||||
//sealed interface KafkatorioTopic {
|
||||
//
|
||||
// val type: String
|
||||
// val entity: String
|
||||
// val description: String
|
||||
//
|
||||
// companion object {
|
||||
// private const val DOMAIN = "kafkatorio"
|
||||
//
|
||||
// val KafkatorioTopic.topic
|
||||
// get() = listOf(DOMAIN, type, entity, description).joinToString(".")
|
||||
//
|
||||
// }
|
||||
//
|
||||
// data class Event(
|
||||
// override val entity: String,
|
||||
// override val description: String,
|
||||
// ) : KafkatorioTopic {
|
||||
// override val type: String = "event"
|
||||
// }
|
||||
//
|
||||
//
|
||||
// data class State(
|
||||
// override val entity: String,
|
||||
// override val description: String,
|
||||
// ) : KafkatorioTopic {
|
||||
// override val type: String = "state"
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
|
|
|||
|
|
@ -1,28 +1,11 @@
|
|||
package dev.adamko.kafkatorio.processor.serdes
|
||||
|
||||
import dev.adamko.kafkatorio.schema.jsonMapperKafkatorio
|
||||
import dev.adamko.kafkatorio.schema2.KafkatorioPacket2
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import org.apache.kafka.common.serialization.Deserializer
|
||||
import org.apache.kafka.common.serialization.Serde
|
||||
import org.apache.kafka.common.serialization.Serializer
|
||||
import org.http4k.format.ConfigurableKotlinxSerialization
|
||||
import org.http4k.format.asConfigurable
|
||||
import org.http4k.format.withStandardMappings
|
||||
|
||||
|
||||
//object KafkatorioPacketSerde : Serde<KafkatorioPacket2> {
|
||||
// override fun serializer() = Serializer<KafkatorioPacket> { _, message ->
|
||||
// jsonMapper.encodeToString<KafkatorioPacket>(message).encodeToByteArray()
|
||||
// }
|
||||
//
|
||||
// override fun deserializer() = Deserializer<KafkatorioPacket> { _, bytes ->
|
||||
// jsonMapper.decodeFromString(bytes.decodeToString())
|
||||
// }
|
||||
//}
|
||||
|
||||
val jsonMapper: Json = Json {
|
||||
prettyPrint = true
|
||||
prettyPrintIndent = " "
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ package dev.adamko.kafkatorio.processor.topology
|
|||
import dev.adamko.kafkatorio.processor.admin.TOPIC_SRC_SERVER_LOG
|
||||
import dev.adamko.kafkatorio.processor.admin.topicName
|
||||
import dev.adamko.kafkatorio.processor.serdes.jsonMapper
|
||||
import dev.adamko.kafkatorio.schema2.KafkatorioPacket2
|
||||
import dev.adamko.kafkatorio.schema.packets.KafkatorioPacket
|
||||
import dev.adamko.kotka.extensions.consumedAs
|
||||
import dev.adamko.kotka.extensions.producedAs
|
||||
import dev.adamko.kotka.extensions.streams.map
|
||||
|
|
@ -19,7 +19,7 @@ import org.apache.kafka.streams.processor.RecordContext
|
|||
|
||||
fun factorioServerPacketStream(
|
||||
builder: StreamsBuilder = StreamsBuilder(),
|
||||
): KStream<FactorioServerId, KafkatorioPacket2> {
|
||||
): KStream<FactorioServerId, KafkatorioPacket> {
|
||||
|
||||
return builder.stream(
|
||||
TOPIC_SRC_SERVER_LOG,
|
||||
|
|
@ -29,14 +29,14 @@ fun factorioServerPacketStream(
|
|||
Serdes.String(),
|
||||
)
|
||||
).map("decode-packets") { serverId: String, value: String ->
|
||||
val packet = jsonMapper.decodeFromString<KafkatorioPacket2>(value)
|
||||
val packet = jsonMapper.decodeFromString<KafkatorioPacket>(value)
|
||||
FactorioServerId(serverId) to packet
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun splitFactorioServerPacketStream(
|
||||
factorioServerPacketStream: KStream<FactorioServerId, KafkatorioPacket2>
|
||||
factorioServerPacketStream: KStream<FactorioServerId, KafkatorioPacket>
|
||||
) {
|
||||
factorioServerPacketStream
|
||||
.to(
|
||||
|
|
@ -45,7 +45,7 @@ fun splitFactorioServerPacketStream(
|
|||
jsonMapper.serde(),
|
||||
jsonMapper.serde(),
|
||||
)
|
||||
) { _: FactorioServerId, value: KafkatorioPacket2, _: RecordContext ->
|
||||
) { _: FactorioServerId, value: KafkatorioPacket, _: RecordContext ->
|
||||
// println("[$key] sending event:${value.eventType} to topic:${value.data.objectName()}")
|
||||
value.data.topicName
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ import dev.adamko.kafkatorio.schema.common.MapTilePosition
|
|||
import dev.adamko.kafkatorio.schema.common.MapTiles
|
||||
import dev.adamko.kafkatorio.schema.common.SurfaceIndex
|
||||
import dev.adamko.kafkatorio.schema.common.toMapChunkPosition
|
||||
import dev.adamko.kafkatorio.schema2.MapChunkUpdate
|
||||
import dev.adamko.kafkatorio.schema2.PrototypesUpdate
|
||||
import dev.adamko.kafkatorio.schema.packets.MapChunkUpdate
|
||||
import dev.adamko.kafkatorio.schema.packets.PrototypesUpdate
|
||||
import dev.adamko.kotka.extensions.groupedAs
|
||||
import dev.adamko.kotka.extensions.materializedWith
|
||||
import dev.adamko.kotka.extensions.producedAs
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ package dev.adamko.kafkatorio.processor.topology
|
|||
|
||||
import dev.adamko.kafkatorio.processor.admin.topicName
|
||||
import dev.adamko.kafkatorio.processor.serdes.jsonMapper
|
||||
import dev.adamko.kafkatorio.schema2.KafkatorioPacket2
|
||||
import dev.adamko.kafkatorio.schema2.KafkatorioPacketData2
|
||||
import dev.adamko.kafkatorio.schema.packets.KafkatorioPacket
|
||||
import dev.adamko.kafkatorio.schema.packets.KafkatorioPacketData
|
||||
import dev.adamko.kotka.extensions.consumedAs
|
||||
import dev.adamko.kotka.extensions.streams.mapValues
|
||||
import dev.adamko.kotka.kxs.serde
|
||||
|
|
@ -11,17 +11,17 @@ import org.apache.kafka.streams.StreamsBuilder
|
|||
import org.apache.kafka.streams.kstream.KStream
|
||||
|
||||
|
||||
inline fun <reified T : KafkatorioPacketData2> StreamsBuilder.streamPacketData(): KStream<FactorioServerId, T> {
|
||||
inline fun <reified T : KafkatorioPacketData> StreamsBuilder.streamPacketData(): KStream<FactorioServerId, T> {
|
||||
|
||||
val simpleName = T::class.simpleName!!
|
||||
val topicName = T::class.topicName
|
||||
|
||||
return stream<FactorioServerId, KafkatorioPacket2>(
|
||||
return stream<FactorioServerId, KafkatorioPacket>(
|
||||
topicName,
|
||||
consumedAs("consume.${simpleName}", jsonMapper.serde(), jsonMapper.serde())
|
||||
).filter { key: FactorioServerId?, value: KafkatorioPacket2? ->
|
||||
).filter { key: FactorioServerId?, value: KafkatorioPacket? ->
|
||||
key != null && value?.data is T
|
||||
}.mapValues("consume.map-values.${simpleName}") { _: FactorioServerId, packet: KafkatorioPacket2 ->
|
||||
}.mapValues("consume.map-values.${simpleName}") { _: FactorioServerId, packet: KafkatorioPacket ->
|
||||
packet.data as T
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ package dev.adamko.kafkatorio.processor.topology
|
|||
import dev.adamko.kafkatorio.processor.WebsocketServer
|
||||
import dev.adamko.kafkatorio.processor.admin.topicName
|
||||
import dev.adamko.kafkatorio.processor.serdes.jsonMapper
|
||||
import dev.adamko.kafkatorio.schema2.KafkatorioPacket2
|
||||
import dev.adamko.kafkatorio.schema2.PlayerUpdate
|
||||
import dev.adamko.kafkatorio.schema.packets.KafkatorioPacket
|
||||
import dev.adamko.kafkatorio.schema.packets.PlayerUpdate
|
||||
import dev.adamko.kotka.extensions.consumedAs
|
||||
import dev.adamko.kotka.kxs.serde
|
||||
import kotlinx.serialization.encodeToString
|
||||
|
|
@ -15,7 +15,7 @@ fun playerUpdatesToWsServer(
|
|||
websocketServer: WebsocketServer,
|
||||
builder: StreamsBuilder = StreamsBuilder(),
|
||||
) {
|
||||
builder.stream<FactorioServerId, KafkatorioPacket2>(
|
||||
builder.stream<FactorioServerId, KafkatorioPacket>(
|
||||
PlayerUpdate::class.topicName,
|
||||
consumedAs("EventUpdate.Player-updates-for-ws-server", jsonMapper.serde(), jsonMapper.serde()),
|
||||
).foreach { _, value ->
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ import dev.adamko.kafkatorio.processor.serdes.kxsBinary
|
|||
import dev.adamko.kafkatorio.schema.common.ColourHex
|
||||
import dev.adamko.kafkatorio.schema.common.MapTile
|
||||
import dev.adamko.kafkatorio.schema.common.toHex
|
||||
import dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2
|
||||
import dev.adamko.kafkatorio.schema2.PrototypesUpdate
|
||||
import dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype
|
||||
import dev.adamko.kafkatorio.schema.packets.PrototypesUpdate
|
||||
import dev.adamko.kotka.extensions.materializedAs
|
||||
import dev.adamko.kotka.extensions.streams.filter
|
||||
import dev.adamko.kotka.extensions.streams.mapValues
|
||||
|
|
@ -21,7 +21,7 @@ import org.apache.kafka.streams.kstream.KTable
|
|||
@Serializable
|
||||
value class TileProtoHashCode private constructor(val code: Int) {
|
||||
constructor(tile: MapTile) : this(tile.proto.hashCode())
|
||||
constructor(tile: FactorioPrototype2.MapTile) : this(tile.name.hashCode())
|
||||
constructor(tile: FactorioPrototype.MapTile) : this(tile.name.hashCode())
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ fun tileProtoColourDictionary(
|
|||
return factorioServerPacketStream.mapValues("server-map-data.tile-prototypes.map-values") { _, protoPacket: PrototypesUpdate ->
|
||||
val map = protoPacket
|
||||
.prototypes
|
||||
.filterIsInstance<FactorioPrototype2.MapTile>()
|
||||
.filterIsInstance<FactorioPrototype.MapTile>()
|
||||
.associate { TileProtoHashCode(it) to it.mapColour.toHex() }
|
||||
|
||||
TileColourDict(map)
|
||||
|
|
|
|||
|
|
@ -12,11 +12,11 @@ import dev.adamko.kafkatorio.schema.common.MapTilePosition
|
|||
import dev.adamko.kafkatorio.schema.common.PrototypeName
|
||||
import dev.adamko.kafkatorio.schema.common.SurfaceIndex
|
||||
import dev.adamko.kafkatorio.schema.common.Tick
|
||||
import dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2
|
||||
import dev.adamko.kafkatorio.schema2.KafkatorioPacket2
|
||||
import dev.adamko.kafkatorio.schema2.MapChunkUpdate
|
||||
import dev.adamko.kafkatorio.schema2.MapChunkUpdateKey
|
||||
import dev.adamko.kafkatorio.schema2.PrototypesUpdate
|
||||
import dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype
|
||||
import dev.adamko.kafkatorio.schema.packets.KafkatorioPacket
|
||||
import dev.adamko.kafkatorio.schema.packets.MapChunkUpdate
|
||||
import dev.adamko.kafkatorio.schema.packets.MapChunkUpdateKey
|
||||
import dev.adamko.kafkatorio.schema.packets.PrototypesUpdate
|
||||
import dev.adamko.kotka.kxs.serde
|
||||
import io.kotest.assertions.withClue
|
||||
import io.kotest.core.spec.style.FunSpec
|
||||
|
|
@ -42,23 +42,23 @@ class GroupMapChunksTest : FunSpec({
|
|||
|
||||
val testDriver = TopologyTestDriver(topology)
|
||||
|
||||
val prototypesTestInputTopic: TestInputTopic<FactorioServerId, KafkatorioPacket2> =
|
||||
val prototypesTestInputTopic: TestInputTopic<FactorioServerId, KafkatorioPacket> =
|
||||
testDriver.createInputTopic(
|
||||
prototypesTopicName,
|
||||
jsonMapper.serde<FactorioServerId>().serializer(),
|
||||
jsonMapper.serde<KafkatorioPacket2>().serializer(),
|
||||
jsonMapper.serde<KafkatorioPacket>().serializer(),
|
||||
)
|
||||
|
||||
val serverId = FactorioServerId("test-server-id")
|
||||
|
||||
prototypesTestInputTopic.pipeInput(
|
||||
serverId,
|
||||
KafkatorioPacket2(
|
||||
KafkatorioPacket(
|
||||
modVersion = "1.2.3",
|
||||
tick = Tick(22u),
|
||||
PrototypesUpdate(
|
||||
listOf(
|
||||
FactorioPrototype2.MapTile(
|
||||
FactorioPrototype.MapTile(
|
||||
PrototypeName("fake-proto"),
|
||||
layer = 1u,
|
||||
mapColour = Colour(0.3f, 0.2f, 0.1f, 1.0f),
|
||||
|
|
@ -71,16 +71,16 @@ class GroupMapChunksTest : FunSpec({
|
|||
)
|
||||
)
|
||||
|
||||
val mapChunkUpdatesInputTopic: TestInputTopic<FactorioServerId, KafkatorioPacket2> =
|
||||
val mapChunkUpdatesInputTopic: TestInputTopic<FactorioServerId, KafkatorioPacket> =
|
||||
testDriver.createInputTopic(
|
||||
mapChunkUpdatesTopicName,
|
||||
jsonMapper.serde<FactorioServerId>().serializer(),
|
||||
jsonMapper.serde<KafkatorioPacket2>().serializer(),
|
||||
jsonMapper.serde<KafkatorioPacket>().serializer(),
|
||||
)
|
||||
|
||||
mapChunkUpdatesInputTopic.pipeInput(
|
||||
serverId,
|
||||
KafkatorioPacket2(
|
||||
KafkatorioPacket(
|
||||
modVersion = "1.2.3",
|
||||
tick = Tick(44u),
|
||||
MapChunkUpdate(
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package dev.adamko.kafkatorio.webmap
|
||||
|
||||
import dev.adamko.kafkatorio.schema.common.MapEntityPosition
|
||||
import dev.adamko.kafkatorio.schema2.PlayerUpdate
|
||||
import dev.adamko.kafkatorio.schema.packets.PlayerUpdate
|
||||
import io.kvision.maps.Maps
|
||||
import io.kvision.maps.externals.leaflet.geo.LatLng
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import dev.adamko.kafkatorio.schema.common.PlayerIndex
|
|||
import dev.adamko.kafkatorio.schema.common.SurfaceIndex
|
||||
import dev.adamko.kafkatorio.schema.common.Tick
|
||||
import dev.adamko.kafkatorio.schema.common.toHexString
|
||||
import dev.adamko.kafkatorio.schema2.PlayerUpdate
|
||||
import dev.adamko.kafkatorio.schema.packets.PlayerUpdate
|
||||
import io.kvision.maps.Maps
|
||||
import io.kvision.maps.Maps.Companion.L
|
||||
import io.kvision.maps.externals.leaflet.geo.LatLng
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
package dev.adamko.kafkatorio.webmap
|
||||
|
||||
import dev.adamko.kafkatorio.schema2.ConfigurationUpdate
|
||||
import dev.adamko.kafkatorio.schema2.ConsoleChatUpdate
|
||||
import dev.adamko.kafkatorio.schema2.ConsoleCommandUpdate
|
||||
import dev.adamko.kafkatorio.schema2.EntityUpdate
|
||||
import dev.adamko.kafkatorio.schema2.KafkatorioPacket2
|
||||
import dev.adamko.kafkatorio.schema2.MapChunkUpdate
|
||||
import dev.adamko.kafkatorio.schema2.PlayerUpdate
|
||||
import dev.adamko.kafkatorio.schema2.PrototypesUpdate
|
||||
import dev.adamko.kafkatorio.schema2.SurfaceUpdate
|
||||
import dev.adamko.kafkatorio.schema.packets.ConfigurationUpdate
|
||||
import dev.adamko.kafkatorio.schema.packets.ConsoleChatUpdate
|
||||
import dev.adamko.kafkatorio.schema.packets.ConsoleCommandUpdate
|
||||
import dev.adamko.kafkatorio.schema.packets.EntityUpdate
|
||||
import dev.adamko.kafkatorio.schema.packets.KafkatorioPacket
|
||||
import dev.adamko.kafkatorio.schema.packets.MapChunkUpdate
|
||||
import dev.adamko.kafkatorio.schema.packets.PlayerUpdate
|
||||
import dev.adamko.kafkatorio.schema.packets.PrototypesUpdate
|
||||
import dev.adamko.kafkatorio.schema.packets.SurfaceUpdate
|
||||
import io.kvision.redux.ReduxStore
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import org.w3c.dom.MessageEvent
|
||||
|
|
@ -36,7 +36,7 @@ class WebsocketService(
|
|||
|
||||
println(data.replace('\n', ' '))
|
||||
|
||||
val packet: KafkatorioPacket2 = jsonMapper.decodeFromString(data)
|
||||
val packet: KafkatorioPacket = jsonMapper.decodeFromString(data)
|
||||
|
||||
when (val packetData = packet.data) {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue