rock-mod
Version:
Rock-Mod is a powerful framework designed for creating and managing mods for Grand Theft Auto (GTA) games.
48 lines (47 loc) • 2.6 kB
JavaScript
/// <reference types="@classic-mp/types/client" />
/**
* Реализация `IControlsManager` поверх натива-обёртки CCMP `ccmp.natives.pad.*`.
*
* Все четыре метода — прямой passthrough к соответствующим GTA V-нативам
* (`DISABLE_CONTROL_ACTION`, `IS_CONTROL_PRESSED`, `IS_DISABLED_CONTROL_PRESSED`,
* `GET_DISABLED_CONTROL_NORMAL`) с сохранением порядка аргументов:
*
* IControlsManager.disableControlAction(padIndex, control, disable)
* → ccmp.natives.pad.disableControlAction(padIndex, control, disable)
*
* Семантика и значения индексов идентичны RageMP — гейм-mod консьюмеры
* (`ControlsService` / `WeaponService.disableControlActions`) используют те
* же константы `Control.*` (см. `@shared/common/enums/Control`).
*
* **Hot path:** `disableControlAction` вызывается на каждый render-tick из
* `WeaponController.onRender`. CCMP-native — это синхронный вызов V8 op'а,
* стоимость порядка единиц микросекунд; никакой буферизации не нужно.
*
* Имена параметров `CcmpNativesPad.disableControlAction(control, action, ...)`
* **обманчивы** — это generic-renames из натив-генератора. Фактически первый
* аргумент — `padIndex` (0..2), второй — `control` (Control.*), третий —
* `disable: boolean`. См. https://docs.fivem.net/natives/?_0xFE99B66D43DA8E7B.
*/
export class CCMPControlsManager {
disableControlAction(padIndex, control, disable) {
ccmp.natives.pad.disableControlAction(padIndex, control, disable);
}
isDisabledControlPressed(padIndex, control) {
return ccmp.natives.pad.isDisabledControlPressed(padIndex, control);
}
isDisabledControlJustPressed(padIndex, control) {
return ccmp.natives.pad.isDisabledControlJustPressed(padIndex, control);
}
isControlPressed(padIndex, control) {
return ccmp.natives.pad.isControlPressed(padIndex, control);
}
isControlJustPressed(padIndex, control) {
return ccmp.natives.pad.isControlJustPressed(padIndex, control);
}
isControlJustReleased(padIndex, control) {
return ccmp.natives.pad.isControlJustReleased(padIndex, control);
}
getDisabledControlNormal(padIndex, control) {
return ccmp.natives.pad.getDisabledControlNormal(padIndex, control);
}
}