@adatechnology/game-vehicles-driving 0.3.13 → 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 +21 -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.js
CHANGED
|
@@ -637,9 +637,11 @@ var DEFAULT_CONTROL_KEYS = {
|
|
|
637
637
|
demist: ["Equal"],
|
|
638
638
|
siren: ["Semicolon"],
|
|
639
639
|
beacon: ["Quote"],
|
|
640
|
-
glovebox: ["Slash"]
|
|
640
|
+
glovebox: ["Slash"],
|
|
641
|
+
comm: ["BracketLeft"],
|
|
642
|
+
talk: ["Backslash"]
|
|
641
643
|
};
|
|
642
|
-
var HELD_KEYS = ["throttle", "brake", "left", "right", "handbrake", "horn", "clutch", "flash", "washer", "hotwire"];
|
|
644
|
+
var HELD_KEYS = ["throttle", "brake", "left", "right", "handbrake", "horn", "clutch", "flash", "washer", "hotwire", "talk"];
|
|
643
645
|
function createVehicleControls(options) {
|
|
644
646
|
const keys = { ...DEFAULT_CONTROL_KEYS, ...options.keys };
|
|
645
647
|
const auto4 = options.autoFourWheel ?? { slip: 0.18, releaseSeconds: 2 };
|
|
@@ -679,9 +681,11 @@ function createVehicleControls(options) {
|
|
|
679
681
|
siren: "off",
|
|
680
682
|
beacon: false,
|
|
681
683
|
beaconSide: 0,
|
|
682
|
-
glovebox: false
|
|
684
|
+
glovebox: false,
|
|
685
|
+
comm: { on: false, talking: false }
|
|
683
686
|
};
|
|
684
687
|
const hasKey = options.hasKey !== false;
|
|
688
|
+
const hasComm = options.commRadio ?? !!options.emergency;
|
|
685
689
|
const hotwireSeconds = Math.max(0.1, options.hotwireSeconds ?? 8);
|
|
686
690
|
const beaconHz = options.beaconHz ?? 2.5;
|
|
687
691
|
let beaconClock = 0;
|
|
@@ -813,6 +817,14 @@ function createVehicleControls(options) {
|
|
|
813
817
|
case "glovebox":
|
|
814
818
|
state.glovebox = !state.glovebox;
|
|
815
819
|
break;
|
|
820
|
+
case "comm":
|
|
821
|
+
if (!hasComm) return emit({ type: "refused", command: c, reason: "no_comm_radio" });
|
|
822
|
+
state.comm.on = !state.comm.on;
|
|
823
|
+
if (!state.comm.on && state.comm.talking) {
|
|
824
|
+
state.comm.talking = false;
|
|
825
|
+
emit({ type: "transmit", on: false });
|
|
826
|
+
}
|
|
827
|
+
break;
|
|
816
828
|
}
|
|
817
829
|
emit({ type: "command", command: c, state });
|
|
818
830
|
};
|
|
@@ -872,6 +884,11 @@ function createVehicleControls(options) {
|
|
|
872
884
|
state.horn = any(keys.horn);
|
|
873
885
|
state.lamps.flash = any(keys.flash);
|
|
874
886
|
state.washer = any(keys.washer);
|
|
887
|
+
const talking = state.comm.on && any(keys.talk);
|
|
888
|
+
if (talking !== state.comm.talking) {
|
|
889
|
+
state.comm.talking = talking;
|
|
890
|
+
emit({ type: "transmit", on: talking });
|
|
891
|
+
}
|
|
875
892
|
state.clutch = ease(state.clutch, any(keys.clutch) ? 1 : 0, any(keys.clutch) ? 8 : 2.5, dt);
|
|
876
893
|
const speed = driver?.state.u ?? 0;
|
|
877
894
|
lastSpeed = speed;
|
|
@@ -924,6 +941,7 @@ function createVehicleControls(options) {
|
|
|
924
941
|
release() {
|
|
925
942
|
held.clear();
|
|
926
943
|
throttle = brake = steer = 0;
|
|
944
|
+
state.comm.talking = false;
|
|
927
945
|
state.horn = false;
|
|
928
946
|
state.lamps.flash = false;
|
|
929
947
|
state.washer = false;
|