1/*****************************************************************************
2 * Copyright (c) 2014-2021 OpenRCT2 developers
3 *
4 * For a complete list of all authors, please refer to contributors.md
5 * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
6 *
7 * OpenRCT2 is licensed under the GNU General Public License version 3.
8 *****************************************************************************/
9
10// OpenRCT2 Scripting API definition file
11
12// To enable IntelliSense for your scripts in Visual Studio or Visual Studio Code,
13// add the following line to the top of your script and change the path appropriately.
14//
15//   /// <reference path="/path/to/openrct2.d.ts" />
16//
17
18export type PluginType = "local" | "remote";
19
20declare global {
21    /**
22     * Global context for accessing all other APIs.
23     */
24    /** APIs for cheats. */
25    var cheats: Cheats;
26    /** APIs for interacting with the stdout console. */
27    var console: Console;
28    /** Core APIs for plugins. */
29    var context: Context;
30    /** APIs for getting or setting the in-game date. */
31    var date: GameDate;
32    /** APIs for manipulating the map. */
33    var map: GameMap;
34    /** APIs for managing the server or interacting with the server or clients. */
35    var network: Network;
36    /** APIs for the park and management of it. */
37    var park: Park;
38    /** APIs for the current scenario. */
39    var scenario: Scenario;
40    /** APIs for the climate and weather. */
41    var climate: Climate;
42    /**
43     * APIs for creating and editing title sequences.
44     * These will only be available to clients that are not running headless mode.
45     */
46    var titleSequenceManager: TitleSequenceManager;
47    /**
48     * APIs for controlling the user interface.
49     * These will only be available to servers and clients that are not running headless mode.
50     * Plugin writers should check if ui is available using `typeof ui !== 'undefined'`.
51     */
52    var ui: Ui;
53
54    /**
55     * Registers the plugin. This may only be called once.
56     * @param metadata Information about the plugin and the entry point.
57     */
58    function registerPlugin(metadata: PluginMetadata): void;
59
60    /**
61     * Represents a JavaScript object that can or should be disposed when no longer needed.
62     */
63    interface IDisposable {
64        dispose(): void;
65    }
66
67    /**
68     * A coordinate within the game's client screen in pixels.
69     */
70    interface ScreenCoordsXY {
71        x: number;
72        y: number;
73    }
74
75    /**
76     * Represents the width and height in pixels.
77     */
78    interface ScreenSize {
79        width: number;
80        height: number;
81    }
82
83    /**
84     * A coordinate within the game.
85     * Each in-game tile is a size of 32x32.
86     */
87    interface CoordsXY {
88        x: number;
89        y: number;
90    }
91
92    /**
93     * A coordinate within the game.
94     * Each in-game tile is a size of 32x32.
95     * The z-coordinate raises 16 per land increment. A full-height wall is 32 in height.
96     */
97    interface CoordsXYZ extends CoordsXY {
98        z: number;
99    }
100
101    /**
102     * A coordinate within the game.
103     * Each in-game tile is a size of 32x32.
104     * The z-coordinate raises 16 per land increment. A full-height wall is 32 in height.
105     * The direction is between 0 and 3.
106     */
107    interface CoordsXYZD extends CoordsXYZ {
108        direction: number;
109    }
110
111    /**
112     * A rectangular area specified using two coordinates.
113     */
114    interface MapRange {
115        leftTop: CoordsXY;
116        rightBottom: CoordsXY;
117    }
118
119    /**
120     * Represents lateral and vertical g-forces.
121     */
122    interface GForces {
123        lateralG: number;
124        verticalG: number;
125    }
126
127    /**
128     * Represents information about the plugin such as type, name, author and version.
129     * It also includes the entry point.
130     */
131    interface PluginMetadata {
132        name: string;
133        version: string;
134        authors: string | string[];
135        type: PluginType;
136        licence: string;
137        minApiVersion?: number;
138        targetApiVersion?: number;
139        main: () => void;
140    }
141
142    /**
143     * Console APIs
144     * Currently interact with stdout.
145     */
146    interface Console {
147        clear(): void;
148        log(message?: any, ...optionalParams: any[]): void;
149
150        /**
151         * Executes a command using the legacy console REPL. This should not be used
152         * by plugins, and exists only for servers to continue using old commands until
153         * all functionality can be accomplished with this scripting API.
154         *
155         * @deprecated
156         * @param command The command and arguments to execute.
157         */
158        executeLegacy(command: string): void;
159    }
160
161    /**
162     * Core APIs for storage and subscriptions.
163     */
164    interface Context {
165        /**
166         * Gets the current version of the plugin api. This is an integer that increments
167         * by 1 every time a change to the plugin api is made.
168         */
169        readonly apiVersion: number;
170
171        /**
172         * The user's current configuration.
173         */
174        configuration: Configuration;
175
176        /**
177         * Shared generic storage for all plugins. Data is persistent across instances
178         * of OpenRCT2 and is stored externally as a single JSON file in the OpenRCT2
179         * user directory. Internally it is a JavaScript object. Objects and arrays
180         * are only copied by reference. The external file is only written when using
181         * the `set` method, do not rely on the file being saved by modifying your own
182         * objects. Functions and other internal structures will not be persisted.
183         */
184        sharedStorage: Configuration;
185
186        /**
187         * Render the current state of the map and save to disc.
188         * Useful for server administration and timelapse creation.
189         * @param options Options that control the capture and output file.
190         */
191        captureImage(options: CaptureOptions): void;
192
193        /**
194         * Gets the loaded object at the given index.
195         * @param type The object type.
196         * @param index The index.
197         */
198        getObject(type: ObjectType, index: number): LoadedObject;
199        getObject(type: "ride", index: number): RideObject;
200        getObject(type: "small_scenery", index: number): SmallSceneryObject;
201
202        getAllObjects(type: ObjectType): LoadedObject[];
203        getAllObjects(type: "ride"): RideObject[];
204
205        /**
206         * Gets a random integer within the specified range using the game's pseudo-
207         * random number generator. This is part of the game state and shared across
208         * all clients, you therefore must be in a context that can mutate the game
209         * state. Use this to generate random numbers instead of Math.Random during
210         * game logic routines such as hooks and game actions.
211         * @param min The minimum value inclusive.
212         * @param max The maximum value exclusive.
213         */
214        getRandom(min: number, max: number): number;
215
216        /**
217         * Formats a new string using the given format string and the arguments.
218         * @param fmt The format string, e.g. "Guests: {COMMA16}"
219         * @param args The arguments to insert into the string.
220         */
221        formatString(fmt: string, ...args: any[]): string;
222
223        /**
224         * Registers a new game action that allows clients to interact with the game.
225         * @param action The unique name of the action.
226         * @param query Logic for validating and returning a price for an action.
227         * @param execute Logic for validating and executing the action.
228         * @throws An error if the action has already been registered by this or another plugin.
229         */
230        registerAction(
231            action: string,
232            query: (args: object) => GameActionResult,
233            execute: (args: object) => GameActionResult): void;
234
235        /**
236         * Query the result of running a game action. This allows you to check the outcome and validity of
237         * an action without actually executing it.
238         * @param action The name of the action.
239         * @param args The action parameters.
240         * @param callback The function to be called with the result of the action.
241         */
242        queryAction(action: ActionType, args: object, callback: (result: GameActionResult) => void): void;
243        queryAction(action: string, args: object, callback: (result: GameActionResult) => void): void;
244
245        /**
246         * Executes a game action. In a network game, this will send a request to the server and wait
247         * for the server to reply.
248         * @param action The name of the action.
249         * @param args The action parameters.
250         * @param callback The function to be called with the result of the action.
251         */
252        executeAction(action: ActionType, args: object, callback: (result: GameActionResult) => void): void;
253        executeAction(action: string, args: object, callback: (result: GameActionResult) => void): void;
254
255        /**
256         * Subscribes to the given hook.
257         */
258        subscribe(hook: HookType, callback: Function): IDisposable;
259
260        subscribe(hook: "action.query", callback: (e: GameActionEventArgs) => void): IDisposable;
261        subscribe(hook: "action.execute", callback: (e: GameActionEventArgs) => void): IDisposable;
262        subscribe(hook: "interval.tick", callback: () => void): IDisposable;
263        subscribe(hook: "interval.day", callback: () => void): IDisposable;
264        subscribe(hook: "network.chat", callback: (e: NetworkChatEventArgs) => void): IDisposable;
265        subscribe(hook: "network.authenticate", callback: (e: NetworkAuthenticateEventArgs) => void): IDisposable;
266        subscribe(hook: "network.join", callback: (e: NetworkEventArgs) => void): IDisposable;
267        subscribe(hook: "network.leave", callback: (e: NetworkEventArgs) => void): IDisposable;
268        subscribe(hook: "ride.ratings.calculate", callback: (e: RideRatingsCalculateArgs) => void): IDisposable;
269        subscribe(hook: "action.location", callback: (e: ActionLocationArgs) => void): IDisposable;
270        subscribe(hook: "guest.generation", callback: (id: number) => void): IDisposable;
271        subscribe(hook: "vehicle.crash", callback: (e: VehicleCrashArgs) => void): IDisposable;
272
273        /**
274         * Registers a function to be called every so often in realtime, specified by the given delay.
275         * @param callback The function to call every time the delay has elapsed.
276         * @param delay The number of milliseconds to wait between each call to the given function.
277         */
278        setInterval(callback: Function, delay: number): number;
279
280        /**
281         * Like `setInterval`, except the callback will only execute once after the given delay.
282         * @param callback The function to call after the given delay has elapsed.
283         * @param delay The number of milliseconds to wait for before calling the given function.
284         */
285        setTimeout(callback: Function, delay: number): number;
286
287        /**
288         * Removes the registered interval specified by the numeric handle. The handles
289         * are shared with `setTimeout`.
290         * @param handle
291         */
292        clearInterval(handle: number): void;
293
294        /**
295         * Removes the registered timeout specified by the numeric handle. The handles
296         * are shared with `setInterval`.
297         * @param handle The numerical handle of the registered timeout to remove.
298         */
299        clearTimeout(handle: number): void;
300    }
301
302    interface Configuration {
303        getAll(namespace: string): { [name: string]: any };
304        get<T>(key: string): T | undefined;
305        get<T>(key: string, defaultValue: T): T;
306        set<T>(key: string, value: T): void;
307        has(key: string): boolean;
308    }
309
310    interface CaptureOptions {
311        /**
312         * A relative filename from the screenshot directory to save the capture as.
313         * By default, the filename will be automatically generated using the system date and time.
314         */
315        filename?: string;
316
317        /**
318         * Width of the capture in pixels.
319         * Do not set if you would like a giant screenshot.
320         */
321        width?: number;
322
323        /**
324         * Height of the capture in pixels.
325         * Do not set if you would like a giant screenshot.
326         */
327        height?: number;
328
329        /**
330         * Map position to centre the view on in map units.
331         * Do not set if you would like a giant screenshot.
332         */
333        position?: CoordsXY;
334
335        /**
336         * The zoom level, 0 is 1:1, 1 is 2:1, 2 is 4:1 etc.
337         */
338        zoom: number;
339
340        /**
341         * Rotation of the camera from 0 to 3.
342         */
343        rotation: number;
344
345        /**
346         * Whether to enable transparency in the screenshot.
347         */
348        transparent?: boolean;
349    }
350
351    type ObjectType =
352        "ride" |
353        "small_scenery" |
354        "large_scenery" |
355        "wall" |
356        "banner" |
357        "footpath" |
358        "footpath_addition" |
359        "scenery_group" |
360        "park_entrance" |
361        "water" |
362        "terrain_surface" |
363        "terrain_edge" |
364        "station" |
365        "music";
366
367    type HookType =
368        "interval.tick" | "interval.day" |
369        "network.chat" | "network.action" | "network.join" | "network.leave" |
370        "ride.ratings.calculate" | "action.location" | "vehicle.crash";
371
372    type ExpenditureType =
373        "ride_construction" |
374        "ride_runningcosts" |
375        "land_purchase" |
376        "landscaping" |
377        "park_entrance_tickets" |
378        "park_ride_tickets" |
379        "shop_sales" |
380        "shop_stock" |
381        "food_drink_sales" |
382        "food_drink_stock" |
383        "wages" |
384        "marketing" |
385        "research" |
386        "interest";
387
388    type ActionType =
389        "balloonpress" |
390        "bannerplace" |
391        "bannerremove" |
392        "bannersetcolour" |
393        "bannersetname" |
394        "bannersetstyle" |
395        "clearscenery" |
396        "climateset" |
397        "footpathplace" |
398        "footpathplacefromtrack" |
399        "footpathremove" |
400        "footpathadditionplace" |
401        "footpathadditionremove" |
402        "guestsetflags" |
403        "guestsetname" |
404        "landbuyrights" |
405        "landlower" |
406        "landraise" |
407        "landsetheight" |
408        "landsetrights" |
409        "landsmoothaction" |
410        "largesceneryplace" |
411        "largesceneryremove" |
412        "largescenerysetcolour" |
413        "loadorquit" |
414        "mazeplacetrack" |
415        "mazesettrack" |
416        "networkmodifygroup" |
417        "parkentranceremove" |
418        "parkmarketing" |
419        "parksetdate" |
420        "parksetloan" |
421        "parksetname" |
422        "parksetparameter" |
423        "parksetresearchfunding" |
424        "pausetoggle" |
425        "peeppickup" |
426        "placeparkentrance" |
427        "placepeepspawn" |
428        "playerkick" |
429        "playersetgroup" |
430        "ridecreate" |
431        "ridedemolish" |
432        "rideentranceexitplace" |
433        "rideentranceexitremove" |
434        "ridesetappearance" |
435        "ridesetcolourscheme" |
436        "ridesetname" |
437        "ridesetprice" |
438        "ridesetsetting" |
439        "ridesetstatus" |
440        "ridesetvehicles" |
441        "scenariosetsetting" |
442        "setcheataction" |
443        "setparkentrancefee" |
444        "signsetname" |
445        "smallsceneryplace" |
446        "smallsceneryremove" |
447        "stafffire" |
448        "staffhire" |
449        "staffsetcolour" |
450        "staffsetcostume" |
451        "staffsetname" |
452        "staffsetorders" |
453        "staffsetpatrolarea" |
454        "surfacesetstyle" |
455        "tilemodify" |
456        "trackdesign" |
457        "trackplace" |
458        "trackremove" |
459        "tracksetbrakespeed" |
460        "wallplace" |
461        "wallremove" |
462        "wallsetcolour" |
463        "waterlower" |
464        "waterraise" |
465        "watersetheight";
466
467    interface GameActionEventArgs {
468        readonly player: number;
469        readonly type: number;
470        readonly action: string;
471        readonly isClientOnly: boolean;
472        readonly args: object;
473        result: GameActionResult;
474    }
475
476    interface GameActionResult {
477        error?: number;
478        errorTitle?: string;
479        errorMessage?: string;
480        position?: CoordsXYZ;
481        cost?: number;
482        expenditureType?: ExpenditureType;
483    }
484
485    interface RideCreateGameActionResult extends GameActionResult {
486        readonly ride: number;
487    }
488
489    interface NetworkEventArgs {
490        readonly player: number;
491    }
492
493    interface NetworkChatEventArgs extends NetworkEventArgs {
494        message: string;
495    }
496
497    interface NetworkAuthenticateEventArgs {
498        readonly name: number;
499        readonly ipAddress: string;
500        readonly publicKeyHash: string;
501        cancel: boolean;
502    }
503
504    interface RideRatingsCalculateArgs {
505        readonly rideId: number;
506        excitement: number;
507        intensity: number;
508        nausea: number;
509    }
510
511    interface ActionLocationArgs {
512        readonly x: number;
513        readonly y: number;
514        readonly player: number;
515        readonly type: number;
516        readonly isClientOnly: boolean;
517        result: boolean;
518    }
519
520    type VehicleCrashIntoType = "another_vehicle" | "land" | "water";
521
522    interface VehicleCrashArgs {
523        readonly id: number;
524        readonly crashIntoType: VehicleCrashIntoType;
525    }
526
527    /**
528     * APIs for the in-game date.
529     */
530    interface GameDate {
531        /**
532         * The total number of ticks that have elapsed since the beginning of the game / scenario. This
533         * should never reset.
534         */
535        readonly ticksElapsed: number;
536        /**
537         * The total number of months that have elapsed. This will equate to 0 in March, Year 1 and
538         * increase by 1 every month, i.e. by 8 every year.
539         * Note: this represents the current date and may be reset by cheats or scripts.
540         */
541        monthsElapsed: number;
542        /**
543         * The total number of years that have elapsed. This always equates to (monthsElapsed / 8).
544         */
545        readonly yearsElapsed: number;
546
547        /**
548         * How far through the month we are between 0 and 65536. This is incremented by 4 each tick, so
549         * every month takes ~6.8 minutes to complete making a year take just under an hour.
550         */
551        monthProgress: number;
552
553        /** The day of the month from 1 to 31. */
554        readonly day: number;
555        /** The current month of the year from 0 to 7, where 0 is March and 7 is October. */
556        readonly month: number;
557        /** The current year starting from 1. */
558        readonly year: number;
559    }
560
561    /**
562     * APIs for the map.
563     */
564    interface GameMap {
565        readonly size: CoordsXY;
566        readonly numRides: number;
567        readonly numEntities: number;
568        readonly rides: Ride[];
569
570        getRide(id: number): Ride;
571        getTile(x: number, y: number): Tile;
572        getEntity(id: number): Entity;
573        getAllEntities(type: EntityType): Entity[];
574        /**
575         * @deprecated since version 34, use guest or staff instead.
576         */
577        getAllEntities(type: "peep"): Peep[];
578        getAllEntities(type: "guest"): Guest[];
579        getAllEntities(type: "staff"): Staff[];
580        getAllEntities(type: "car"): Car[];
581        getAllEntities(type: "litter"): Litter[];
582        createEntity(type: EntityType, initializer: object): Entity;
583    }
584
585    type TileElementType =
586        "surface" | "footpath" | "track" | "small_scenery" | "wall" | "entrance" | "large_scenery" | "banner"
587        /** This only exist to retrieve the types for existing corrupt elements. For hiding elements, use the isHidden field instead. */
588        | "openrct2_corrupt_deprecated";
589
590    type Direction = 0 | 1 | 2 | 3;
591
592    type TileElement =
593        SurfaceElement | FootpathElement | TrackElement | SmallSceneryElement | WallElement | EntranceElement
594        | LargeSceneryElement | BannerElement | CorruptElement;
595
596    interface BaseTileElement {
597        type: TileElementType;
598        baseHeight: number;
599        baseZ: number;
600        clearanceHeight: number;
601        clearanceZ: number;
602        occupiedQuadrants: number;
603        isGhost: boolean;
604        isHidden: boolean; /** Take caution when changing this field, it may invalidate TileElements you have stored in your script. */
605    }
606
607    interface SurfaceElement extends BaseTileElement {
608        type: "surface";
609
610        slope: number;
611        surfaceStyle: number;
612        edgeStyle: number;
613        waterHeight: number;
614        grassLength: number;
615        ownership: number;
616        parkFences: number;
617
618        readonly hasOwnership: boolean;
619        readonly hasConstructionRights: boolean;
620    }
621
622    interface FootpathElement extends BaseTileElement {
623        type: "footpath";
624
625        object: number;
626
627        edges: number;
628        corners: number;
629        slopeDirection: number | null;
630        isBlockedByVehicle: boolean;
631        isWide: boolean;
632
633        isQueue: boolean;
634        queueBannerDirection: number | null;
635        ride: number | null;
636        station: number | null;
637
638        addition: number | null;
639        additionStatus: number | null;
640        isAdditionBroken: boolean | null;
641        isAdditionGhost: boolean | null;
642    }
643
644    interface TrackElement extends BaseTileElement {
645        type: "track";
646
647        direction: Direction;
648        trackType: number;
649        sequence: number | null;
650        mazeEntry: number | null;
651
652        colourScheme: number | null;
653        seatRotation: number | null;
654
655        ride: number;
656        station: number | null;
657
658        brakeBoosterSpeed: number | null;
659        hasChainLift: boolean;
660        isInverted: boolean;
661        hasCableLift: boolean;
662    }
663
664    interface SmallSceneryElement extends BaseTileElement {
665        type: "small_scenery";
666
667        direction: Direction;
668        object: number;
669        primaryColour: number;
670        secondaryColour: number;
671        quadrant: number;
672        age: number;
673    }
674
675    interface WallElement extends BaseTileElement {
676        type: "wall";
677
678        direction: Direction;
679        object: number;
680        primaryColour: number;
681        secondaryColour: number;
682        tertiaryColour: number;
683        bannerIndex: number | null;
684        slope: Direction;
685    }
686
687    interface EntranceElement extends BaseTileElement {
688        type: "entrance";
689
690        direction: Direction;
691        object: number;
692        ride: number;
693        station: number;
694        sequence: number;
695        footpathObject: number;
696    }
697
698    interface LargeSceneryElement extends BaseTileElement {
699        type: "large_scenery";
700
701        direction: Direction;
702        object: number;
703        primaryColour: number;
704        secondaryColour: number;
705        bannerIndex: number | null;
706        sequence: number;
707    }
708
709    interface BannerElement extends BaseTileElement {
710        type: "banner";
711        direction: Direction;
712        bannerIndex: number;
713    }
714
715    interface CorruptElement extends BaseTileElement {
716        type: "openrct2_corrupt_deprecated";
717    }
718
719    /**
720     * Represents a tile containing tile elements on the map. This is a fixed handle
721     * for a given tile position. It can be re-used safely between game ticks.
722     */
723    interface Tile {
724        /** The x position in tiles. */
725        readonly x: number;
726        /** The y position in tiles. */
727        readonly y: number;
728        /** Gets an array of all the tile elements on this tile. */
729        readonly elements: TileElement[];
730        /** Gets the number of tile elements on this tile. */
731        readonly numElements: number;
732        /**
733         * Gets or sets the raw data for this tile.
734         * This can provide more control and efficiency for tile manipulation but requires
735         * knowledge of tile element structures and may change between versions of OpenRCT2.
736         */
737        data: Uint8Array;
738
739        /** Gets the tile element at the given index on this tile. */
740        getElement(index: number): TileElement;
741        /** Gets the tile element at the given index on this tile. */
742        getElement<T extends TileElement>(index: number): T;
743        /** Inserts a new tile element at the given index on this tile. */
744        insertElement(index: number): TileElement;
745        /** Removes the tile element at the given index from this tile. */
746        removeElement(index: number): void;
747    }
748
749    /**
750     * Represents the definition of a loaded object (.DAT or .json) such a ride type or scenery item.
751     */
752    interface LoadedObject {
753        /**
754         * The object type.
755         */
756        readonly type: ObjectType;
757
758        /**
759         * The index of the loaded object for the object type.
760         */
761        readonly index: number;
762
763        /**
764         * The unique identifier of the object, e.g. "rct2.burgb".
765         * Only JSON objects will have an identifier.
766         */
767        readonly identifier: string;
768
769        /**
770         * The original unique identifier of the object, e.g. "BURGB   ".
771         * This may have trailing spaces if the name is shorter than 8 characters.
772         * Only .DAT objects or JSON objects based on .DAT objects will have legacy identifiers.
773         */
774        readonly legacyIdentifier: string;
775
776        /**
777         * The name in the user's current language.
778         */
779        readonly name: string;
780    }
781
782    /**
783     * Represents the object definition of a ride or stall.
784     */
785    interface RideObject extends LoadedObject {
786        /**
787         * The description of the ride / stall in the player's current language.
788         */
789        readonly description: string;
790        /**
791         * A text description describing the capacity of the ride in the player's current language.
792         */
793        readonly capacity: string;
794
795        readonly flags: number;
796        readonly rideType: number[];
797        readonly minCarsInTrain: number;
798        readonly maxCarsInTrain: number;
799        readonly carsPerFlatRide: number;
800        readonly zeroCars: number;
801        readonly tabVehicle: number;
802        readonly defaultVehicle: number;
803        readonly frontVehicle: number;
804        readonly secondVehicle: number;
805        readonly rearVehicle: number;
806        readonly thirdVehicle: number;
807        readonly vehicles: RideObjectVehicle[];
808        readonly excitementMultiplier: number;
809        readonly intensityMultiplier: number;
810        readonly nauseaMultiplier: number;
811        readonly maxHeight: number;
812        readonly shopItem: number;
813        readonly shopItemSecondary: number;
814    }
815
816    /**
817     * Represents a defined vehicle within a Ride object definition.
818     */
819    interface RideObjectVehicle {
820        readonly rotationFrameMask: number;
821        readonly numVerticalFrames: number;
822        readonly numHorizontalFrames: number;
823        readonly spacing: number;
824        readonly carMass: number;
825        readonly tabHeight: number;
826        readonly numSeats: number;
827        readonly spriteFlags: number;
828        readonly spriteWidth: number;
829        readonly spriteHeightNegative: number;
830        readonly spriteHeightPositive: number;
831        readonly animation: number;
832        readonly flags: number;
833        readonly baseNumFrames: number;
834        readonly baseImageId: number;
835        readonly restraintImageId: number;
836        readonly gentleSlopeImageId: number;
837        readonly steepSlopeImageId: number;
838        readonly verticalSlopeImageId: number;
839        readonly diagonalSlopeImageId: number;
840        readonly bankedImageId: number;
841        readonly inlineTwistImageId: number;
842        readonly flatToGentleBankImageId: number;
843        readonly diagonalToGentleSlopeBankImageId: number;
844        readonly gentleSlopeToBankImageId: number;
845        readonly gentleSlopeBankTurnImageId: number;
846        readonly flatBankToGentleSlopeImageId: number;
847        readonly curvedLiftHillImageId: number;
848        readonly corkscrewImageId: number;
849        readonly noVehicleImages: number;
850        readonly noSeatingRows: number;
851        readonly spinningInertia: number;
852        readonly spinningFriction: number;
853        readonly frictionSoundId: number;
854        readonly logFlumeReverserVehicleType: number;
855        readonly soundRange: number;
856        readonly doubleSoundFrequency: number;
857        readonly poweredAcceleration: number;
858        readonly poweredMaxSpeed: number;
859        readonly carVisual: number;
860        readonly effectVisual: number;
861        readonly drawOrder: number;
862        readonly numVerticalFramesOverride: number;
863    }
864
865    /**
866     * Represents the object definition of a small scenery item such a tree.
867     */
868    interface SmallSceneryObject extends LoadedObject {
869        /**
870         * Raw bit flags that describe characteristics of the scenery item.
871         */
872        readonly flags: number;
873
874        /**
875         * The default clearance height of the scenery item.
876         */
877        readonly height: number;
878
879        /**
880         * How much the scenery item costs to build.
881         */
882        readonly price: number;
883
884        /**
885         * How much the scenery item costs to remove.
886         */
887        readonly removalPrice: number;
888    }
889
890    /**
891     * Represents a ride or stall within the park.
892     */
893    interface Ride {
894        /**
895         * The object metadata for this ride.
896         */
897        readonly object: RideObject;
898
899        /**
900         * The unique ID / index of the ride.
901         */
902        readonly id: number;
903
904        /**
905         * The type of the ride represented as the internal built-in ride type ID.
906         */
907        type: number;
908
909        /**
910         * Whether the ride is a ride, shop or facility.
911         */
912        readonly classification: RideClassification;
913
914        /**
915         * The generated or custom name of the ride.
916         */
917        name: string;
918
919        /**
920         * Whether the ride is open, closed or testing.
921         */
922        readonly status: RideStatus;
923
924        /**
925         * Various flags related to the operation of the ride.
926         */
927        lifecycleFlags: number;
928
929        /**
930         * The operation mode.
931         */
932        mode: number;
933
934        /**
935         * Flags related to how trains depart.
936         */
937        departFlags: number;
938
939        /**
940         * The minimum time a train will wait at the station before departing.
941         */
942        minimumWaitingTime: number;
943
944        /**
945         * The maximum time a train will wait at the station before departing.
946         */
947        maximumWaitingTime: number;
948
949        /**
950         * The head vehicle IDs associated with the ride, one for each train.
951         */
952        readonly vehicles: number[];
953
954        /**
955         * The colour for each vehicle when the ride opens. Modifying this directly will not
956         * change the colour of any currently running trains nor will it reflect them if they
957         * have been modified.
958         */
959        vehicleColours: VehicleColour[];
960
961        /**
962         * The track colour schemes for the ride.
963         */
964        colourSchemes: TrackColour[];
965
966        /**
967         * The style used for the station, entrance, and exit building.
968         */
969        stationStyle: number;
970
971        /**
972         * The music track to play at each station.
973         */
974        music: number;
975
976        /**
977         * Information about each station.
978         */
979        readonly stations: RideStation[];
980
981        /**
982         * The admission price for the ride and the price of the on-ride photo, or the cost of each item of the stall.
983         */
984        price: number[];
985
986        /**
987         * The excitement metric of the ride represented as a 2 decimal point fixed integer.
988         * For example, `652` equates to `6.52`.
989         */
990        excitement: number;
991
992        /**
993         * The intensity metric of the ride represented as a 2 decimal point fixed integer.
994         * For example, `652` equates to `6.52`.
995         */
996        intensity: number;
997
998        /**
999         * The nausea metric of the ride represented as a 2 decimal point fixed integer.
1000         * For example, `652` equates to `6.52`.
1001         */
1002        nausea: number;
1003
1004        /**
1005         * The total number of customers the ride has served since it was built.
1006         */
1007        totalCustomers: number;
1008
1009        /**
1010         * The date in months when the ride was built.
1011         * Subtract this from `date.monthsElapsed` to get the age.
1012         */
1013        buildDate: number;
1014
1015        /**
1016         * How old the ride is in months.
1017         */
1018        readonly age: number;
1019
1020        /**
1021         * The running cost of the ride billed every fortnight. Multiply this by 16 to get the cost per hour (~ 1 year).
1022         */
1023        runningCost: number;
1024
1025        /**
1026         * The total profit of the ride over the course of its lifetime.
1027         */
1028        totalProfit: number;
1029
1030        /**
1031         * How often the ride should be inspected by a mechanic.
1032         */
1033        inspectionInterval: number;
1034
1035        /**
1036         * The value of the ride.
1037         */
1038        value: number;
1039
1040        /**
1041         * The percentage of downtime for this ride from 0 to 100.
1042         */
1043        readonly downtime: number;
1044    }
1045
1046    type RideClassification = "ride" | "stall" | "facility";
1047
1048    type RideStatus = "closed" | "open" | "testing" | "simulating";
1049
1050    interface TrackColour {
1051        main: number;
1052        additional: number;
1053        supports: number;
1054    }
1055
1056    interface VehicleColour {
1057        body: number;
1058        trim: number;
1059        ternary: number;
1060    }
1061
1062    interface RideStation {
1063        start: CoordsXYZ;
1064        length: number;
1065        entrance: CoordsXYZD;
1066        exit: CoordsXYZD;
1067    }
1068
1069    type EntityType =
1070        "balloon" |
1071        "car" |
1072        "crash_splash" |
1073        "crashed_vehicle_particle" |
1074        "duck" |
1075        "explosion_cloud" |
1076        "explosion_flare" |
1077        "jumping_fountain_snow" |
1078        "jumping_fountain_water" |
1079        "litter" |
1080        "money_effect" |
1081        "guest" |
1082        "staff" |
1083        "steam_particle" |
1084        /**
1085         * @deprecated since version 34, use guest or staff instead.
1086         */
1087        "peep";
1088
1089    /**
1090     * Represents an object "entity" on the map that can typically moves and has a sub-tile coordinate.
1091     */
1092    interface Entity {
1093        /**
1094         * The entity index within the entity list.
1095         */
1096        readonly id: number;
1097        /**
1098         * The type of entity, e.g. guest, vehicle, etc.
1099         */
1100        readonly type: EntityType;
1101        /**
1102         * The x-coordinate of the entity in game units.
1103         */
1104        x: number;
1105        /**
1106         * The y-coordinate of the entity in game units.
1107         */
1108        y: number;
1109        /**
1110         * The z-coordinate of the entity in game units.
1111         */
1112        z: number;
1113
1114        /**
1115         * Removes the entity from the map.
1116         * Note: removing vehicles and peeps that are on rides is currently unsupported.
1117         */
1118        remove(): void;
1119    }
1120
1121    /**
1122     * Represents a single car on a ride. A train is made up of multiple cars, but
1123     * something like boat hire will be one car per boat.
1124     */
1125    interface Car extends Entity {
1126        /**
1127         * The ride this car belongs to.
1128         */
1129        ride: number;
1130
1131        /**
1132         * The ride object for this car, e.g. the ladybird trains object.
1133         */
1134        rideObject: number;
1135
1136        /**
1137         * The vehicle type for the ride object used. This is a local index
1138         * into the ride object list of vehicle types.
1139         */
1140        vehicleObject: number;
1141
1142        spriteType: number;
1143
1144        /**
1145         * How many seats the car has, i.e. the capacity.
1146         */
1147        numSeats: number;
1148
1149        /**
1150         * The next car on the same train. If this is the last or only car on the train,
1151         * this will return null.
1152         */
1153        nextCarOnTrain: number | null;
1154
1155        /**
1156         * The previous car on the ride. This may be the on the same train or the previous
1157         * train. This will point to the last car if this is the first car on the ride.
1158         */
1159        previousCarOnRide: number;
1160
1161        /**
1162         * The next car on the ride. This may be the on the same train or the next
1163         * train. This will point to the first car if this is the last car on the ride.
1164         */
1165        nextCarOnRide: number;
1166
1167        /**
1168         * The current station the train is in or departing.
1169         */
1170        currentStation: number;
1171
1172        /**
1173         * How heavy the car is. This is the sum of the mass of the empty car and the
1174         * mass of each guest that is riding it.
1175         */
1176        mass: number;
1177
1178        /**
1179         * How much the car's velocity changes per tick.
1180         */
1181        acceleration: number;
1182
1183        /**
1184         * How fast the car is moving.
1185         */
1186        velocity: number;
1187
1188        /**
1189         * The current tilt of the car in the X/Y axis.
1190         */
1191        bankRotation: number;
1192
1193        /**
1194         * The colour of the car.
1195         */
1196        colours: VehicleColour;
1197
1198        /**
1199         * The acceleration for vehicles with constant power, e.g.
1200         * transport rides and boats.
1201         */
1202        poweredAcceleration: number;
1203
1204        /**
1205         * The maximum speed for vehicles with constant power, e.g.
1206         * transport rides and boats.
1207         */
1208        poweredMaxSpeed: number;
1209
1210        /**
1211         * Current status of the car or train.
1212         */
1213        status: VehicleStatus;
1214
1215        /**
1216         * The location and direction of where the car is on the track.
1217         */
1218        trackLocation: CoordsXYZD;
1219
1220        /**
1221         * The current g-forces of this car.
1222         */
1223        readonly gForces: GForces;
1224
1225        /**
1226         * The progress on the current track piece, in steps.
1227         */
1228        readonly trackProgress: number;
1229
1230        /**
1231         * The currently projected remaining distance the car will travel.
1232         */
1233        readonly remainingDistance: number;
1234
1235        /**
1236         * List of guest IDs ordered by seat.
1237         * @deprecated since version 34, use guests instead.
1238         */
1239        peeps: Array<number | null>;
1240
1241        /**
1242         * List of guest IDs ordered by seat.
1243         */
1244        guests: Array<number | null>;
1245
1246        /**
1247         * Moves the vehicle forward or backwards along the track, relative to its current
1248         * position. A single visible step is about 8.000 to 14.000 in distance depending
1249         * on the direction its moving in.
1250         */
1251        travelBy(distance: number): void;
1252    }
1253
1254    type VehicleStatus =
1255        "arriving" |
1256        "crashed" |
1257        "crashing" |
1258        "crooked_house_operating" |
1259        "departing" |
1260        "doing_circus_show" |
1261        "ferris_wheel_rotating" |
1262        "haunted_house_operating" |
1263        "moving_to_end_of_station" |
1264        "operating_1a" |
1265        "rotating" |
1266        "showing_film" |
1267        "simulator_operating" |
1268        "space_rings_operating" |
1269        "starting" |
1270        "stopped_by_block_brake" |
1271        "stopping_1b" |
1272        "stopping" |
1273        "swinging" |
1274        "top_spin_operating" |
1275        "travelling_boat" |
1276        "travelling_cable_lift" |
1277        "travelling_dodgems" |
1278        "travelling" |
1279        "unloading_passengers_1c" |
1280        "unloading_passengers" |
1281        "waiting_for_cable_lift" |
1282        "waiting_for_passengers_17" |
1283        "waiting_for_passengers" |
1284        "waiting_to_depart" |
1285        "waiting_to_start";
1286
1287    /**
1288     * Represents a guest or staff member.
1289     * @deprecated since version 34, use guest or staff instead.
1290     */
1291    interface Peep extends Entity {
1292        /**
1293         * Whether the peep is a guest or staff member.
1294         */
1295        peepType: PeepType;
1296
1297        /**
1298         * Name of the peep.
1299         */
1300        name: string;
1301
1302        /**
1303         * The peep's direct destination.
1304         */
1305        destination: CoordsXY;
1306
1307        /**
1308         * How tired the guest is between 32 and 128 where lower is more tired.
1309         */
1310        energy: number;
1311
1312        /**
1313         * The target energy value. Energy will increase / decrease slowly towards this value.
1314         */
1315        energyTarget: number;
1316
1317        /**
1318         * Gets whether a given flag is set or not.
1319         * @param key The flag to test.
1320         */
1321        getFlag(key: PeepFlags): boolean;
1322
1323        /**
1324         * Sets the given flag to the given value.
1325         * @param key The flag to set.
1326         * @param value Whether to set or clear the flag.
1327         */
1328        setFlag(key: PeepFlags, value: boolean): void;
1329    }
1330
1331    type PeepFlags =
1332        "leavingPark" |
1333        "slowWalk" |
1334        "tracking" |
1335        "waving" |
1336        "hasPaidForParkEntry" |
1337        "photo" |
1338        "painting" |
1339        "wow" |
1340        "litter" |
1341        "lost" |
1342        "hunger" |
1343        "toilet" |
1344        "crowded" |
1345        "happiness" |
1346        "nausea" |
1347        "purple" |
1348        "pizza" |
1349        "explode" |
1350        "rideShouldBeMarkedAsFavourite" |
1351        "parkEntranceChosen" |
1352        "contagious" |
1353        "joy" |
1354        "angry" |
1355        "iceCream" |
1356        "hereWeAre";
1357
1358    /**
1359     * @deprecated since version 34, use EntityType instead.
1360     */
1361    type PeepType = "guest" | "staff";
1362
1363    /**
1364     * Represents a guest.
1365     */
1366    interface Guest extends Peep {
1367        /**
1368         * Colour of the guest's t-shirt.
1369         */
1370        tshirtColour: number;
1371
1372        /**
1373         * Colour of the guest's trousers.
1374         */
1375        trousersColour: number;
1376
1377        /**
1378         * Colour of the guest's balloon.
1379         */
1380        balloonColour: number;
1381
1382        /**
1383         * Colour of the guest's hat.
1384         */
1385        hatColour: number;
1386
1387        /**
1388         * Colour of the guest's umbrella.
1389         */
1390        umbrellaColour: number;
1391
1392        /**
1393         * How happy the guest is between 0 and 255.
1394         */
1395        happiness: number;
1396
1397        /**
1398         * The target happiness value. Happiness will increase / decrease slowly towards this value.
1399         */
1400        happinessTarget: number;
1401
1402        /**
1403         * How nauseated the guest is between 0 and 255.
1404         */
1405        nausea: number;
1406
1407        /**
1408         * The target nausea value. Nausea will increase / decrease slowly towards this value.
1409         */
1410        nauseaTarget: number;
1411
1412        /**
1413         * How hungry the guest is between 0 and 255. Lower is more hungry.
1414         */
1415        hunger: number;
1416
1417        /**
1418         * How thirsty the guest is between 0 and 255. Lower is more thirsty.
1419         */
1420        thirst: number;
1421
1422        /**
1423         * How much the guest requires the need to go to the toilet between 0 and 255.
1424         */
1425        toilet: number;
1426
1427        /**
1428         * The mass of the guest. Affects vehicle mass.
1429         */
1430        mass: number;
1431
1432        /**
1433         * The guest's minimum preferred intensity between 0 and 15.
1434         */
1435        minIntensity: number;
1436
1437        /**
1438         * The guest's maximum preferred intensity between 0 and 15.
1439         */
1440        maxIntensity: number;
1441
1442        /**
1443         * The guest's tolerance to nauseating rides between 0 and 3.
1444         */
1445        nauseaTolerance: number;
1446
1447        /**
1448         * Amount of cash in the guest's pocket.
1449         */
1450        cash: number;
1451
1452        /**
1453         * Whether the guest is within the boundaries of the park.
1454         */
1455        readonly isInPark: boolean;
1456
1457        /**
1458         * Whether the guest is lost or not. The guest is lost when the countdown is below 90.
1459         */
1460        readonly isLost: boolean;
1461
1462        /**
1463         * Countdown between 0 and 255 that keeps track of how long the guest has been looking for its current destination.
1464         */
1465        lostCountdown: number;
1466    }
1467
1468    /**
1469     * Represents a staff member.
1470     */
1471    interface Staff extends Peep {
1472        /**
1473         * The type of staff member, e.g. handyman, mechanic.
1474         */
1475        staffType: StaffType;
1476
1477        /**
1478         * Colour of the staff member. Not applicable for entertainers.
1479         */
1480        colour: number;
1481
1482        /**
1483         * The entertainer's costume, only applicable for entertainers.
1484         */
1485        costume: number;
1486
1487        /**
1488         * The enabled jobs the staff can do, e.g. sweep litter, water plants, inspect rides etc.
1489         */
1490        orders: number;
1491    }
1492
1493    type StaffType = "handyman" | "mechanic" | "security" | "entertainer";
1494
1495    /**
1496     * Represents litter entity.
1497     */
1498    interface Litter extends Entity {
1499        /**
1500         * The type of the litter.
1501         */
1502        litterType: LitterType;
1503
1504        /**
1505         * The tick number this entity was created.
1506         */
1507        creationTick: number;
1508    }
1509
1510    type LitterType = "vomit" |
1511        "vomit_alt" |
1512        "empty_can" |
1513        "rubbish" |
1514        "burger_box" |
1515        "empty_cup" |
1516        "empty_box" |
1517        "empty_bottle" |
1518        "empty_bowl_red" |
1519        "empty_drink_carton" |
1520        "empty_juice_cup" |
1521        "empty_bowl_blue";
1522
1523    /**
1524     * Network APIs
1525     * Use `network.status` to determine whether the current game is a client, server or in single player mode.
1526     */
1527    interface Network {
1528        readonly mode: NetworkMode;
1529        readonly numGroups: number;
1530        readonly numPlayers: number;
1531        readonly groups: PlayerGroup[];
1532        readonly players: Player[];
1533        readonly currentPlayer: Player;
1534        defaultGroup: number;
1535        readonly stats: NetworkStats;
1536
1537        getServerInfo(): ServerInfo;
1538        addGroup(): void;
1539        getGroup(index: number): PlayerGroup;
1540        removeGroup(index: number): void;
1541        getPlayer(index: number): Player;
1542        kickPlayer(index: number): void;
1543        sendMessage(message: string): void;
1544        sendMessage(message: string, players: number[]): void;
1545
1546        createListener(): Listener;
1547        createSocket(): Socket;
1548    }
1549
1550    type NetworkMode = "none" | "server" | "client";
1551
1552    /**
1553     * Represents a player within a network game.
1554     */
1555    interface Player {
1556        readonly id: number;
1557        readonly name: string;
1558        group: number;
1559        readonly ping: number;
1560        readonly commandsRan: number;
1561        readonly moneySpent: number;
1562        readonly ipAddress: string;
1563        readonly publicKeyHash: string;
1564    }
1565
1566    interface PlayerGroup {
1567        readonly id: number;
1568        name: string;
1569        permissions: PermissionType[];
1570    }
1571
1572    interface ServerInfo {
1573        readonly name: string;
1574        readonly description: string;
1575        readonly greeting: string;
1576        readonly providerName: string;
1577        readonly providerEmail: string;
1578        readonly providerWebsite: string;
1579    }
1580
1581    interface NetworkStats {
1582        bytesReceived: number[];
1583        bytesSent: number[];
1584    }
1585
1586    type PermissionType =
1587        "chat" |
1588        "terraform" |
1589        "set_water_level" |
1590        "toggle_pause" |
1591        "create_ride" |
1592        "remove_ride" |
1593        "build_ride" |
1594        "ride_properties" |
1595        "scenery" |
1596        "path" |
1597        "clear_landscape" |
1598        "guest" |
1599        "staff" |
1600        "park_properties" |
1601        "park_funding" |
1602        "kick_player" |
1603        "modify_groups" |
1604        "set_player_group" |
1605        "cheat" |
1606        "toggle_scenery_cluster" |
1607        "passwordless_login" |
1608        "modify_tile" |
1609        "edit_scenario_options";
1610
1611    /**
1612     * Park APIs
1613     */
1614
1615    /**
1616     * The type of park message, including icon and behaviour.
1617     */
1618    type ParkMessageType =
1619        "attraction" | "peep_on_attraction" | "peep" | "money" | "blank" | "research" | "guests" | "award" | "chart";
1620
1621    interface ParkMessage {
1622        /**
1623         * Whether the message has been shown and archived.
1624         */
1625        readonly isArchived: boolean;
1626
1627        /**
1628         * The date this message was posted in total elapsed months.
1629         */
1630        month: number;
1631
1632        /**
1633         * The day of the month this message was posted.
1634         */
1635        day: number;
1636
1637        /**
1638         * How old the message is in number of ticks.
1639         */
1640        tickCount: number;
1641
1642        /**
1643         * The format of the message such as the icon and whether location is enabled.
1644         */
1645        type: ParkMessageType;
1646
1647        /**
1648         * The actual message content.
1649         */
1650        text: string;
1651
1652        /**
1653         * Ride ID for attraction.
1654         * Entity ID for peep_on_attraction or peep.
1655         * Researched item for research.
1656         */
1657        subject?: number;
1658
1659        /**
1660         * Removes the message.
1661         */
1662        remove(): void;
1663    }
1664
1665    interface ParkMessageDesc {
1666        type: ParkMessageType;
1667        text: string;
1668        subject?: number;
1669    }
1670
1671    type ParkFlags =
1672        "difficultGuestGeneration" |
1673        "difficultParkRating" |
1674        "forbidHighConstruction" |
1675        "forbidLandscapeChanges" |
1676        "forbidMarketingCampaigns" |
1677        "forbidTreeRemoval" |
1678        "freeParkEntry" |
1679        "noMoney" |
1680        "open" |
1681        "preferLessIntenseRides" |
1682        "preferMoreIntenseRides" |
1683        "scenarioCompleteNameInput" |
1684        "unlockAllPrices";
1685
1686    interface Park {
1687        cash: number;
1688        rating: number;
1689        bankLoan: number;
1690        maxBankLoan: number;
1691
1692        /**
1693         * The current entrance fee for the park.
1694         */
1695        entranceFee: number;
1696
1697        /**
1698         * The number of guests within the park, not including any outside the park but still
1699         * on the map.
1700         */
1701        readonly guests: number;
1702
1703        /**
1704         * The maximum number of guests that will spawn naturally (soft guest cap).
1705         * In scenarios with difficult guest generation, guests will not spawn above
1706         * this value without advertisements.
1707         */
1708        readonly suggestedGuestMaximum: number;
1709
1710        /**
1711         * The probability out of 65535 that guests will spawn per tick.
1712         * The number of guest spawns per second is equal to
1713         * guests per second = 40 * (guestGenerationProbability / 65535)
1714         */
1715        readonly guestGenerationProbability: number;
1716
1717        /**
1718         * The average amount of cash guests will spawn with.
1719         */
1720        readonly guestInitialCash: number;
1721
1722        /**
1723         * The average happiness guests will spawn at out of 255.
1724         */
1725        readonly guestInitialHappiness: number;
1726
1727        /**
1728         * The average hunger guests will spawn at out of 255.
1729         */
1730        readonly guestInitialHunger: number;
1731
1732        /**
1733         * The average thirst guests will spawn at out of 255.
1734         */
1735        readonly guestInitialThirst: number;
1736
1737        /**
1738         * The park value, will be updated every 512 ticks.
1739         */
1740        value: number;
1741
1742        /**
1743         * The company value, will be updated every 512 ticks.
1744         * Calculation is: `park.value + park.cash - park.bankLoan`
1745         */
1746        companyValue: number;
1747
1748        /**
1749         * The sum of ride values, used to determine the most guests will
1750         * pay to enter the park and for some awards.
1751         * Calculated as the sum of (ride value - ride price) * 2.
1752         */
1753        readonly totalRideValueForMoney: number;
1754
1755        /**
1756         * The total number of guests that have entered the park.
1757         */
1758        totalAdmissions: number;
1759
1760        /**
1761         * The total amount of income gained from admissions into the park.
1762         */
1763        totalIncomeFromAdmissions: number;
1764
1765        /**
1766         * The purchase price of one tile for park ownership.
1767         */
1768        landPrice: number;
1769
1770        /**
1771         * The purchase price of one tile for construction rights.
1772         */
1773        constructionRightsPrice: number;
1774
1775        /**
1776         * The amount of penalty points currentlty applied to the park rating for
1777         * drowned guests and crashed coaster cars.
1778         */
1779        casualtyPenalty: number;
1780
1781        /**
1782         * The number of tiles on the map with park ownership or construction rights.
1783         * Updated every 4096 ticks.
1784         */
1785        readonly parkSize: number;
1786
1787        name: string;
1788        messages: ParkMessage[];
1789
1790        /**
1791         * Gets whether a given flag is set or not.
1792         * @param key The flag to test.
1793         */
1794        getFlag(flag: ParkFlags): boolean;
1795
1796        /**
1797         * Sets the given flag to the given value.
1798         * @param key The flag to set.
1799         * @param value Whether to set or clear the flag.
1800         */
1801        setFlag(flag: ParkFlags, value: boolean): void;
1802
1803        postMessage(message: string): void;
1804        postMessage(message: ParkMessageDesc): void;
1805    }
1806
1807    type ScenarioObjectiveType =
1808        "none" |
1809        "guestsBy" |
1810        "parkValueBy" |
1811        "haveFun" |
1812        "buildTheBest" |
1813        "10Rollercoasters" |
1814        "guestsAndRating" |
1815        "monthlyRideIncome" |
1816        "10RollercoastersLength" |
1817        "finish5Rollercoasters" |
1818        "repayLoanAndParkValue" |
1819        "monthlyFoodIncome";
1820
1821    interface ScenarioObjective {
1822        /**
1823         * The objective type.
1824         */
1825        type: ScenarioObjective;
1826
1827        /**
1828         * The required number of guests.
1829         */
1830        guests: number;
1831
1832        /**
1833         * The year the objective must be completed by the end of.
1834         */
1835        year: number;
1836
1837        /**
1838         * The minimum length required for each rollercoaster.
1839         */
1840        length: number;
1841
1842        /**
1843         * The minimum excitement rating required for each rollercoaster.
1844         */
1845        excitement: number;
1846
1847        /**
1848         * The minimum park value required.
1849         */
1850        parkValue: number;
1851
1852        /**
1853         * The minimum monthly income from rides / food.
1854         */
1855        monthlyIncome: number;
1856    }
1857
1858    type ScenarioStatus = "inProgress" | "completed" | "failed";
1859
1860    interface Scenario {
1861        /**
1862         * The name of the scenario. This is not necessarily the name of the park.
1863         */
1864        name: string;
1865
1866        /**
1867         * The description of the scenario, shown above the scenario objective.
1868         */
1869        details: string;
1870
1871        /**
1872         * The entered player name if the scenario is complete.
1873         */
1874        completedBy: string;
1875
1876        /**
1877         * The filename of the scenario that is being played. Used to match the
1878         * completion score with the scenario file.
1879         */
1880        filename: string;
1881
1882        /**
1883         * The criteria required to complete the scenario.
1884         */
1885        objective: ScenarioObjective;
1886
1887        /**
1888         * The number of consecutive days the park rating has been under the threshold for.
1889         * This is reset when the park rating rises above the threshold again.
1890         * Also used to post warning messages.
1891         */
1892        parkRatingWarningDays: number;
1893
1894        /**
1895         * The company value when the scenario was completed.
1896         */
1897        completedCompanyValue?: number;
1898
1899        /**
1900         * The current status of the scenario.
1901         */
1902        status: ScenarioStatus;
1903
1904        /**
1905         * The current highest recorded company value.
1906         */
1907        companyValueRecord: number;
1908    }
1909
1910    type ClimateType =
1911        "coolAndWet" |
1912        "warm" |
1913        "hotAndDry" |
1914        "cold";
1915
1916    type WeatherType =
1917        "sunny" |
1918        "partiallyCloudy" |
1919        "cloudy" |
1920        "rain" |
1921        "heavyRain" |
1922        "thunder" |
1923        "snow" |
1924        "heavySnow" |
1925        "blizzard";
1926
1927    interface ClimateState {
1928        readonly weather: WeatherType;
1929        readonly temperature: number;
1930    }
1931
1932    interface Climate {
1933        /**
1934         * The climate of the park.
1935         */
1936        readonly type: ClimateType;
1937
1938        /**
1939         * The current weather in the park.
1940         */
1941        readonly current: ClimateState;
1942
1943        /**
1944         * The next weather the park will experience.
1945         */
1946        readonly future: ClimateState;
1947    }
1948
1949    interface Cheats {
1950        allowArbitraryRideTypeChanges: boolean;
1951        allowTrackPlaceInvalidHeights: boolean;
1952        buildInPauseMode: boolean;
1953        disableAllBreakdowns: boolean;
1954        disableBrakesFailure: boolean;
1955        disableClearanceChecks: boolean;
1956        disableLittering: boolean;
1957        disablePlantAging: boolean;
1958        disableRideValueAging: boolean;
1959        disableSupportLimits: boolean;
1960        disableTrainLengthLimit: boolean;
1961        disableVandalism: boolean;
1962        enableAllDrawableTrackPieces: boolean;
1963        enableChainLiftOnAllTrack: boolean;
1964        fastLiftHill: boolean;
1965        freezeWeather: boolean;
1966        ignoreResearchStatus: boolean;
1967        ignoreRideIntensity: boolean;
1968        neverendingMarketing: boolean;
1969        sandboxMode: boolean;
1970        showAllOperatingModes: boolean;
1971        showVehiclesFromOtherTrackTypes: boolean;
1972    }
1973
1974    /**
1975     * User Interface APIs
1976     * These will only be available to servers and clients that are not running headless mode.
1977     * Plugin writers should check if ui is available using `typeof ui !== 'undefined'`.
1978     */
1979    interface Ui {
1980        readonly width: number;
1981        readonly height: number;
1982        readonly windows: number;
1983        readonly mainViewport: Viewport;
1984        readonly tileSelection: TileSelection;
1985        readonly tool: Tool | null;
1986
1987        getWindow(id: number): Window;
1988        getWindow(classification: string): Window;
1989        openWindow(desc: WindowDesc): Window;
1990        closeWindows(classification: string, id?: number): void;
1991        closeAllWindows(): void;
1992
1993        /**
1994         * Show a red error box.
1995         * @param title The title / first line of the box.
1996         * @param message The message / second line of the box.
1997         */
1998        showError(title: string, message: string): void;
1999
2000        /**
2001         * Shows a text input prompt and calls the given callback when entered.
2002         * @param desc The parameters for the text input window.
2003         */
2004        showTextInput(desc: TextInputDesc): void;
2005
2006        /**
2007         * Shows the window for loading or saving a file and calls the given callback when a file
2008         * is selected.
2009         * @param desc The parameters for the file browse window.
2010         */
2011        showFileBrowse(desc: FileBrowseDesc): void;
2012
2013        /**
2014         * Shows the scenario select window and calls the given callback when a scenario is
2015         * selected.
2016         */
2017        showScenarioSelect(desc: ScenarioSelectDesc): void;
2018
2019        /**
2020         * Begins a new tool session. The cursor will change to the style specified by the
2021         * given tool descriptor and cursor events will be provided.
2022         * @param tool The properties and event handlers for the tool.
2023         */
2024        activateTool(tool: ToolDesc): void;
2025
2026        registerMenuItem(text: string, callback: () => void): void;
2027
2028        registerShortcut(desc: ShortcutDesc): void;
2029    }
2030
2031    /**
2032     * Parameters for the text input window.
2033     */
2034    interface TextInputDesc {
2035        /**
2036         * The title of the text input window.
2037         */
2038        title: string;
2039
2040        /**
2041         * The description to show above the text box.
2042         */
2043        description: string;
2044
2045        /**
2046         * The current value of the text box.
2047         */
2048        initialValue?: string;
2049
2050        /**
2051         * The maximum length the value can be.
2052         */
2053        maxLength?: number;
2054
2055        /**
2056         * The function to call when the user has entered a new value and pressed OK.
2057         */
2058        callback: (value: string) => void;
2059    }
2060
2061    /**
2062     * Parameters for the file browse window.
2063     */
2064    interface FileBrowseDesc {
2065        /**
2066         * Whether to browse a file for loading or saving. Saving will prompt the user
2067         * before overwriting a file.
2068         */
2069        type: "load";
2070
2071        /**
2072         * The type of file to browse for.
2073         */
2074        fileType: "game" | "heightmap";
2075
2076        /**
2077         * The pre-selected file to load by default if the user clicks OK.
2078         */
2079        defaultPath?: string;
2080
2081        /**
2082         * The function to call when the user has selected a file.
2083         */
2084        callback: (path: string) => void;
2085    }
2086
2087    /**
2088     * Parameters for the scenario select window.
2089     */
2090    interface ScenarioSelectDesc {
2091        /**
2092         * The function to call when the user has selected a scenario.
2093         */
2094        callback: (scenario: ScenarioFile) => void;
2095    }
2096
2097    /**
2098     * Represents an installed scenario's path and metadata.
2099     */
2100    interface ScenarioFile {
2101        id: number;
2102        category: "beginner" | "challenging" | "expert" | "real" | "other" | "dlc" | "build_your_own";
2103        sourceGame: "rct1" | "rct1_aa" | "rct1_ll" | "rct2" | "rct2_ww" | "rct2_tt" | "real" | "other";
2104        path: string;
2105        internalName: string;
2106        name: string;
2107        details: string;
2108        highscore: {
2109            name: string;
2110            companyValue: number;
2111        };
2112    }
2113
2114    interface TileSelection {
2115        range: MapRange;
2116        tiles: CoordsXY[];
2117    }
2118
2119    interface Tool {
2120        id: string;
2121        cursor: CursorType;
2122
2123        cancel: () => void;
2124    }
2125
2126    interface ToolEventArgs {
2127        readonly isDown: boolean;
2128        readonly screenCoords: ScreenCoordsXY;
2129        readonly mapCoords?: CoordsXYZ;
2130        readonly tileElementIndex?: number;
2131        readonly entityId?: number;
2132    }
2133
2134    /**
2135     * Describes the properties and event handlers for a custom tool.
2136     */
2137    interface ToolDesc {
2138        id: string;
2139        cursor?: CursorType;
2140
2141        /**
2142         * What types of object in the game can be selected with the tool.
2143         * E.g. only specify terrain if you only want a tile selection.
2144         */
2145        filter?: ToolFilter[];
2146
2147        onStart?: () => void;
2148        onDown?: (e: ToolEventArgs) => void;
2149        onMove?: (e: ToolEventArgs) => void;
2150        onUp?: (e: ToolEventArgs) => void;
2151        onFinish?: () => void;
2152    }
2153
2154    type CursorType =
2155        "arrow" |
2156        "bench_down" |
2157        "bin_down" |
2158        "blank" |
2159        "cross_hair" |
2160        "diagonal_arrows" |
2161        "dig_down" |
2162        "entrance_down" |
2163        "fence_down" |
2164        "flower_down" |
2165        "fountain_down" |
2166        "hand_closed" |
2167        "hand_open" |
2168        "hand_point" |
2169        "house_down" |
2170        "lamppost_down" |
2171        "paint_down" |
2172        "path_down" |
2173        "picker" |
2174        "statue_down" |
2175        "tree_down" |
2176        "up_arrow" |
2177        "up_down_arrow" |
2178        "volcano_down" |
2179        "walk_down" |
2180        "water_down" |
2181        "zzz";
2182
2183    type ToolFilter =
2184        "terrain" |
2185        "entity" |
2186        "ride" |
2187        "water" |
2188        "scenery" |
2189        "footpath" |
2190        "footpath_item" |
2191        "park_entrance" |
2192        "wall" |
2193        "large_scenery" |
2194        "label" |
2195        "banner";
2196
2197    interface ShortcutDesc {
2198        /**
2199         * The unique identifier for the shortcut.
2200         * If the identifier already exists, the shortcut will not be registered.
2201         * Use full stops to group shortcuts together, e.g. `yourplugin.somewindow.apply`.
2202         */
2203        id: string;
2204
2205        /**
2206         * The display text for the shortcut.
2207         */
2208        text: string;
2209
2210        /**
2211         * Default bindings for the shortcut.
2212         * E.g. `["CTRL+SHIFT+L", "MOUSE 3"]`
2213         */
2214        bindings?: string[];
2215
2216        /**
2217         * Function to call when the shortcut is invoked.
2218         */
2219        callback: () => void;
2220    }
2221
2222    /**
2223     * Represents the type of a widget, e.g. button or label.
2224     */
2225    type WidgetType =
2226        "button" | "checkbox" | "colourpicker" | "custom" | "dropdown" | "groupbox" |
2227        "label" | "listview" | "spinner" | "textbox" | "viewport";
2228
2229    type Widget =
2230        ButtonWidget | CheckboxWidget | ColourPickerWidget | CustomWidget | DropdownWidget | GroupBoxWidget |
2231        LabelWidget | ListViewWidget | SpinnerWidget | TextBoxWidget | ViewportWidget;
2232
2233    interface WidgetBase {
2234        readonly window?: Window;
2235        type: WidgetType;
2236        x: number;
2237        y: number;
2238        width: number;
2239        height: number;
2240        name?: string;
2241        tooltip?: string;
2242        isDisabled?: boolean;
2243        isVisible?: boolean;
2244    }
2245
2246    interface ButtonWidget extends WidgetBase {
2247        type: "button";
2248        /**
2249         * Whether the button has a 3D border.
2250         * By default, text buttons have borders and image buttons do not but it can be overridden.
2251         */
2252        border?: boolean;
2253        image?: number;
2254        isPressed?: boolean;
2255        text?: string;
2256        onClick?: () => void;
2257    }
2258
2259    interface CheckboxWidget extends WidgetBase {
2260        type: "checkbox";
2261        text?: string;
2262        isChecked?: boolean;
2263        onChange?: (isChecked: boolean) => void;
2264    }
2265
2266    interface ColourPickerWidget extends WidgetBase {
2267        type: "colourpicker";
2268        colour?: number;
2269        onChange?: (colour: number) => void;
2270    }
2271
2272    interface CustomWidget extends WidgetBase {
2273        type: "custom";
2274        onDraw?: (this: CustomWidget, g: GraphicsContext) => void;
2275    }
2276
2277    interface DropdownWidget extends WidgetBase {
2278        type: "dropdown";
2279        items?: string[];
2280        selectedIndex?: number;
2281        onChange?: (index: number) => void;
2282    }
2283
2284    interface GroupBoxWidget extends WidgetBase {
2285        type: "groupbox";
2286    }
2287
2288    interface LabelWidget extends WidgetBase {
2289        type: "label";
2290        text?: string;
2291        textAlign?: TextAlignment;
2292        onChange?: (index: number) => void;
2293    }
2294
2295    type TextAlignment = "left" | "centred";
2296
2297    type SortOrder = "none" | "ascending" | "descending";
2298
2299    type ScrollbarType = "none" | "horizontal" | "vertical" | "both";
2300
2301    interface ListViewColumn {
2302        canSort?: boolean;
2303        sortOrder?: SortOrder;
2304        header?: string;
2305        headerTooltip?: string;
2306        width?: number;
2307        ratioWidth?: number;
2308        minWidth?: number;
2309        maxWidth?: number;
2310    }
2311
2312    interface ListViewItemSeperator {
2313        type: "seperator";
2314        text?: string;
2315    }
2316
2317    type ListViewItem = ListViewItemSeperator | string[];
2318
2319    interface RowColumn {
2320        row: number;
2321        column: number;
2322    }
2323
2324    interface ListViewWidget extends WidgetBase {
2325        type: "listview";
2326        scrollbars?: ScrollbarType;
2327        isStriped?: boolean;
2328        showColumnHeaders?: boolean;
2329        columns?: ListViewColumn[];
2330        items?: string[] | ListViewItem[];
2331        selectedCell?: RowColumn;
2332        readonly highlightedCell?: RowColumn;
2333        canSelect?: boolean;
2334
2335        onHighlight?: (item: number, column: number) => void;
2336        onClick?: (item: number, column: number) => void;
2337    }
2338
2339    interface SpinnerWidget extends WidgetBase {
2340        type: "spinner";
2341        text?: string;
2342
2343        onDecrement?: () => void;
2344        onIncrement?: () => void;
2345        onClick?: () => void;
2346    }
2347
2348    interface TextBoxWidget extends WidgetBase {
2349        type: "textbox";
2350        text?: string;
2351        maxLength?: number;
2352        onChange?: (text: string) => void;
2353    }
2354
2355    interface ViewportWidget extends WidgetBase {
2356        type: "viewport";
2357        viewport?: Viewport;
2358    }
2359
2360    interface Window {
2361        classification: number;
2362        number: number;
2363        x: number;
2364        y: number;
2365        width: number;
2366        height: number;
2367        minWidth: number;
2368        maxWidth: number;
2369        minHeight: number;
2370        maxHeight: number;
2371        isSticky: boolean;
2372        colours: number[];
2373        title: string;
2374        widgets: Widget[];
2375        tabIndex: number;
2376
2377        close(): void;
2378        bringToFront(): void;
2379        findWidget<T extends Widget>(name: string): T;
2380    }
2381
2382    interface WindowDesc {
2383        classification: string;
2384        x?: number;
2385        y?: number;
2386        width: number;
2387        height: number;
2388        title: string;
2389        id?: number;
2390        minWidth?: number;
2391        minHeight?: number;
2392        maxWidth?: number;
2393        maxHeight?: number;
2394        widgets?: Widget[];
2395        colours?: number[];
2396        tabs?: WindowTabDesc[];
2397        tabIndex?: number;
2398
2399        onClose?: () => void;
2400        onUpdate?: () => void;
2401        onTabChange?: () => void;
2402    }
2403
2404    interface ImageAnimation {
2405        frameBase: number;
2406        frameCount?: number;
2407        frameDuration?: number;
2408        offset?: ScreenCoordsXY;
2409    }
2410
2411    interface WindowTabDesc {
2412        image: number | ImageAnimation;
2413        widgets?: Widget[];
2414    }
2415
2416    interface Viewport {
2417        left: number;
2418        top: number;
2419        right: number;
2420        bottom: number;
2421        rotation: number;
2422        zoom: number;
2423        visibilityFlags: number;
2424
2425        getCentrePosition(): CoordsXY;
2426        moveTo(position: CoordsXY | CoordsXYZ): void;
2427        scrollTo(position: CoordsXY | CoordsXYZ): void;
2428    }
2429
2430    /**
2431     * API for drawing graphics.
2432     */
2433    interface GraphicsContext {
2434        colour: number | undefined;
2435        secondaryColour: number | undefined;
2436        ternaryColour: number | undefined;
2437        stroke: number;
2438        fill: number;
2439        paletteId: number | undefined;
2440        readonly width: number;
2441        readonly height: number;
2442
2443        getImage(id: number): ImageInfo | undefined;
2444        measureText(text: string): ScreenSize;
2445
2446        clear(): void;
2447        clip(x: number, y: number, width: number, height: number): void;
2448        box(x: number, y: number, width: number, height: number): void;
2449        image(id: number, x: number, y: number): void;
2450        line(x1: number, y1: number, x2: number, y2: number): void;
2451        rect(x: number, y: number, width: number, height: number): void;
2452        text(text: string, x: number, y: number): void;
2453        well(x: number, y: number, width: number, height: number): void;
2454    }
2455
2456    interface ImageInfo {
2457        readonly id: number;
2458        readonly offset: ScreenCoordsXY;
2459        readonly width: number;
2460        readonly height: number;
2461        readonly isBMP: boolean;
2462        readonly isRLE: boolean;
2463        readonly isPalette: boolean;
2464        readonly noZoom: boolean;
2465        readonly nextZoomId: number | undefined;
2466    }
2467
2468    /**
2469     * Listens for incoming connections.
2470     * Based on node.js net.Server, see https://nodejs.org/api/net.html for more information.
2471     */
2472    interface Listener {
2473        readonly listening: boolean;
2474
2475        listen(port: number, host?: string): Listener;
2476        close(): Listener;
2477
2478        on(event: "connection", callback: (socket: Socket) => void): Listener;
2479
2480        off(event: "connection", callback: (socket: Socket) => void): Listener;
2481    }
2482
2483    /**
2484     * Represents a socket such as a TCP connection.
2485     * Based on node.js net.Socket, see https://nodejs.org/api/net.html for more information.
2486     */
2487    interface Socket {
2488        connect(port: number, host: string, callback: Function): Socket;
2489        destroy(error: object): Socket;
2490        setNoDelay(noDelay: boolean): Socket;
2491        end(data?: string): Socket;
2492        write(data: string): boolean;
2493
2494        on(event: "close", callback: (hadError: boolean) => void): Socket;
2495        on(event: "error", callback: (hadError: boolean) => void): Socket;
2496        on(event: "data", callback: (data: string) => void): Socket;
2497
2498        off(event: "close", callback: (hadError: boolean) => void): Socket;
2499        off(event: "error", callback: (hadError: boolean) => void): Socket;
2500        off(event: "data", callback: (data: string) => void): Socket;
2501    }
2502
2503    interface TitleSequence {
2504        /**
2505         * The name of the title sequence.
2506         */
2507        name: string;
2508
2509        /**
2510         * The full path of the title sequence.
2511         */
2512        readonly path: string;
2513
2514        /**
2515         * Whether the title sequence is a single file or directory.
2516         */
2517        readonly isDirectory: boolean;
2518
2519        /**
2520         * Whether or not the title sequence is read-only (e.g. a pre-installed sequence).
2521         */
2522        readonly isReadOnly: boolean;
2523
2524        /**
2525         * The parks stored within this title sequence.
2526         */
2527        readonly parks: TitleSequencePark[];
2528
2529        /**
2530         * The commands that describe how to play the title sequence.
2531         */
2532        commands: TitleSequenceCommand[];
2533
2534        /**
2535         * Whether the title sequence is currently playing.
2536         */
2537        readonly isPlaying: boolean;
2538
2539        /**
2540         * The current command the title sequence is on if playing.
2541         */
2542        readonly position: number | null;
2543
2544        addPark(path: string, fileName: string): void;
2545
2546        /**
2547         * Creates a new title sequence identical to this one.
2548         * @param name The name of the new title sequence.
2549         */
2550        clone(name: string): TitleSequence;
2551
2552        /**
2553         * Deletes this title sequence from disc.
2554         */
2555        delete(): void;
2556
2557        /**
2558         * Play the title sequence.
2559         */
2560        play(): void;
2561
2562        /**
2563         * Seek to a specific command in the sequence.
2564         * @param position The index of the command to seek to.
2565         */
2566        seek(position: number): void;
2567
2568        /**
2569         * Stops playing the title sequence.
2570         */
2571        stop(): void;
2572    }
2573
2574    interface TitleSequencePark {
2575        /**
2576         * The file name of the park.
2577         */
2578        fileName: string;
2579
2580        /**
2581         * Deletes this park from the title sequence.
2582         */
2583        delete(): void;
2584
2585        /**
2586         * Loads this park.
2587         */
2588        load(): void;
2589    }
2590
2591    type TitleSequenceCommandType =
2592        "load" |
2593        "loadsc" |
2594        "location" |
2595        "rotate" |
2596        "zoom" |
2597        "speed" |
2598        "follow" |
2599        "wait" |
2600        "restart" |
2601        "end";
2602
2603    interface LoadTitleSequenceCommand {
2604        type: "load";
2605        index: number;
2606    }
2607
2608    interface LocationTitleSequenceCommand {
2609        type: "location";
2610        x: number;
2611        y: number;
2612    }
2613
2614    interface RotateTitleSequenceCommand {
2615        type: "rotate";
2616        rotations: number;
2617    }
2618
2619    interface ZoomTitleSequenceCommand {
2620        type: "zoom";
2621        zoom: number;
2622    }
2623
2624    interface FollowTitleSequenceCommand {
2625        type: "follow";
2626        id: number | null;
2627    }
2628
2629    interface SpeedTitleSequenceCommand {
2630        type: "speed";
2631        speed: number;
2632    }
2633
2634    interface WaitTitleSequenceCommand {
2635        type: "wait";
2636        duration: number;
2637    }
2638
2639    interface LoadScenarioTitleSequenceCommand {
2640        type: "loadsc";
2641        scenario: string;
2642    }
2643
2644    interface RestartTitleSequenceCommand {
2645        type: "restart";
2646    }
2647
2648    interface EndTitleSequenceCommand {
2649        type: "end";
2650    }
2651
2652    type TitleSequenceCommand =
2653        LoadTitleSequenceCommand |
2654        LocationTitleSequenceCommand |
2655        RotateTitleSequenceCommand |
2656        ZoomTitleSequenceCommand |
2657        FollowTitleSequenceCommand |
2658        SpeedTitleSequenceCommand |
2659        WaitTitleSequenceCommand |
2660        LoadScenarioTitleSequenceCommand |
2661        RestartTitleSequenceCommand |
2662        EndTitleSequenceCommand;
2663
2664    interface TitleSequenceManager {
2665        /**
2666         * Gets all the available title sequences.
2667         */
2668        readonly titleSequences: TitleSequence[];
2669
2670        /**
2671         * Creates a new blank title sequence.
2672         * @param name The name of the title sequence.
2673         */
2674        create(name: string): TitleSequence;
2675    }
2676}
2677