resolveComponentIndices method

  1. @override
void resolveComponentIndices(
  1. List<ActorComponent?> components
)
override

Implementation

@override
void resolveComponentIndices(List<ActorComponent?> components) {
  super.resolveComponentIndices(components);

  if (_inTargetIdx != 0) {
    _inTarget = components[_inTargetIdx] as ActorNode?;
  }
  if (_outTargetIdx != 0) {
    _outTarget = components[_outTargetIdx] as ActorNode?;
  }

  List<ActorConstraint> dependencyConstraints = <ActorConstraint>[];
  ActorBone? bone = parent as ActorBone?;
  if (bone != null) {
    artboard.addDependency(this, bone);
    dependencyConstraints += bone.allConstraints;
    ActorBone? firstBone = bone.firstBone;
    if (firstBone != null) {
      artboard.addDependency(this, firstBone);
      dependencyConstraints += firstBone.allConstraints;

      // If we don't have an out target and the child jelly does have an
      // in target we are dependent on that target's position.
      if (_outTarget == null &&
          firstBone.jelly != null &&
          firstBone.jelly!.inTarget != null) {
        artboard.addDependency(this, firstBone.jelly!.inTarget!);
        dependencyConstraints += firstBone.jelly!.inTarget!.allConstraints;
      }
    }
    if (bone.parent is ActorBone) {
      ActorBone parentBone = bone.parent as ActorBone;
      JellyComponent? parentBoneJelly = parentBone.jelly;
      if (parentBoneJelly != null && parentBoneJelly.outTarget != null) {
        artboard.addDependency(this, parentBoneJelly.outTarget!);
        dependencyConstraints += parentBoneJelly.outTarget!.allConstraints;
      }
    }
  }

  if (_inTarget != null) {
    artboard.addDependency(this, _inTarget!);
    dependencyConstraints += _inTarget!.allConstraints;
  }
  if (_outTarget != null) {
    artboard.addDependency(this, _outTarget!);
    dependencyConstraints += _outTarget!.allConstraints;
  }

  // We want to depend on any and all constraints that our dependents have.
  Set<ActorConstraint> constraints =
      Set<ActorConstraint>.from(dependencyConstraints);
  for (final ActorConstraint constraint in constraints) {
    artboard.addDependency(this, constraint);
  }
}