setWeaponZero method

Future<Angular> setWeaponZero(
  1. Shot shot,
  2. Distance zeroDistance
)

Async counterpart to Calculator.setWeaponZero.

The zero-finding itself runs off-isolate (native) or through the loaded wasm engine (web); the resulting elevation is then applied to shot on the caller's isolate, since shot is mutated in place and mutations made inside a spawned isolate would not be visible here.

Implementation

Future<Angular> setWeaponZero(Shot shot, Distance zeroDistance) async {
  final elev = await barrelElevationForTarget(shot, zeroDistance);
  shot.weapon.zeroElevation = elev;
  shot.relativeAngle = Angular.radian(0);
  return elev;
}