chunk pngs almost working...

- rm yarn lock, it should be in ./gradle/kotlin-js-store
 - move kafka extensions to another project, kotka-streams
 - move prototypes to their own package
 - create a Factorio command for emitting prototypes
 - add bounding box to chunk updates
 - bump typed-factorio version
 - fix MapEntityPosition -> MapChunkPosition x/y rounding
 - lots of work on the Kafka Streams topology
This commit is contained in:
Adam 2022-01-16 23:16:09 +01:00
parent 49ad3654a3
commit 8533be0af8
47 changed files with 1097 additions and 4179 deletions

View file

@ -1,5 +1,6 @@
import {handleConfigurationUpdate} from "./main/config-update/handleConfigurationUpdate";
require("./main/events/registerHandlers")
require("./main/commands/kafkatorioCommands")
script.on_configuration_changed(handleConfigurationUpdate)

View file

@ -16,5 +16,4 @@ interface FactorioConfigurationUpdate extends KafkatorioPacket {
factorioData: FactorioGameDataUpdate;
modVersion: string;
packetType: PacketType;
prototypes: FactorioPrototype[];
}

View file

@ -50,6 +50,7 @@ interface MapTiles extends FactorioObjectData {
}
interface MapChunk extends FactorioObjectData {
area: MapBoundingBox;
objectName: ObjectName;
position: MapChunkPosition;
tiles: MapTiles;

View file

@ -6,6 +6,12 @@ interface FactorioPrototype {
prototypeObjectName: PrototypeObjectName;
}
interface FactorioPrototypes extends KafkatorioPacket {
modVersion: string;
packetType: PacketType;
prototypes: FactorioPrototype[];
}
interface MapTilePrototype extends FactorioPrototype {
canBeMined: boolean;
collisionMasks: string[];

View file

@ -1,6 +1,6 @@
// Generated by TypeScriptGenerator - do not edit this file manually
type PacketType = "EVENT" | "CONFIG";
type PacketType = "EVENT" | "CONFIG" | "PROTOTYPES";
interface KafkatorioPacket {
modVersion: string;
@ -27,12 +27,17 @@ interface MapEntityPosition {
y: double;
}
interface MapChunkPosition {
x: int;
y: int;
}
interface MapTilePosition {
x: int;
y: int;
}
interface MapBoundingBox {
bottomRight: MapTilePosition;
topLeft: MapTilePosition;
}
interface MapChunkPosition {
x: int;
y: int;
}

View file

@ -0,0 +1,12 @@
import {emitPrototypes} from "../config-update/prototypes";
commands.add_command(
"kafkatorio",
"kafkatorio innit bruv",
(e: CustomCommandData) => {
if (e.parameter == undefined) {
// do nothing
} else if ("PROTOTYPES" == e.parameter.toUpperCase()) {
emitPrototypes()
}
})

View file

@ -1,6 +1,6 @@
import {emitPacket} from "../emitKafkatorioPacket";
import {convertPrototypes} from "./convertPrototypes";
import {updateGlobal} from "./updateGlobal";
import {emitPrototypes} from "./prototypes";
export function handleConfigurationUpdate(changeData: ConfigurationChangedData) {
updateGlobal()
@ -9,10 +9,10 @@ export function handleConfigurationUpdate(changeData: ConfigurationChangedData)
modVersion: global.MOD_VERSION,
packetType: "CONFIG",
allMods: allMods(changeData),
factorioData: factorioData(changeData),
prototypes: convertPrototypes()
factorioData: factorioData(changeData)
})
emitPrototypes()
}
function factorioData(changeData: ConfigurationChangedData): FactorioGameDataUpdate {

View file

@ -1,6 +1,15 @@
import {Converters} from "../events/converters";
import {emitPacket} from "../emitKafkatorioPacket";
export function convertPrototypes(): FactorioPrototype[] {
export function emitPrototypes() {
emitPacket<FactorioPrototypes>({
modVersion: global.MOD_VERSION,
packetType: "PROTOTYPES",
prototypes: prototypes()
})
}
function prototypes(): FactorioPrototype[] {
let prototypes: FactorioPrototype[] = []
prototypes.push(...getMapTilePrototypes())

View file

@ -114,4 +114,11 @@ export namespace Converters {
// }
// }
export function convertBoundingBox(bb: BoundingBoxTable): MapBoundingBox {
return {
topLeft: mapTilePosition(bb.left_top as PositionTable),
bottomRight: mapTilePosition(bb.right_bottom as PositionTable),
}
}
}

View file

@ -1,6 +1,6 @@
import {Converters} from "./converters"
import {emitEvent} from "./emitEvent";
import mapChunkPosition = Converters.mapChunkPosition;
export function handlePlayerUpdate(tick: uint, eventType: string, playerIndex: uint) {
let player: LuaPlayer = game.players[playerIndex]
@ -80,7 +80,8 @@ export function handleChunkUpdate(
let mapChunk: MapChunk = {
objectName: "MapChunk",
tiles: createMapTiles(surfaceIndex, convertedTiles),
position: mapChunkPosition(position)
position: Converters.mapChunkPosition(position),
area: Converters.convertBoundingBox(area)
}
emitEvent(mapChunk, tick, eventType)

View file

@ -1,6 +1,6 @@
{
"name": "kafkatorio-events-mod",
"version": "0.2.2",
"version": "0.2.4",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -74,9 +74,9 @@
"integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ=="
},
"typed-factorio": {
"version": "0.15.0",
"resolved": "https://registry.npmjs.org/typed-factorio/-/typed-factorio-0.15.0.tgz",
"integrity": "sha512-hEpW+nRL3q5vg3aOxbNbYpwARxYzMTncihurAucwnpQ/IDc4w4PrO2/OWHI5R+PkZSEQUY5LSRxG7qrGqDeWHQ=="
"version": "0.16.0",
"resolved": "https://registry.npmjs.org/typed-factorio/-/typed-factorio-0.16.0.tgz",
"integrity": "sha512-I6W1lhRkeE+mHzLBKBVIDZdquwBjBYaS7jkV0CKiWWkA9ptGqT+MblOkNUdYZ0ykR2Rvn1eF/6pzh8WwQ+mYVQ=="
},
"typescript": {
"version": "4.5.4",

View file

@ -1,6 +1,6 @@
{
"name": "kafkatorio-events-mod",
"version": "0.2.2",
"version": "0.2.4",
"private": true,
"scripts": {
"build": "tstl",
@ -14,7 +14,7 @@
"lua-types": "^2.11.0",
"@types/node": "^12.0.8",
"typescript-to-lua": "1.3.0",
"typed-factorio": "0.15.0",
"typed-factorio": "0.16.0",
"typescript": "4.5.4"
},
"license": "UNLICENSED",