OpenRCT2/distribution/openrct2.d.ts

162 lines
3.4 KiB
TypeScript
Raw Normal View History

2018-03-17 19:37:46 +01:00
/*****************************************************************************
* Copyright (c) 2014-2018 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
// OpenRCT2 Scripting API definition file
2018-03-18 02:55:12 +01:00
// To enable IntelliSense for your scripts in Visual Studio or Visual Studio Code,
// add the following line to the top of your script and change the path appropriately.
//
// /// <reference path="/path/to/openrct2.d.ts" />
//
2018-03-17 19:37:46 +01:00
export interface Console {
2018-03-18 02:55:12 +01:00
clear(): void;
2018-03-17 19:37:46 +01:00
log(message?: any, ...optionalParams: any[]): void;
}
export interface Configuration {
getAll(pattern: string): { [name: string]: any };
get<T>(key: string): T | undefined;
get<T>(key: string, defaultValue: T): T;
set<T>(key: string, value: T): void;
has(key: string): boolean;
}
export interface Context {
/**
* The user's current configuration.
*/
configuration: Configuration;
2018-03-20 20:40:38 +01:00
/**
* Registers a new intent (command) that can be mapped to a shortcut.
*/
registerIntent(desc: IntentDesc);
2018-03-17 19:37:46 +01:00
/**
* Subscribes to the given hook.
*/
2018-03-19 00:35:58 +01:00
subscribe(hook: string, callback: Function): IDisposable;
}
2018-03-20 20:40:38 +01:00
export interface IntentDesc
{
key: string;
title?: string;
shortcut?: string;
action: Function;
}
2018-03-19 00:35:58 +01:00
export interface IDisposable {
dispose(): void;
2018-03-17 19:37:46 +01:00
}
2018-03-20 20:40:38 +01:00
export type TileElementType =
"surface" | "footpath-item";
export interface TileElement {
type: TileElementType;
zBase: number;
zClearance: number;
// footpath-item:
broken: boolean;
}
export interface Tile {
x: number;
y: number;
type: TileType;
elements: TileElement[];
}
2018-03-17 19:37:46 +01:00
export interface Ride {
name: string;
excitement: number;
intensity: number;
nausea: number;
totalCustomers: number;
}
2018-03-20 20:40:38 +01:00
export type TileElementType =
"car" | "duck" | "peep";
export interface Thing {
type: ThingType;
x: number;
y: number;
z: number;
// Peep
tshirt: number;
trousers: number;
}
2018-03-17 19:37:46 +01:00
export interface Map {
2018-03-20 20:40:38 +01:00
size: { x: number; y: number; };
rides: number;
things: number;
2018-03-17 19:37:46 +01:00
getRide(id: number): Ride;
2018-03-20 20:40:38 +01:00
getTile(x: number, y: number): Tile;
getThing(id: number): Thing;
2018-03-17 19:37:46 +01:00
}
export type ParkMessageType =
"attraction" | "peep_on_attraction" | "peep" | "money" | "blank" | "research" | "guests" | "award" | "chart";
export interface ParkMessage {
type: ParkMessageType;
text: string;
}
export interface Park {
cash: number;
rating: number;
bankLoan: number;
maxBankLoan: number;
postMessage(message: ParkMessage): void;
}
export interface Window {
id: number;
classification: string;
x: number;
y: number;
width: number;
height: number;
title: string;
}
export interface WindowDesc {
classification: string;
x?: number;
y?: number;
width: number;
height: number;
title: string;
id?: number;
}
export interface Ui {
openWindow(desc: WindowDesc): Window;
2018-03-18 02:55:12 +01:00
closeWindow(window: Window): void;
2018-03-17 19:37:46 +01:00
closeWindows(classification: string, id?: number): void;
closeAllWindows(): void;
}
2018-03-18 02:55:12 +01:00
declare global {
var console: Console;
var context: Context;
var map: Map;
var park: Park;
var ui: Ui;
}