getInstances method
Returns all instances of entity
.
Implementation
@override
Future<List<ThermionEntity>> getInstances(ThermionEntity entity) async {
final instanceCount = await getInstanceCount(entity);
final buf = _module._malloc(instanceCount * 4) as JSNumber;
_module.ccall(
"get_instances",
"void",
["void*".toJS, "int".toJS, "int*".toJS].toJS,
[_sceneManager!, entity.toJS, buf].toJS,
null);
final instances = <ThermionEntity>[];
for (int i = 0; i < instanceCount; i++) {
final instanceId =
_module.getValue((buf.toDartInt + (i * 4)).toJS, "i32") as JSNumber;
instances.add(instanceId.toDartInt);
}
_module._free(buf);
return instances;
}