@adatechnology/game-vehicles-driving 0.3.12 → 0.4.0
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/dist/index.d.ts +16 -2
- package/dist/index.global.js +23 -3
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +21 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -496,7 +496,7 @@ declare const DEFAULT_CRUISE: CruiseOptions;
|
|
|
496
496
|
/** Gas cruise control asks for to hold `target` at `speed` (m/s); none above the target, the car coasts down to it. */
|
|
497
497
|
declare function cruiseThrottle(target: number, speed: number, options?: CruiseOptions): number;
|
|
498
498
|
|
|
499
|
-
type ControlCommand = 'ignition' | 'gearbox' | 'gear_up' | 'gear_down' | 'parking_brake' | 'drive_mode' | 'lights' | 'high_beam' | 'fog_lights' | 'interior_light' | 'alarm' | 'radio' | 'radio_source' | 'radio_track' | 'exit' | 'indicator_left' | 'indicator_right' | 'hazard' | 'wipers' | 'seatbelt' | 'drive_profile' | 'traction_control' | 'abs' | 'cruise' | 'climate' | 'demist' | 'siren' | 'beacon' | 'glovebox';
|
|
499
|
+
type ControlCommand = 'ignition' | 'gearbox' | 'gear_up' | 'gear_down' | 'parking_brake' | 'drive_mode' | 'lights' | 'high_beam' | 'fog_lights' | 'interior_light' | 'alarm' | 'radio' | 'radio_source' | 'radio_track' | 'exit' | 'indicator_left' | 'indicator_right' | 'hazard' | 'wipers' | 'seatbelt' | 'drive_profile' | 'traction_control' | 'abs' | 'cruise' | 'climate' | 'demist' | 'siren' | 'beacon' | 'comm' | 'glovebox';
|
|
500
500
|
type ControlKeyMap = {
|
|
501
501
|
readonly throttle: readonly string[];
|
|
502
502
|
readonly brake: readonly string[];
|
|
@@ -508,6 +508,8 @@ type ControlKeyMap = {
|
|
|
508
508
|
/** Flashes the high beam while held. */
|
|
509
509
|
readonly flash: readonly string[];
|
|
510
510
|
readonly washer: readonly string[];
|
|
511
|
+
/** The two-way radio's button on the microphone: it transmits while held (the set must be on). */
|
|
512
|
+
readonly talk: readonly string[];
|
|
511
513
|
/** Held without the key (`hasKey: false`): strips and joins the wires under the column until the engine turns over. */
|
|
512
514
|
readonly hotwire: readonly string[];
|
|
513
515
|
} & {
|
|
@@ -587,6 +589,11 @@ interface ControlState {
|
|
|
587
589
|
beaconSide: 0 | 1;
|
|
588
590
|
/** The glovebox lid is open. */
|
|
589
591
|
glovebox: boolean;
|
|
592
|
+
/** The two-way radio of an emergency vehicle: the set is on (it hisses and takes the calls of the net), and the driver transmits (the button held: the set is silent meanwhile). */
|
|
593
|
+
comm: {
|
|
594
|
+
on: boolean;
|
|
595
|
+
talking: boolean;
|
|
596
|
+
};
|
|
590
597
|
}
|
|
591
598
|
type ControlEvent = {
|
|
592
599
|
type: 'command';
|
|
@@ -595,10 +602,15 @@ type ControlEvent = {
|
|
|
595
602
|
} | {
|
|
596
603
|
type: 'refused';
|
|
597
604
|
command: ControlCommand;
|
|
598
|
-
reason: 'no_four_wheel_drive' | 'no_fog_lamps' | 'ignition_off' | 'battery_flat' | 'too_slow' | 'no_key' | 'no_siren';
|
|
605
|
+
reason: 'no_four_wheel_drive' | 'no_fog_lamps' | 'ignition_off' | 'battery_flat' | 'too_slow' | 'no_key' | 'no_siren' | 'no_comm_radio';
|
|
599
606
|
} | {
|
|
600
607
|
type: 'cruise_cancelled';
|
|
601
608
|
}
|
|
609
|
+
/** The two-way radio's button: down (the driver transmits) and let go of (the set listens again). */
|
|
610
|
+
| {
|
|
611
|
+
type: 'transmit';
|
|
612
|
+
on: boolean;
|
|
613
|
+
}
|
|
602
614
|
/** The wires under the column: stripped (first touch), joined (the ignition is live and the starter turns). */
|
|
603
615
|
| {
|
|
604
616
|
type: 'hotwire';
|
|
@@ -640,6 +652,8 @@ interface VehicleControlOptions {
|
|
|
640
652
|
hotwireSeconds?: number;
|
|
641
653
|
/** The vehicle has a siren and a beacon (an emergency vehicle). Default false: both refuse. */
|
|
642
654
|
emergency?: boolean;
|
|
655
|
+
/** The vehicle has a two-way radio (police, ambulance, fire). Default: as `emergency`. Without one `comm` refuses. */
|
|
656
|
+
commRadio?: boolean;
|
|
643
657
|
/** The beacon's sides swap this many times a second. Default 2.5. */
|
|
644
658
|
beaconHz?: number;
|
|
645
659
|
onEvent?: (event: ControlEvent) => void;
|
package/dist/index.global.js
CHANGED
|
@@ -236,6 +236,8 @@ var GameVehiclesDriving = (() => {
|
|
|
236
236
|
[DEFERRED_QUEUE_ID.DESTRUCTION_PREFIT]: { priority: 40, phase: "idle", minEveryFrames: 30 }
|
|
237
237
|
};
|
|
238
238
|
var MUST_DRAIN_QUEUE_IDS = /* @__PURE__ */ new Set([DEFERRED_QUEUE_ID.DESTRUCTION_EVENTS, DEFERRED_QUEUE_ID.BREACH_CUT]);
|
|
239
|
+
var BODY_FOAM_SURFACES = ["hands", "arms", "torso", "hair", "mouth"];
|
|
240
|
+
var WASH_SURFACES = [...BODY_FOAM_SURFACES, "brush"];
|
|
239
241
|
var WARNED_KEY = /* @__PURE__ */ Symbol.for("@adatechnology/game-contracts.warned");
|
|
240
242
|
var warnedKeys = () => {
|
|
241
243
|
const holder = globalThis;
|
|
@@ -843,9 +845,11 @@ var GameVehiclesDriving = (() => {
|
|
|
843
845
|
demist: ["Equal"],
|
|
844
846
|
siren: ["Semicolon"],
|
|
845
847
|
beacon: ["Quote"],
|
|
846
|
-
glovebox: ["Slash"]
|
|
848
|
+
glovebox: ["Slash"],
|
|
849
|
+
comm: ["BracketLeft"],
|
|
850
|
+
talk: ["Backslash"]
|
|
847
851
|
};
|
|
848
|
-
var HELD_KEYS = ["throttle", "brake", "left", "right", "handbrake", "horn", "clutch", "flash", "washer", "hotwire"];
|
|
852
|
+
var HELD_KEYS = ["throttle", "brake", "left", "right", "handbrake", "horn", "clutch", "flash", "washer", "hotwire", "talk"];
|
|
849
853
|
function createVehicleControls(options) {
|
|
850
854
|
const keys = { ...DEFAULT_CONTROL_KEYS, ...options.keys };
|
|
851
855
|
const auto4 = options.autoFourWheel ?? { slip: 0.18, releaseSeconds: 2 };
|
|
@@ -885,9 +889,11 @@ var GameVehiclesDriving = (() => {
|
|
|
885
889
|
siren: "off",
|
|
886
890
|
beacon: false,
|
|
887
891
|
beaconSide: 0,
|
|
888
|
-
glovebox: false
|
|
892
|
+
glovebox: false,
|
|
893
|
+
comm: { on: false, talking: false }
|
|
889
894
|
};
|
|
890
895
|
const hasKey = options.hasKey !== false;
|
|
896
|
+
const hasComm = options.commRadio ?? !!options.emergency;
|
|
891
897
|
const hotwireSeconds = Math.max(0.1, options.hotwireSeconds ?? 8);
|
|
892
898
|
const beaconHz = options.beaconHz ?? 2.5;
|
|
893
899
|
let beaconClock = 0;
|
|
@@ -1019,6 +1025,14 @@ var GameVehiclesDriving = (() => {
|
|
|
1019
1025
|
case "glovebox":
|
|
1020
1026
|
state.glovebox = !state.glovebox;
|
|
1021
1027
|
break;
|
|
1028
|
+
case "comm":
|
|
1029
|
+
if (!hasComm) return emit({ type: "refused", command: c, reason: "no_comm_radio" });
|
|
1030
|
+
state.comm.on = !state.comm.on;
|
|
1031
|
+
if (!state.comm.on && state.comm.talking) {
|
|
1032
|
+
state.comm.talking = false;
|
|
1033
|
+
emit({ type: "transmit", on: false });
|
|
1034
|
+
}
|
|
1035
|
+
break;
|
|
1022
1036
|
}
|
|
1023
1037
|
emit({ type: "command", command: c, state });
|
|
1024
1038
|
};
|
|
@@ -1078,6 +1092,11 @@ var GameVehiclesDriving = (() => {
|
|
|
1078
1092
|
state.horn = any(keys.horn);
|
|
1079
1093
|
state.lamps.flash = any(keys.flash);
|
|
1080
1094
|
state.washer = any(keys.washer);
|
|
1095
|
+
const talking = state.comm.on && any(keys.talk);
|
|
1096
|
+
if (talking !== state.comm.talking) {
|
|
1097
|
+
state.comm.talking = talking;
|
|
1098
|
+
emit({ type: "transmit", on: talking });
|
|
1099
|
+
}
|
|
1081
1100
|
state.clutch = ease(state.clutch, any(keys.clutch) ? 1 : 0, any(keys.clutch) ? 8 : 2.5, dt);
|
|
1082
1101
|
const speed = driver?.state.u ?? 0;
|
|
1083
1102
|
lastSpeed = speed;
|
|
@@ -1130,6 +1149,7 @@ var GameVehiclesDriving = (() => {
|
|
|
1130
1149
|
release() {
|
|
1131
1150
|
held.clear();
|
|
1132
1151
|
throttle = brake = steer = 0;
|
|
1152
|
+
state.comm.talking = false;
|
|
1133
1153
|
state.horn = false;
|
|
1134
1154
|
state.lamps.flash = false;
|
|
1135
1155
|
state.washer = false;
|