@sagl/server 0.0.0-stage → 0.1.0-next.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +61 -2
- package/dist/actions.d.ts +46 -0
- package/dist/actions.js +80 -0
- package/dist/actions.js.map +1 -0
- package/dist/animations.d.ts +32 -0
- package/dist/animations.js +95 -0
- package/dist/animations.js.map +1 -0
- package/dist/audio.d.ts +180 -0
- package/dist/audio.js +353 -0
- package/dist/audio.js.map +1 -0
- package/dist/audio_effects.d.ts +219 -0
- package/dist/audio_effects.js +84 -0
- package/dist/audio_effects.js.map +1 -0
- package/dist/camera.d.ts +188 -0
- package/dist/camera.js +247 -0
- package/dist/camera.js.map +1 -0
- package/dist/claims.d.ts +27 -0
- package/dist/claims.js +48 -0
- package/dist/claims.js.map +1 -0
- package/dist/commands.d.ts +135 -0
- package/dist/commands.js +373 -0
- package/dist/commands.js.map +1 -0
- package/dist/console.d.ts +21 -0
- package/dist/console.js +100 -0
- package/dist/console.js.map +1 -0
- package/dist/constants.d.ts +654 -0
- package/dist/constants.js +657 -0
- package/dist/constants.js.map +1 -0
- package/dist/cutscene.d.ts +47 -0
- package/dist/cutscene.js +190 -0
- package/dist/cutscene.js.map +1 -0
- package/dist/draw.d.ts +106 -0
- package/dist/draw.js +132 -0
- package/dist/draw.js.map +1 -0
- package/dist/effects.d.ts +91 -0
- package/dist/effects.js +116 -0
- package/dist/effects.js.map +1 -0
- package/dist/gangzones.d.ts +47 -0
- package/dist/gangzones.js +122 -0
- package/dist/gangzones.js.map +1 -0
- package/dist/geo.d.ts +11 -0
- package/dist/geo.js +25 -0
- package/dist/geo.js.map +1 -0
- package/dist/hud.d.ts +159 -0
- package/dist/hud.js +247 -0
- package/dist/hud.js.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/interaction.d.ts +81 -0
- package/dist/interaction.js +143 -0
- package/dist/interaction.js.map +1 -0
- package/dist/junctions.d.ts +1 -0
- package/dist/junctions.js +330 -0
- package/dist/junctions.js.map +1 -0
- package/dist/map.d.ts +55 -0
- package/dist/map.js +71 -0
- package/dist/map.js.map +1 -0
- package/dist/menu.d.ts +96 -0
- package/dist/menu.js +129 -0
- package/dist/menu.js.map +1 -0
- package/dist/mission.d.ts +482 -0
- package/dist/mission.js +1258 -0
- package/dist/mission.js.map +1 -0
- package/dist/models.d.ts +56 -0
- package/dist/models.js +71 -0
- package/dist/models.js.map +1 -0
- package/dist/modshop.d.ts +229 -0
- package/dist/modshop.js +904 -0
- package/dist/modshop.js.map +1 -0
- package/dist/modshop_data.d.ts +44 -0
- package/dist/modshop_data.js +287 -0
- package/dist/modshop_data.js.map +1 -0
- package/dist/native.d.ts +809 -0
- package/dist/native.js +27 -0
- package/dist/native.js.map +1 -0
- package/dist/objects.d.ts +249 -0
- package/dist/objects.js +455 -0
- package/dist/objects.js.map +1 -0
- package/dist/paint.d.ts +124 -0
- package/dist/paint.js +84 -0
- package/dist/paint.js.map +1 -0
- package/dist/paynspray.d.ts +44 -0
- package/dist/paynspray.js +177 -0
- package/dist/paynspray.js.map +1 -0
- package/dist/ped.d.ts +335 -0
- package/dist/ped.js +536 -0
- package/dist/ped.js.map +1 -0
- package/dist/player.d.ts +685 -0
- package/dist/player.js +1163 -0
- package/dist/player.js.map +1 -0
- package/dist/screeneffects.d.ts +99 -0
- package/dist/screeneffects.js +257 -0
- package/dist/screeneffects.js.map +1 -0
- package/dist/scripts.d.ts +69 -0
- package/dist/scripts.js +125 -0
- package/dist/scripts.js.map +1 -0
- package/dist/server.d.ts +713 -0
- package/dist/server.js +1080 -0
- package/dist/server.js.map +1 -0
- package/dist/shopblips.d.ts +9 -0
- package/dist/shopblips.js +30 -0
- package/dist/shopblips.js.map +1 -0
- package/dist/special.d.ts +33 -0
- package/dist/special.js +26 -0
- package/dist/special.js.map +1 -0
- package/dist/splash.d.ts +42 -0
- package/dist/splash.js +55 -0
- package/dist/splash.js.map +1 -0
- package/dist/text.d.ts +19 -0
- package/dist/text.js +25 -0
- package/dist/text.js.map +1 -0
- package/dist/ui.d.ts +141 -0
- package/dist/ui.js +243 -0
- package/dist/ui.js.map +1 -0
- package/dist/vehicle.d.ts +306 -0
- package/dist/vehicle.js +612 -0
- package/dist/vehicle.js.map +1 -0
- package/dist/vehiclecolors.d.ts +26 -0
- package/dist/vehiclecolors.js +49 -0
- package/dist/vehiclecolors.js.map +1 -0
- package/dist/world.d.ts +222 -0
- package/dist/world.js +227 -0
- package/dist/world.js.map +1 -0
- package/dist/zone.d.ts +89 -0
- package/dist/zone.js +140 -0
- package/dist/zone.js.map +1 -0
- package/package.json +33 -4
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { CAR_COLORS } from "./modshop_data.js";
|
|
2
|
+
/**
|
|
3
|
+
* Car colours: the game's (0-127) and your own (`server.vehicleColors`).
|
|
4
|
+
* Add a colour of your own and you get an id, 128 up, that works anywhere
|
|
5
|
+
* a colour does: `vehicle.colors`, `createVehicle`, the mod shops' colour
|
|
6
|
+
* grid (where yours are added by default).
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* const teal = server.vehicleColors.add(0x00a8a8);
|
|
10
|
+
* vehicle.colors = [teal, 1];
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export class VehicleColors {
|
|
14
|
+
#native;
|
|
15
|
+
#players;
|
|
16
|
+
#custom = [];
|
|
17
|
+
/** @internal */
|
|
18
|
+
constructor(native, players) {
|
|
19
|
+
this.#native = native;
|
|
20
|
+
this.#players = players;
|
|
21
|
+
}
|
|
22
|
+
/** Adds a colour (0xRRGGBB) and gives its id (128 up; the same colour twice: the same id). At most 128. */
|
|
23
|
+
add(rgb) {
|
|
24
|
+
const c = rgb & 0xffffff;
|
|
25
|
+
const at = this.#custom.indexOf(c);
|
|
26
|
+
if (at >= 0)
|
|
27
|
+
return 128 + at;
|
|
28
|
+
if (this.#custom.length >= 128)
|
|
29
|
+
throw new RangeError("at most 128 colours of your own");
|
|
30
|
+
this.#custom.push(c);
|
|
31
|
+
for (const p of this.#players())
|
|
32
|
+
this.joined(p);
|
|
33
|
+
return 127 + this.#custom.length;
|
|
34
|
+
}
|
|
35
|
+
/** Your colours' ids, in order. */
|
|
36
|
+
get custom() {
|
|
37
|
+
return this.#custom.map((_, i) => 128 + i);
|
|
38
|
+
}
|
|
39
|
+
/** A colour id's 0xRRGGBB (the game's or yours), or undefined. */
|
|
40
|
+
rgb(id) {
|
|
41
|
+
return id < 128 ? CAR_COLORS[id] : this.#custom[id - 128];
|
|
42
|
+
}
|
|
43
|
+
/** @internal A player joined: they get yours. */
|
|
44
|
+
joined(player) {
|
|
45
|
+
if (player.connected && this.#custom.length)
|
|
46
|
+
this.#native.vehiclePalette(player.id, this.#custom);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=vehiclecolors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vehiclecolors.js","sourceRoot":"","sources":["../src/vehiclecolors.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C;;;;;;;;;;GAUG;AACH,MAAM,OAAO,aAAa;IACxB,OAAO,CAAe;IACtB,QAAQ,CAAiB;IACzB,OAAO,GAAa,EAAE,CAAC;IAEvB,gBAAgB;IAChB,YAAY,MAAoB,EAAE,OAAuB;QACvD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED,2GAA2G;IAC3G,GAAG,CAAC,GAAW;QACb,MAAM,CAAC,GAAG,GAAG,GAAG,QAAQ,CAAC;QACzB,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACnC,IAAI,EAAE,IAAI,CAAC;YAAE,OAAO,GAAG,GAAG,EAAE,CAAC;QAC7B,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,GAAG;YAAE,MAAM,IAAI,UAAU,CAAC,iCAAiC,CAAC,CAAC;QACxF,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACrB,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE;YAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAChD,OAAO,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IACnC,CAAC;IAED,mCAAmC;IACnC,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;IAC7C,CAAC;IAED,kEAAkE;IAClE,GAAG,CAAC,EAAU;QACZ,OAAO,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC;IAC5D,CAAC;IAED,iDAAiD;IACjD,MAAM,CAAC,MAAc;QACnB,IAAI,MAAM,CAAC,SAAS,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM;YAAE,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACpG,CAAC;CACF"}
|
package/dist/world.d.ts
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import type { NativeServer } from "./native.js";
|
|
2
|
+
import type { Vector3 } from "./player.js";
|
|
3
|
+
/** The game's weather types (eWeatherType). */
|
|
4
|
+
export declare const Weather: {
|
|
5
|
+
readonly ExtraSunnyLA: 0;
|
|
6
|
+
readonly SunnyLA: 1;
|
|
7
|
+
readonly ExtraSunnySmogLA: 2;
|
|
8
|
+
readonly SunnySmogLA: 3;
|
|
9
|
+
readonly CloudyLA: 4;
|
|
10
|
+
readonly SunnySF: 5;
|
|
11
|
+
readonly ExtraSunnySF: 6;
|
|
12
|
+
readonly CloudySF: 7;
|
|
13
|
+
readonly RainySF: 8;
|
|
14
|
+
readonly FoggySF: 9;
|
|
15
|
+
readonly SunnyVegas: 10;
|
|
16
|
+
readonly ExtraSunnyVegas: 11;
|
|
17
|
+
readonly CloudyVegas: 12;
|
|
18
|
+
readonly ExtraSunnyCountryside: 13;
|
|
19
|
+
readonly SunnyCountryside: 14;
|
|
20
|
+
readonly CloudyCountryside: 15;
|
|
21
|
+
readonly RainyCountryside: 16;
|
|
22
|
+
readonly ExtraSunnyDesert: 17;
|
|
23
|
+
readonly SunnyDesert: 18;
|
|
24
|
+
readonly SandstormDesert: 19;
|
|
25
|
+
readonly Underwater: 20;
|
|
26
|
+
readonly ExtraColours1: 21;
|
|
27
|
+
readonly ExtraColours2: 22;
|
|
28
|
+
/** Each player's game runs its own weather cycle (not synced). */
|
|
29
|
+
readonly GameCycle: -1;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* A virtual world's settings. Worlds share world 0's time and weather until
|
|
33
|
+
* given their own: setting `time` or `weather` here (on any world but 0)
|
|
34
|
+
* starts it off from world 0's; `synced = true` makes it follow world 0
|
|
35
|
+
* again.
|
|
36
|
+
*/
|
|
37
|
+
/** A world's ambient population (`world.population`, `server.population`). */
|
|
38
|
+
export interface Population {
|
|
39
|
+
/** Ambient peds on foot. */
|
|
40
|
+
peds: boolean;
|
|
41
|
+
/** Ambient vehicles with their drivers. */
|
|
42
|
+
traffic: boolean;
|
|
43
|
+
/** 1 is single-player's; 0-3. */
|
|
44
|
+
density: number;
|
|
45
|
+
/** Gang members and gang cars, in their territories. */
|
|
46
|
+
gangs: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Cops: patrolling, and responding to a wanted player (whatever made them
|
|
49
|
+
* wanted: the game's crime rules, or the gamemode). Off, no cop ever
|
|
50
|
+
* appears, wanted or not. Default off; works with peds and traffic off.
|
|
51
|
+
*/
|
|
52
|
+
police: boolean;
|
|
53
|
+
/** Medics and ambulances, sent to the injured as in single-player. Default off. */
|
|
54
|
+
ambulance: boolean;
|
|
55
|
+
/** Firemen and fire trucks, sent to fires as in single-player. Default off. */
|
|
56
|
+
fire: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Crimes make players wanted, as in single-player (the game raises their
|
|
59
|
+
* wanted level, and lowers it as they lose the cops; `wantedLevel` can
|
|
60
|
+
* refuse or change it). Off: wanted levels are only what the gamemode
|
|
61
|
+
* sets. Default off.
|
|
62
|
+
*/
|
|
63
|
+
wanted: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Losing the cops: with no police (cops or their vehicles) within
|
|
66
|
+
* `evadeDistance` m (default 60) for this many seconds, a star goes, and
|
|
67
|
+
* so on for the next. 0 (the default): only as the game's own rules
|
|
68
|
+
* allow, under which a city never lets more than one star go (that takes
|
|
69
|
+
* a Pay 'n' Spray).
|
|
70
|
+
*/
|
|
71
|
+
evadeSeconds: number;
|
|
72
|
+
evadeDistance: number;
|
|
73
|
+
/**
|
|
74
|
+
* Ambient drivers (and server peds driving) signal their turns with their
|
|
75
|
+
* indicators, and put their hazards on when their car's broken down.
|
|
76
|
+
* Default on.
|
|
77
|
+
*/
|
|
78
|
+
indicators: boolean;
|
|
79
|
+
}
|
|
80
|
+
/** A traffic light: for pedestrians, `"yellow"` is the flashing "don't walk". `"off"` and `"flashing"` (yellow) let cars through. */
|
|
81
|
+
export type TrafficLight = "green" | "yellow" | "red" | "off" | "flashing";
|
|
82
|
+
/** Every traffic light, by the way it faces: SA's lights are all one of these two, plus the crossings. */
|
|
83
|
+
export interface TrafficLightStates {
|
|
84
|
+
northSouth: TrafficLight;
|
|
85
|
+
eastWest: TrafficLight;
|
|
86
|
+
pedestrians: TrafficLight;
|
|
87
|
+
}
|
|
88
|
+
/** How long each part of the lights' round lasts (ms). */
|
|
89
|
+
export interface TrafficLightTiming {
|
|
90
|
+
/** Each direction's green. Default 10000. */
|
|
91
|
+
green: number;
|
|
92
|
+
/** Each direction's yellow. Default 2000. */
|
|
93
|
+
yellow: number;
|
|
94
|
+
/** Pedestrians' walk (every car waits). Default 6766. */
|
|
95
|
+
walk: number;
|
|
96
|
+
/** Then their flashing "don't walk". Default 2002. */
|
|
97
|
+
flashing: number;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* A world's traffic lights (`world.trafficLights`, `server.trafficLights`
|
|
101
|
+
* for world 0's), the same for everyone in it: the lights change together
|
|
102
|
+
* on every screen, and traffic stops for them alike. SA's lights all run
|
|
103
|
+
* on one round: north-south green, then yellow, then east-west's, then
|
|
104
|
+
* every car waits while pedestrians cross. They go as the world's time and
|
|
105
|
+
* weather do: changing them in a world without its own gives it its own.
|
|
106
|
+
*
|
|
107
|
+
* ```ts
|
|
108
|
+
* server.trafficLights.timing = { green: 15000 }; // longer greens
|
|
109
|
+
* server.trafficLights.freeze(); // held as they are
|
|
110
|
+
* server.trafficLights.set({ northSouth: "green", eastWest: "red" });
|
|
111
|
+
* server.trafficLights.set({ northSouth: "flashing", eastWest: "flashing" }); // out of order
|
|
112
|
+
* server.trafficLights.resume(); // the round goes on
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
export declare class TrafficLights {
|
|
116
|
+
#private;
|
|
117
|
+
/** @internal */
|
|
118
|
+
constructor(native: NativeServer, world: number);
|
|
119
|
+
/** The lights now. */
|
|
120
|
+
get state(): TrafficLightStates;
|
|
121
|
+
/** Held (by `freeze` or `set`), not going round. */
|
|
122
|
+
get frozen(): boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Whether a vehicle (or anything facing `heading` at `position`) is at a
|
|
125
|
+
* red light: within `radius` m (default 25) of a junction with lights,
|
|
126
|
+
* and the lights its way red or amber. Its way is by its heading: north
|
|
127
|
+
* or south, else east or west.
|
|
128
|
+
*
|
|
129
|
+
* ```ts
|
|
130
|
+
* if (car.speed < 0.5 && server.trafficLights.isRedFor(car)) ...
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
isRedFor(what: {
|
|
134
|
+
position: Vector3;
|
|
135
|
+
heading: number;
|
|
136
|
+
}, radius?: number): boolean;
|
|
137
|
+
/** Holds them as they are now. */
|
|
138
|
+
freeze(): void;
|
|
139
|
+
/** Holds them, these as given (the rest as they are now). */
|
|
140
|
+
set(states: Partial<TrafficLightStates>): void;
|
|
141
|
+
/** Back to going round, from where they were held. */
|
|
142
|
+
resume(): void;
|
|
143
|
+
/** The round's timing (ms); setting some keeps the rest. Each at least 500. */
|
|
144
|
+
get timing(): TrafficLightTiming;
|
|
145
|
+
set timing(timing: Partial<TrafficLightTiming>);
|
|
146
|
+
}
|
|
147
|
+
export declare class World {
|
|
148
|
+
#private;
|
|
149
|
+
readonly id: number;
|
|
150
|
+
/** @internal Created by Server.world(). */
|
|
151
|
+
constructor(nativeServer: NativeServer, id: number);
|
|
152
|
+
/**
|
|
153
|
+
* Its ambient population: peds on foot and traffic as in single-player,
|
|
154
|
+
* shared by everyone in it, and what's allowed in it (gangs, police,
|
|
155
|
+
* ambulances, fire trucks). Off by default; worlds without their own
|
|
156
|
+
* settings use world 0's. Setting only some fields keeps the rest.
|
|
157
|
+
*/
|
|
158
|
+
get population(): Population;
|
|
159
|
+
set population(settings: Partial<Population>);
|
|
160
|
+
/** Follows world 0's time and weather (always true for world 0 itself). */
|
|
161
|
+
get synced(): boolean;
|
|
162
|
+
set synced(synced: boolean);
|
|
163
|
+
get time(): {
|
|
164
|
+
hour: number;
|
|
165
|
+
minute: number;
|
|
166
|
+
frozen: boolean;
|
|
167
|
+
};
|
|
168
|
+
set time(value: {
|
|
169
|
+
hour: number;
|
|
170
|
+
minute: number;
|
|
171
|
+
});
|
|
172
|
+
freezeTime(): void;
|
|
173
|
+
unfreezeTime(): void;
|
|
174
|
+
/** `Weather` (0-22), or `Weather.GameCycle`. */
|
|
175
|
+
get weather(): number;
|
|
176
|
+
set weather(weather: number);
|
|
177
|
+
/** Its traffic lights (world 0's until it has its own, as its time and weather). */
|
|
178
|
+
get trafficLights(): TrafficLights;
|
|
179
|
+
/** Lets this world see `target` (one way); see `server.setWorldView`. */
|
|
180
|
+
view(target: number, visible?: boolean): void;
|
|
181
|
+
}
|
|
182
|
+
/** Cull zone attribute flags (eZoneAttributes). */
|
|
183
|
+
export declare const ZoneAttribute: {
|
|
184
|
+
readonly CameraCloseIn: 1;
|
|
185
|
+
readonly CameraStairs: 2;
|
|
186
|
+
readonly FirstPersonBoats: 4;
|
|
187
|
+
readonly NoRain: 8;
|
|
188
|
+
readonly NoPolice: 16;
|
|
189
|
+
readonly PoliceAbandonCars: 256;
|
|
190
|
+
readonly InRoomForAudio: 512;
|
|
191
|
+
readonly FewerPeds: 1024;
|
|
192
|
+
readonly MilitaryZone: 4096;
|
|
193
|
+
readonly ExtraAirResistance: 16384;
|
|
194
|
+
readonly FewerCars: 32768;
|
|
195
|
+
};
|
|
196
|
+
/** Game audio zone ids for `createCullZone({ audio })`: interior music/ambience. */
|
|
197
|
+
export declare const AudioZone: {
|
|
198
|
+
readonly AmmuNation: 48;
|
|
199
|
+
readonly ClothesShop: 54;
|
|
200
|
+
readonly Barbers: 57;
|
|
201
|
+
readonly Gym: 59;
|
|
202
|
+
readonly GymOrBarbers: 61;
|
|
203
|
+
readonly Tattoo: 58;
|
|
204
|
+
readonly Diner: 44;
|
|
205
|
+
readonly FastFood: 44;
|
|
206
|
+
readonly Bar: 29;
|
|
207
|
+
readonly Casino: 17;
|
|
208
|
+
readonly StripClub: 66;
|
|
209
|
+
readonly PoliceStation: 39;
|
|
210
|
+
readonly Stadium: 41;
|
|
211
|
+
};
|
|
212
|
+
/** A server cull zone (`server.createCullZone`). */
|
|
213
|
+
export declare class CullZone {
|
|
214
|
+
#private;
|
|
215
|
+
readonly id: number;
|
|
216
|
+
/** @internal */
|
|
217
|
+
constructor(id: number, destroy: (zone: CullZone) => void);
|
|
218
|
+
get exists(): boolean;
|
|
219
|
+
/** @internal */
|
|
220
|
+
markDestroyed(): void;
|
|
221
|
+
destroy(): void;
|
|
222
|
+
}
|
package/dist/world.js
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { JUNCTIONS } from "./junctions.js";
|
|
2
|
+
/** The game's weather types (eWeatherType). */
|
|
3
|
+
export const Weather = {
|
|
4
|
+
ExtraSunnyLA: 0,
|
|
5
|
+
SunnyLA: 1,
|
|
6
|
+
ExtraSunnySmogLA: 2,
|
|
7
|
+
SunnySmogLA: 3,
|
|
8
|
+
CloudyLA: 4,
|
|
9
|
+
SunnySF: 5,
|
|
10
|
+
ExtraSunnySF: 6,
|
|
11
|
+
CloudySF: 7,
|
|
12
|
+
RainySF: 8,
|
|
13
|
+
FoggySF: 9,
|
|
14
|
+
SunnyVegas: 10,
|
|
15
|
+
ExtraSunnyVegas: 11,
|
|
16
|
+
CloudyVegas: 12,
|
|
17
|
+
ExtraSunnyCountryside: 13,
|
|
18
|
+
SunnyCountryside: 14,
|
|
19
|
+
CloudyCountryside: 15,
|
|
20
|
+
RainyCountryside: 16,
|
|
21
|
+
ExtraSunnyDesert: 17,
|
|
22
|
+
SunnyDesert: 18,
|
|
23
|
+
SandstormDesert: 19,
|
|
24
|
+
Underwater: 20,
|
|
25
|
+
ExtraColours1: 21,
|
|
26
|
+
ExtraColours2: 22,
|
|
27
|
+
/** Each player's game runs its own weather cycle (not synced). */
|
|
28
|
+
GameCycle: -1,
|
|
29
|
+
};
|
|
30
|
+
const TRAFFIC_LIGHTS = ["green", "yellow", "red", "off", "flashing"];
|
|
31
|
+
/**
|
|
32
|
+
* A world's traffic lights (`world.trafficLights`, `server.trafficLights`
|
|
33
|
+
* for world 0's), the same for everyone in it: the lights change together
|
|
34
|
+
* on every screen, and traffic stops for them alike. SA's lights all run
|
|
35
|
+
* on one round: north-south green, then yellow, then east-west's, then
|
|
36
|
+
* every car waits while pedestrians cross. They go as the world's time and
|
|
37
|
+
* weather do: changing them in a world without its own gives it its own.
|
|
38
|
+
*
|
|
39
|
+
* ```ts
|
|
40
|
+
* server.trafficLights.timing = { green: 15000 }; // longer greens
|
|
41
|
+
* server.trafficLights.freeze(); // held as they are
|
|
42
|
+
* server.trafficLights.set({ northSouth: "green", eastWest: "red" });
|
|
43
|
+
* server.trafficLights.set({ northSouth: "flashing", eastWest: "flashing" }); // out of order
|
|
44
|
+
* server.trafficLights.resume(); // the round goes on
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export class TrafficLights {
|
|
48
|
+
#native;
|
|
49
|
+
#world;
|
|
50
|
+
/** @internal */
|
|
51
|
+
constructor(native, world) {
|
|
52
|
+
this.#native = native;
|
|
53
|
+
this.#world = world;
|
|
54
|
+
}
|
|
55
|
+
/** The lights now. */
|
|
56
|
+
get state() {
|
|
57
|
+
const s = this.#native.trafficLights(this.#world);
|
|
58
|
+
return {
|
|
59
|
+
northSouth: TRAFFIC_LIGHTS[s.northSouth] ?? "red",
|
|
60
|
+
eastWest: TRAFFIC_LIGHTS[s.eastWest] ?? "red",
|
|
61
|
+
pedestrians: TRAFFIC_LIGHTS[s.pedestrians] ?? "red",
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/** Held (by `freeze` or `set`), not going round. */
|
|
65
|
+
get frozen() {
|
|
66
|
+
return this.#native.trafficLights(this.#world).fixed;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Whether a vehicle (or anything facing `heading` at `position`) is at a
|
|
70
|
+
* red light: within `radius` m (default 25) of a junction with lights,
|
|
71
|
+
* and the lights its way red or amber. Its way is by its heading: north
|
|
72
|
+
* or south, else east or west.
|
|
73
|
+
*
|
|
74
|
+
* ```ts
|
|
75
|
+
* if (car.speed < 0.5 && server.trafficLights.isRedFor(car)) ...
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
isRedFor(what, radius = 25) {
|
|
79
|
+
const at = what.position;
|
|
80
|
+
if (!JUNCTIONS.some(([x, y, z]) => Math.hypot(x - at.x, y - at.y) < radius && Math.abs(z - at.z) < 15))
|
|
81
|
+
return false;
|
|
82
|
+
const h = (what.heading * Math.PI) / 180;
|
|
83
|
+
const northSouth = Math.abs(Math.cos(h)) > Math.abs(Math.sin(h));
|
|
84
|
+
const s = this.state;
|
|
85
|
+
const theirs = northSouth ? s.northSouth : s.eastWest;
|
|
86
|
+
return theirs === "red" || theirs === "yellow";
|
|
87
|
+
}
|
|
88
|
+
/** Holds them as they are now. */
|
|
89
|
+
freeze() {
|
|
90
|
+
this.#native.holdTrafficLights(this.#world);
|
|
91
|
+
}
|
|
92
|
+
/** Holds them, these as given (the rest as they are now). */
|
|
93
|
+
set(states) {
|
|
94
|
+
const light = (l) => {
|
|
95
|
+
if (l === undefined)
|
|
96
|
+
return -1;
|
|
97
|
+
const i = TRAFFIC_LIGHTS.indexOf(l);
|
|
98
|
+
if (i < 0)
|
|
99
|
+
throw new RangeError(`not a traffic light: ${l}`);
|
|
100
|
+
return i;
|
|
101
|
+
};
|
|
102
|
+
this.#native.setTrafficLights(light(states.northSouth), light(states.eastWest), light(states.pedestrians), this.#world);
|
|
103
|
+
}
|
|
104
|
+
/** Back to going round, from where they were held. */
|
|
105
|
+
resume() {
|
|
106
|
+
this.#native.resumeTrafficLights(this.#world);
|
|
107
|
+
}
|
|
108
|
+
/** The round's timing (ms); setting some keeps the rest. Each at least 500. */
|
|
109
|
+
get timing() {
|
|
110
|
+
return this.#native.trafficLights(this.#world).timing;
|
|
111
|
+
}
|
|
112
|
+
set timing(timing) {
|
|
113
|
+
const t = { ...this.timing, ...timing };
|
|
114
|
+
this.#native.setTrafficTiming(t.green, t.yellow, t.walk, t.flashing, this.#world);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
export class World {
|
|
118
|
+
id;
|
|
119
|
+
#native;
|
|
120
|
+
/** @internal Created by Server.world(). */
|
|
121
|
+
constructor(nativeServer, id) {
|
|
122
|
+
this.#native = nativeServer;
|
|
123
|
+
this.id = id;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Its ambient population: peds on foot and traffic as in single-player,
|
|
127
|
+
* shared by everyone in it, and what's allowed in it (gangs, police,
|
|
128
|
+
* ambulances, fire trucks). Off by default; worlds without their own
|
|
129
|
+
* settings use world 0's. Setting only some fields keeps the rest.
|
|
130
|
+
*/
|
|
131
|
+
get population() {
|
|
132
|
+
return this.#native.population(this.id);
|
|
133
|
+
}
|
|
134
|
+
set population(settings) {
|
|
135
|
+
this.#native.setPopulation(this.id, settings);
|
|
136
|
+
}
|
|
137
|
+
/** Follows world 0's time and weather (always true for world 0 itself). */
|
|
138
|
+
get synced() {
|
|
139
|
+
return this.id === 0 || this.#native.worldSynced(this.id);
|
|
140
|
+
}
|
|
141
|
+
set synced(synced) {
|
|
142
|
+
this.#native.setWorldSynced(this.id, synced);
|
|
143
|
+
}
|
|
144
|
+
get time() {
|
|
145
|
+
return this.#native.getTime(this.id);
|
|
146
|
+
}
|
|
147
|
+
set time(value) {
|
|
148
|
+
if (value.hour < 0 || value.hour > 23 || value.minute < 0 || value.minute > 59) {
|
|
149
|
+
throw new RangeError("time must be 00:00-23:59");
|
|
150
|
+
}
|
|
151
|
+
this.#native.setTime(value.hour, value.minute, this.id);
|
|
152
|
+
}
|
|
153
|
+
freezeTime() {
|
|
154
|
+
this.#native.freezeTime(true, this.id);
|
|
155
|
+
}
|
|
156
|
+
unfreezeTime() {
|
|
157
|
+
this.#native.freezeTime(false, this.id);
|
|
158
|
+
}
|
|
159
|
+
/** `Weather` (0-22), or `Weather.GameCycle`. */
|
|
160
|
+
get weather() {
|
|
161
|
+
return this.#native.getWeather(this.id);
|
|
162
|
+
}
|
|
163
|
+
set weather(weather) {
|
|
164
|
+
this.#native.setWeather(weather, this.id);
|
|
165
|
+
}
|
|
166
|
+
/** Its traffic lights (world 0's until it has its own, as its time and weather). */
|
|
167
|
+
get trafficLights() {
|
|
168
|
+
return new TrafficLights(this.#native, this.id);
|
|
169
|
+
}
|
|
170
|
+
/** Lets this world see `target` (one way); see `server.setWorldView`. */
|
|
171
|
+
view(target, visible = true) {
|
|
172
|
+
this.#native.setWorldView(this.id, target, visible);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/** Cull zone attribute flags (eZoneAttributes). */
|
|
176
|
+
export const ZoneAttribute = {
|
|
177
|
+
CameraCloseIn: 0x1,
|
|
178
|
+
CameraStairs: 0x2,
|
|
179
|
+
FirstPersonBoats: 0x4,
|
|
180
|
+
NoRain: 0x8,
|
|
181
|
+
NoPolice: 0x10,
|
|
182
|
+
PoliceAbandonCars: 0x100,
|
|
183
|
+
InRoomForAudio: 0x200,
|
|
184
|
+
FewerPeds: 0x400,
|
|
185
|
+
MilitaryZone: 0x1000,
|
|
186
|
+
ExtraAirResistance: 0x4000,
|
|
187
|
+
FewerCars: 0x8000,
|
|
188
|
+
};
|
|
189
|
+
/** Game audio zone ids for `createCullZone({ audio })`: interior music/ambience. */
|
|
190
|
+
export const AudioZone = {
|
|
191
|
+
AmmuNation: 48,
|
|
192
|
+
ClothesShop: 54,
|
|
193
|
+
Barbers: 57,
|
|
194
|
+
Gym: 59,
|
|
195
|
+
GymOrBarbers: 61,
|
|
196
|
+
Tattoo: 58,
|
|
197
|
+
Diner: 44,
|
|
198
|
+
FastFood: 44,
|
|
199
|
+
Bar: 29,
|
|
200
|
+
Casino: 17,
|
|
201
|
+
StripClub: 66,
|
|
202
|
+
PoliceStation: 39,
|
|
203
|
+
Stadium: 41,
|
|
204
|
+
};
|
|
205
|
+
/** A server cull zone (`server.createCullZone`). */
|
|
206
|
+
export class CullZone {
|
|
207
|
+
id;
|
|
208
|
+
#destroy;
|
|
209
|
+
#exists = true;
|
|
210
|
+
/** @internal */
|
|
211
|
+
constructor(id, destroy) {
|
|
212
|
+
this.id = id;
|
|
213
|
+
this.#destroy = destroy;
|
|
214
|
+
}
|
|
215
|
+
get exists() {
|
|
216
|
+
return this.#exists;
|
|
217
|
+
}
|
|
218
|
+
/** @internal */
|
|
219
|
+
markDestroyed() {
|
|
220
|
+
this.#exists = false;
|
|
221
|
+
}
|
|
222
|
+
destroy() {
|
|
223
|
+
if (this.#exists)
|
|
224
|
+
this.#destroy(this);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
//# sourceMappingURL=world.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"world.js","sourceRoot":"","sources":["../src/world.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,+CAA+C;AAC/C,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,YAAY,EAAE,CAAC;IACf,OAAO,EAAE,CAAC;IACV,gBAAgB,EAAE,CAAC;IACnB,WAAW,EAAE,CAAC;IACd,QAAQ,EAAE,CAAC;IACX,OAAO,EAAE,CAAC;IACV,YAAY,EAAE,CAAC;IACf,QAAQ,EAAE,CAAC;IACX,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,CAAC;IACV,UAAU,EAAE,EAAE;IACd,eAAe,EAAE,EAAE;IACnB,WAAW,EAAE,EAAE;IACf,qBAAqB,EAAE,EAAE;IACzB,gBAAgB,EAAE,EAAE;IACpB,iBAAiB,EAAE,EAAE;IACrB,gBAAgB,EAAE,EAAE;IACpB,gBAAgB,EAAE,EAAE;IACpB,WAAW,EAAE,EAAE;IACf,eAAe,EAAE,EAAE;IACnB,UAAU,EAAE,EAAE;IACd,aAAa,EAAE,EAAE;IACjB,aAAa,EAAE,EAAE;IACjB,kEAAkE;IAClE,SAAS,EAAE,CAAC,CAAC;CACL,CAAC;AAsDX,MAAM,cAAc,GAAmB,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;AAqBrF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,aAAa;IACxB,OAAO,CAAe;IACtB,MAAM,CAAS;IAEf,gBAAgB;IAChB,YAAY,MAAoB,EAAE,KAAa;QAC7C,I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AiB,EAAE,KAAK;IACxB,cAAc,EAAE,KAAK;IACrB,SAAS,EAAE,KAAK;IAChB,YAAY,EAAE,MAAM;IACpB,kBAAkB,EAAE,MAAM;IAC1B,SAAS,EAAE,MAAM;CACT,CAAC;AAEX,oFAAoF;AACpF,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,UAAU,EAAE,EAAE;IACd,WAAW,EAAE,EAAE;IACf,OAAO,EAAE,EAAE;IACX,GAAG,EAAE,EAAE;IACP,YAAY,EAAE,EAAE;IAChB,MAAM,EAAE,EAAE;IACV,KAAK,EAAE,EAAE;IACT,QAAQ,EAAE,EAAE;IACZ,GAAG,EAAE,EAAE;IACP,MAAM,EAAE,EAAE;IACV,SAAS,EAAE,EAAE;IACb,aAAa,EAAE,EAAE;IACjB,OAAO,EAAE,EAAE;CACH,CAAC;AAEX,oDAAoD;AACpD,MAAM,OAAO,QAAQ;IACV,EAAE,CAAS;IACpB,QAAQ,CAA2B;IACnC,OAAO,GAAG,IAAI,CAAC;IAEf,gBAAgB;IAChB,YAAY,EAAU,EAAE,OAAiC;QACvD,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,gBAAgB;IAChB,aAAa;QACX,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;IACvB,CAAC;IAED,OAAO;QACL,IAAI,IAAI,CAAC,OAAO;YAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;CACF"}
|
package/dist/zone.d.ts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { NativeServer } from "./native.js";
|
|
2
|
+
import type { Vector3 } from "./player.js";
|
|
3
|
+
/** The game's garage types (as the map files define them). */
|
|
4
|
+
export declare const GarageType: {
|
|
5
|
+
readonly Mission: 1;
|
|
6
|
+
readonly BombShopTimed: 2;
|
|
7
|
+
readonly BombShopEngine: 3;
|
|
8
|
+
readonly BombShopRemote: 4;
|
|
9
|
+
readonly PayNSpray: 5;
|
|
10
|
+
readonly SafehouseGanton: 16;
|
|
11
|
+
readonly SafehouseSantaMaria: 17;
|
|
12
|
+
readonly SafehouseRockshore: 18;
|
|
13
|
+
readonly ImpoundLS: 33;
|
|
14
|
+
readonly ImpoundSF: 34;
|
|
15
|
+
readonly ImpoundLV: 35;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* An area the server watches players against, firing `zoneEnter`,
|
|
19
|
+
* `zoneLeave` and `zoneMove` (each position update while inside). Positions
|
|
20
|
+
* are the ones players sync, on foot or driving.
|
|
21
|
+
*/
|
|
22
|
+
export declare class Zone {
|
|
23
|
+
#private;
|
|
24
|
+
readonly id: number;
|
|
25
|
+
/** The garage this zone covers, for the built-in garage zones. */
|
|
26
|
+
readonly garage: Garage | null;
|
|
27
|
+
/** Free-form storage for gamemode data. */
|
|
28
|
+
readonly data: Record<string, unknown>;
|
|
29
|
+
/** @internal Created by Server. */
|
|
30
|
+
constructor(id: number, garage: Garage | null, destroy: (zone: Zone) => void);
|
|
31
|
+
get exists(): boolean;
|
|
32
|
+
/** @internal */
|
|
33
|
+
markDestroyed(): void;
|
|
34
|
+
/** Stops watching it (no leave events are sent). */
|
|
35
|
+
destroy(): void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* One of the game's garages: a door the server opens and closes for
|
|
39
|
+
* everyone, and a zone over its floor. Players' games run none of the
|
|
40
|
+
* garage's own logic (no Pay 'n' Spray, safehouse storage, ...): build that
|
|
41
|
+
* from `zoneEnter` on `garage.zone`.
|
|
42
|
+
*/
|
|
43
|
+
export declare class Garage {
|
|
44
|
+
#private;
|
|
45
|
+
readonly id: number;
|
|
46
|
+
/** As in the map files; not unique. */
|
|
47
|
+
readonly name: string;
|
|
48
|
+
/** See `GarageType`. */
|
|
49
|
+
readonly type: number;
|
|
50
|
+
readonly position: Vector3;
|
|
51
|
+
zone: Zone;
|
|
52
|
+
/** @internal Created by Server. */
|
|
53
|
+
constructor(nativeServer: NativeServer, state: {
|
|
54
|
+
id: number;
|
|
55
|
+
name: string;
|
|
56
|
+
type: number;
|
|
57
|
+
x: number;
|
|
58
|
+
y: number;
|
|
59
|
+
z: number;
|
|
60
|
+
open: boolean;
|
|
61
|
+
frontX: number;
|
|
62
|
+
frontY: number;
|
|
63
|
+
sideX: number;
|
|
64
|
+
sideY: number;
|
|
65
|
+
topZ: number;
|
|
66
|
+
});
|
|
67
|
+
/**
|
|
68
|
+
* Whether a spot is inside it, at least `margin` m from its walls (not
|
|
69
|
+
* the floor or roof): a car's position with a margin of half its length
|
|
70
|
+
* is a car wholly inside, as the game's garages check before shutting.
|
|
71
|
+
* A negative margin reaches that far outside.
|
|
72
|
+
*/
|
|
73
|
+
contains(at: Vector3, margin?: number): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* The spot `distance` m outside the wall nearest `at`, across from `at`
|
|
76
|
+
* (for where a car drove in: in front of the door), facing away from the
|
|
77
|
+
* garage: where to put a car driving out.
|
|
78
|
+
*/
|
|
79
|
+
outside(at: Vector3, distance?: number): {
|
|
80
|
+
position: Vector3;
|
|
81
|
+
heading: number;
|
|
82
|
+
};
|
|
83
|
+
/** Its floor's middle. */
|
|
84
|
+
get center(): Vector3;
|
|
85
|
+
get isOpen(): boolean;
|
|
86
|
+
open(): void;
|
|
87
|
+
close(): void;
|
|
88
|
+
toString(): string;
|
|
89
|
+
}
|