UNPKG

sc4

Version:

A command line utility for automating SimCity 4 modding tasks & modifying savegames

84 lines (83 loc) 2.75 kB
import Stream from './stream.js'; import LotObject from './lot-object.js'; import { kFileType } from './symbols.js'; import type { TGIArray, TGILike } from 'sc4/types'; import { type Value, type Key, type PropertyValueType } from './exemplar-properties-types.js'; import TGI from './tgi.js'; type ExemplarId = 'EQZB1###' | 'EQZT1###' | 'CQZB1###' | 'CQZT###'; export type ExemplarLike = { get<K extends Key = Key>(key: K): Value<K> | undefined; }; export type ExemplarOptions = { id?: ExemplarId; parent?: TGILike; properties?: Property[] | PropertyOptions[]; }; export type PropertyOptions<K extends Key = Key> = { id: number; type?: PropertyValueType; value: Value<K>; comment?: string; }; type AddPropertyOptions<K extends Key = Key> = { id: K; value: Value<K>; type?: PropertyValueType; }; type ExemplarJSON = { parent: TGIArray; properties: ExemplarPropertyJSON[]; }; type ExemplarPropertyJSON = { id: number; name?: string; value: any; }; declare abstract class BaseExemplar { #private; id: ExemplarId; parent: TGI; properties: Property[]; constructor(data?: ExemplarOptions | Uint8Array); clone(): BaseExemplar; get fileType(): 1697917002; [Symbol.iterator](): Generator<Property<Key>, void, unknown>; get lotObjects(): LotObject[]; set lotObjects(lotObjects: LotObject[]); prop<K extends Key>(key: K): Property<K> | undefined; value<K extends Key>(key: K): Value<K> | undefined; get<K extends Key>(key: K): Value<K> | undefined; set<K extends Key>(key: K, value: Value<K>): this; addProperty<K extends Key>(idOrName: K, value: Value<K>, typeHint?: PropertyValueType): Property<K>; addProperty<K extends Key>(propOptions: AddPropertyOptions<K>): Property<K>; parse(bufferOrStream: Stream | Uint8Array): this; parseFromString(str: string): this; createTable(): this; toBuffer(): Uint8Array<ArrayBufferLike>; toJSON(): ExemplarJSON; } export declare class Exemplar extends BaseExemplar { static [kFileType]: 1697917002; id: ExemplarId; } export declare class Cohort extends BaseExemplar { static [kFileType]: 87304289; id: ExemplarId; } declare class Property<K extends Key = Key> { id: number; type: PropertyValueType; value: Value<K> | undefined; constructor(data?: PropertyOptions<K> | Property<K>); getSafeValue(): Value<K> | undefined; get name(): string; [Symbol.toPrimitive](hint: string): string | Value<K> | undefined; get hex(): string; get hexType(): number; get keyType(): 0 | 128; get multiple(): boolean; get byteLength(): number; parse(rs: Stream): this; toBuffer(): Uint8Array<ArrayBufferLike>; } export {};