Fish constructor

Fish({
  1. required int id,
  2. required Offset position,
  3. required double angle,
  4. required FishSpecies species,
  5. double scale = 1.0,
  6. double? depth,
})

Implementation

Fish({
  required this.id,
  required this.position,
  required this.angle,
  required this.species,
  this.scale = 1.0,
  double? depth,
})  : config = FishSpeciesConfig.getConfig(species),
      depth = depth ?? (0.55 + Random().nextDouble() * 0.65),
      velocity = Offset(cos(angle), sin(angle)) * 40.0,
      targetAngle = angle,
      angularVelocity = 0.0,
      state = FishState.wandering,
      loadingPhase = FishLoadingPhase.none,
      stateTimer = 0.0,
      wigglePhase = Random().nextDouble() * 2 * pi,
      gillPhase = Random().nextDouble() * 2 * pi,
      jointAngles = List.filled(numJoints, angle),
      spineJoints = List.generate(
        numJoints,
        (i) => position - Offset(cos(angle), sin(angle)) * (i * (FishSpeciesConfig.getConfig(species).bodyLength / numJoints)),
      );