mod build improvements, add a separate model def
This commit is contained in:
parent
34c87ea5b8
commit
1c9f415d01
3 changed files with 25 additions and 23 deletions
|
|
@ -8,16 +8,10 @@
|
||||||
// thingType: Object.values(defines.events)
|
// thingType: Object.values(defines.events)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
import {JsonTable, Serdes} from "./serdes/serdes"
|
import {Serdes} from "./serdes/serdes"
|
||||||
|
import {FactorioEvent, JsonTable} from "./model/model";
|
||||||
|
|
||||||
|
|
||||||
interface FactorioEvent extends JsonTable {
|
|
||||||
tick: uint
|
|
||||||
object_name: string,
|
|
||||||
event_type: string,
|
|
||||||
data: JsonTable,
|
|
||||||
}
|
|
||||||
|
|
||||||
const FactorioEvent = ((tick: uint, objectName: string, eventType: string, data: JsonTable) => {
|
const FactorioEvent = ((tick: uint, objectName: string, eventType: string, data: JsonTable) => {
|
||||||
return {
|
return {
|
||||||
tick: tick,
|
tick: tick,
|
||||||
|
|
|
||||||
21
modules/mod/src/main/typescript/model/model.ts
Normal file
21
modules/mod/src/main/typescript/model/model.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
export type JsonPrimitiveType = number | string | boolean | undefined | null | void
|
||||||
|
|
||||||
|
export type JsonArray<T extends JsonPrimitiveType = void> = T[]
|
||||||
|
|
||||||
|
export type JsonTableValueType =
|
||||||
|
JsonPrimitiveType
|
||||||
|
| JsonTable
|
||||||
|
| JsonArray<JsonPrimitiveType>
|
||||||
|
| undefined
|
||||||
|
| null
|
||||||
|
|
||||||
|
export interface JsonTable {
|
||||||
|
[key: string]: JsonTableValueType
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FactorioEvent extends JsonTable {
|
||||||
|
tick: uint
|
||||||
|
object_name: string,
|
||||||
|
event_type: string,
|
||||||
|
data: JsonTable,
|
||||||
|
}
|
||||||
|
|
@ -1,18 +1,3 @@
|
||||||
export type JsonPrimitiveType = number | string | boolean | undefined | null | void
|
|
||||||
|
|
||||||
export type JsonArray<T extends JsonPrimitiveType = void> = T[]
|
|
||||||
|
|
||||||
export type JsonTableValueType =
|
|
||||||
JsonPrimitiveType
|
|
||||||
| JsonTable
|
|
||||||
| JsonArray<JsonPrimitiveType>
|
|
||||||
| undefined
|
|
||||||
| null
|
|
||||||
|
|
||||||
export interface JsonTable {
|
|
||||||
[key: string]: JsonTableValueType
|
|
||||||
}
|
|
||||||
|
|
||||||
// export type JsonArray<TValue extends JsonPrimitiveType> = TValue[]
|
// export type JsonArray<TValue extends JsonPrimitiveType> = TValue[]
|
||||||
// export class JsonArray extends Array<JsonPrimitiveTypes> {
|
// export class JsonArray extends Array<JsonPrimitiveTypes> {
|
||||||
// }
|
// }
|
||||||
|
|
@ -29,6 +14,8 @@ export interface JsonTable {
|
||||||
// declare const JsonTable: JsonTableConstructor
|
// declare const JsonTable: JsonTableConstructor
|
||||||
|
|
||||||
|
|
||||||
|
import {JsonTable, JsonArray} from "../model/model";
|
||||||
|
|
||||||
export namespace Serdes {
|
export namespace Serdes {
|
||||||
|
|
||||||
export namespace Player {
|
export namespace Player {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue