addCollisionComponent method

  1. @override
Future addCollisionComponent(
  1. ThermionEntity entity, {
  2. void callback(
    1. int entityId1,
    2. int entityId2
    )?,
  3. bool affectsTransform = false,
})
override

Implementation

@override
Future addCollisionComponent(ThermionEntity entity,
    {void Function(int entityId1, int entityId2)? callback,
    bool affectsTransform = false}) async {
  if (_sceneManager == null) {
    throw Exception("SceneManager must be non-null");
  }
  // ignore: sdk_version_since

  if (callback != null) {
    var ptr =
        NativeCallable<Void Function(Int entityId1, Int entityId2)>.listener(
            callback);
    add_collision_component(
        _sceneManager!, entity, ptr.nativeFunction, affectsTransform);
    _collisions[entity] = ptr;
  } else {
    add_collision_component(
        _sceneManager!, entity, nullptr, affectsTransform);
  }
}