Skip to content

Commit 07b805b

Browse files
authored
Merge pull request #91 from ollymonger/feat/add-client-types-for-entity-overlays
chore: Add clientside graphics typings for entity overlays
2 parents f396129 + 35071e3 commit 07b805b

File tree

1 file changed

+178
-0
lines changed

1 file changed

+178
-0
lines changed

packages/client/game/graphics.d.ts

+178
Original file line numberDiff line numberDiff line change
@@ -1291,6 +1291,184 @@ declare interface GameGraphics extends GameGraphicsLegacy {
12911291
registerTextFontId(fontname: string): number;
12921292
setNumberPlateTexture(txDict: string, txName: string, txDictNormal: string, txNameNorma: string): void;
12931293
setParticleFxBloodScale(scale: number): void;
1294+
1295+
/**
1296+
* Returns a batch object for using overlays on entities.
1297+
* @param overlayParams
1298+
*
1299+
* @example
1300+
* let overlayParams = {
1301+
* enableDepth: true,
1302+
* deleteWhenUnused: false,
1303+
* keepNonBlurred: true,
1304+
* processAttachments: true,
1305+
* fill: { enable: false, color: 0xFFFFFFFF },
1306+
* noise: { enable: false, size: 0.0, speed: 0.0, intensity: 0.0 },
1307+
* outline: { enable: true, color: 0xFF9000FF, width: 5.0, blurRadius: 1.0, blurIntensity: 1.0 },
1308+
* wireframe: { enable: false }
1309+
* };
1310+
*
1311+
* mp.game.graphics.setEntityOverlayPassEnabled(true);
1312+
*
1313+
* let batch = mp.game.graphics.createEntityOverlayBatch(overlayParams);
1314+
*
1315+
* mp.events.add('render', () => {
1316+
* batch.addThisFrame(mp.players.local);
1317+
* });
1318+
*/
1319+
createEntityOverlayBatch(overlayParams: {
1320+
enableDepth: boolean,
1321+
deleteWhenUnused: boolean,
1322+
keepNonBlurred: boolean,
1323+
processAttachments: boolean,
1324+
fill: { enable: boolean, color: number },
1325+
noise: { enable: boolean, size: number, speed: number, intensity: number },
1326+
outline: { enable: boolean, color: number, width: number, blurRadius: number, blurIntensity: number },
1327+
wireframe: { enable: boolean }
1328+
}): {
1329+
1330+
/**
1331+
* Update an existing entity overlay batch created with createEntityOverlayBatch
1332+
* @param overlayParams
1333+
*
1334+
* @example
1335+
*
1336+
* //update its fill color
1337+
* let overlayParams = { ... }
1338+
* let batch = mp.game.graphics.createEntityOverlayBatch(overlayParams);
1339+
*
1340+
* mp.events.add('updatebatchcolor', () => {
1341+
* overlayParams.fill.color = 0x00AA00FF;
1342+
* batch.update(overlayParams);
1343+
* });
1344+
*
1345+
*/
1346+
update(overlayParams: {
1347+
enableDepth: boolean,
1348+
deleteWhenUnused: boolean,
1349+
keepNonBlurred: boolean,
1350+
processAttachments: boolean,
1351+
fill: { enable: boolean, color: number },
1352+
noise: { enable: boolean, size: number, speed: number, intensity: number },
1353+
outline: { enable: boolean, color: number, width: number, blurRadius: number, blurIntensity: number },
1354+
wireframe: { enable: boolean }
1355+
}): void,
1356+
1357+
/**
1358+
* This method will destroy an entity overlay batch.
1359+
* @example
1360+
* // Enable entity overlay batch
1361+
* mp.game.graphics.setEntityOverlayPassEnabled(true);
1362+
*
1363+
* // Create new entity overlay batch with specified parameters
1364+
* const overlayParams = { ... };
1365+
* let batch = mp.game.graphics.createEntityOverlayBatch(overlayParams);
1366+
*
1367+
* // Add a vehicle to the overlay batch once the player enters it
1368+
* mp.events.add('playerEnterVehicle', (vehicle) => {
1369+
* batch.add(vehicle);
1370+
* });
1371+
*
1372+
* // Add an event to destroy the created batch
1373+
* mp.events.add("client_batch_destroy", () => {
1374+
* batch.destroy();
1375+
* mp.console.logInfo(`Entity overlay batch was destroyed successfully.`);
1376+
* });
1377+
*/
1378+
destroy(): void,
1379+
1380+
/**
1381+
* This property will return whether an entity overlay is valid or not.
1382+
* Note: This property is readonly.
1383+
* @returns boolean
1384+
*/
1385+
valid: boolean,
1386+
1387+
/**
1388+
* This method will add an entity to overlay batch.
1389+
* @param entity
1390+
*
1391+
* @example
1392+
* //Enable entity overlay batch.
1393+
* mp.game.graphics.setEntityOverlayPassEnabled(true);
1394+
* //Create a new entity overlay batch.
1395+
* let batch = mp.game.graphics.createEntityOverlayBatch(overlayParams);
1396+
1397+
* //Add a vehicle to overlay batch once the player enters in them.
1398+
* mp.events.add('playerEnterVehicle', (vehicle) => {
1399+
* batch.add(vehicle);
1400+
* });
1401+
*/
1402+
add(entity: number): void,
1403+
1404+
/**
1405+
* This method will remove an entity from overlay batch.
1406+
* @param entity
1407+
*
1408+
* @example
1409+
* //Enable entity overlay batch
1410+
* mp.game.graphics.setEntityOverlayPassEnabled(true);
1411+
1412+
* //Create new entity overlay batch
1413+
* let batch = mp.game.graphics.createEntityOverlayBatch(overlayParams);
1414+
1415+
* //Add a vehicle to overlay batch once the player enters in them.
1416+
* mp.events.add('playerEnterVehicle', (vehicle) => {
1417+
* batch.add(vehicle);
1418+
* });
1419+
1420+
* //Remove vehicle from batch once the player leaves them.
1421+
* mp.events.add('playerLeaveVehicle', (vehicle) => {
1422+
* batch.remove(vehicle);
1423+
* })
1424+
*/
1425+
remove(entity: number): void,
1426+
1427+
/**
1428+
* This method will add an entity to overlay batch only this frame.
1429+
* @param entity
1430+
* //Enable entity overlay batch
1431+
* mp.game.graphics.setEntityOverlayPassEnabled(true);
1432+
1433+
* //Create new entity overlay batch
1434+
* let batch = mp.game.graphics.createEntityOverlayBatch(overlayParams);
1435+
1436+
* //Add streamed vehicles to overlay batch.
1437+
* mp.events.add('render', () => {
1438+
* mp.vehicles.forEachInStreamRange((vehicle) => {
1439+
batch.addThisFrame(vehicle);
1440+
* })
1441+
* });
1442+
*/
1443+
addThisFrame(entity: number): void,
1444+
1445+
/**
1446+
* This method will remove an entity from overlay batch only this frame.
1447+
* @param entity
1448+
*
1449+
* @example
1450+
* let batch = mp.game.graphics.createEntityOverlayBatch(overlayParams);
1451+
1452+
* //Remove vehicle from batch once the player leaves them.
1453+
* mp.events.add('playerLeaveVehicle', (vehicle) => {
1454+
* batch.remove(vehicle);
1455+
* })
1456+
*/
1457+
removeThisFrame(entity: number): void,
1458+
}
1459+
1460+
/**
1461+
* This method will enable or disable entity overlay feature.
1462+
* @param enable
1463+
*
1464+
* @example
1465+
* //enable entity overlay
1466+
* mp.game.graphics.setEntityOverlayPassEnabled(true);
1467+
*
1468+
* //disable entity overlay
1469+
* mp.game.graphics.setEntityOverlayPassEnabled(false);
1470+
*/
1471+
setEntityOverlayPassEnabled(enable: boolean): void,
12941472
}
12951473

12961474
declare interface GameGraphicsMp extends GameGraphics { }

0 commit comments

Comments
 (0)