(
instanceContainer: gdjs.RuntimeInstanceContainer,
objectsLists: Hashtable<gdjs.RuntimeObject[]>,
obj: gdjs.RuntimeObject | null,
eventsFunctionContext: EventsFunctionContext | null | undefined
)
| 335 | }; |
| 336 | |
| 337 | export const pickObjectsLinkedTo = function ( |
| 338 | instanceContainer: gdjs.RuntimeInstanceContainer, |
| 339 | objectsLists: Hashtable<gdjs.RuntimeObject[]>, |
| 340 | obj: gdjs.RuntimeObject | null, |
| 341 | eventsFunctionContext: EventsFunctionContext | null | undefined |
| 342 | ) { |
| 343 | if (obj === null) { |
| 344 | return false; |
| 345 | } |
| 346 | const linkedObjectMap = |
| 347 | LinksManager.getManager(instanceContainer)._getMapOfObjectsLinkedWith( |
| 348 | obj |
| 349 | ); |
| 350 | |
| 351 | let pickedSomething = false; |
| 352 | for (const contextObjectName in objectsLists.items) { |
| 353 | if (objectsLists.containsKey(contextObjectName)) { |
| 354 | const parentEventPickedObjects = |
| 355 | objectsLists.items[contextObjectName]; |
| 356 | |
| 357 | if (parentEventPickedObjects.length === 0) { |
| 358 | continue; |
| 359 | } |
| 360 | |
| 361 | // Find the object names in the scene |
| 362 | const parentEventPickedObjectNames = gdjs.staticArray2( |
| 363 | gdjs.evtTools.linkedObjects.pickObjectsLinkedTo |
| 364 | ); |
| 365 | parentEventPickedObjectNames.length = 0; |
| 366 | if (eventsFunctionContext) { |
| 367 | // For functions, objects lists may contain objects with different names |
| 368 | // indexed not by their name, but by the parameter name representing them. |
| 369 | // This means that each object can have a different name, |
| 370 | // so we iterate on them to get all the names. |
| 371 | for (const pickedObject of parentEventPickedObjects) { |
| 372 | if ( |
| 373 | parentEventPickedObjectNames.indexOf(pickedObject.getName()) < |
| 374 | 0 |
| 375 | ) { |
| 376 | parentEventPickedObjectNames.push(pickedObject.getName()); |
| 377 | } |
| 378 | } |
| 379 | } else { |
| 380 | // In the case of a scene, the list of objects are guaranteed |
| 381 | // to be indexed by the object name (no mix of objects with |
| 382 | // different names in a list). |
| 383 | parentEventPickedObjectNames.push(contextObjectName); |
| 384 | } |
| 385 | |
| 386 | // Sum the number of instances in the scene for each objects found |
| 387 | // previously in parentEventPickedObjects, so that we know if we can |
| 388 | // avoid running an intersection with the picked objects later. |
| 389 | let objectCount = 0; |
| 390 | for (const objectName of parentEventPickedObjectNames) { |
| 391 | objectCount += instanceContainer.getObjects(objectName)!.length; |
| 392 | } |
| 393 | |
| 394 | if (parentEventPickedObjects.length === objectCount) { |
nothing calls this directly
no test coverage detected