read method

PropertyAnimation read (
  1. StreamReader reader,
  2. ActorComponent component
)

Implementation

static PropertyAnimation read(StreamReader reader, ActorComponent component) {
  StreamReader propertyBlock = reader.readNextBlock(propertyTypesMap);
  if (propertyBlock == null) {
    return null;
  }
  PropertyAnimation propertyAnimation = PropertyAnimation();
  int type = propertyBlock.blockType;
  propertyAnimation._type = type;

  KeyFrameReader keyFrameReader;
  switch (propertyAnimation._type) {
    case PropertyTypes.posX:
      keyFrameReader = KeyFramePosX.read;
      break;
    case PropertyTypes.posY:
      keyFrameReader = KeyFramePosY.read;
      break;
    case PropertyTypes.scaleX:
      keyFrameReader = KeyFrameScaleX.read;
      break;
    case PropertyTypes.scaleY:
      keyFrameReader = KeyFrameScaleY.read;
      break;
    case PropertyTypes.rotation:
      keyFrameReader = KeyFrameRotation.read;
      break;
    case PropertyTypes.opacity:
      keyFrameReader = KeyFrameOpacity.read;
      break;
    case PropertyTypes.drawOrder:
      keyFrameReader = KeyFrameDrawOrder.read;
      break;
    case PropertyTypes.length:
      keyFrameReader = KeyFrameLength.read;
      break;
    case PropertyTypes.imageVertices:
      keyFrameReader = KeyFrameImageVertices.read;
      break;
    case PropertyTypes.constraintStrength:
      keyFrameReader = KeyFrameConstraintStrength.read;
      break;
    case PropertyTypes.trigger:
      keyFrameReader = KeyFrameTrigger.read;
      break;
    case PropertyTypes.intProperty:
      keyFrameReader = KeyFrameIntProperty.read;
      break;
    case PropertyTypes.floatProperty:
      keyFrameReader = KeyFrameFloatProperty.read;
      break;
    case PropertyTypes.stringProperty:
      keyFrameReader = KeyFrameStringProperty.read;
      break;
    case PropertyTypes.booleanProperty:
      keyFrameReader = KeyFrameBooleanProperty.read;
      break;
    case PropertyTypes.collisionEnabled:
      keyFrameReader = KeyFrameCollisionEnabledProperty.read;
      break;
    case PropertyTypes.activeChildIndex:
      keyFrameReader = KeyFrameActiveChild.read;
      break;
    case PropertyTypes.sequence:
      keyFrameReader = KeyFrameSequence.read;
      break;
    case PropertyTypes.pathVertices:
      keyFrameReader = KeyFramePathVertices.read;
      break;
    case PropertyTypes.fillColor:
      keyFrameReader = KeyFrameFillColor.read;
      break;
    case PropertyTypes.color:
      keyFrameReader = KeyFrameShadowColor.read;
      break;
    case PropertyTypes.offsetX:
      keyFrameReader = KeyFrameShadowOffsetX.read;
      break;
    case PropertyTypes.offsetY:
      keyFrameReader = KeyFrameShadowOffsetY.read;
      break;
    case PropertyTypes.blurX:
      keyFrameReader = KeyFrameBlurX.read;
      break;
    case PropertyTypes.blurY:
      keyFrameReader = KeyFrameBlurY.read;
      break;
    case PropertyTypes.fillGradient:
      keyFrameReader = KeyFrameGradient.read;
      break;
    case PropertyTypes.strokeGradient:
      keyFrameReader = KeyFrameGradient.read;
      break;
    case PropertyTypes.fillRadial:
      keyFrameReader = KeyFrameRadial.read;
      break;
    case PropertyTypes.strokeRadial:
      keyFrameReader = KeyFrameRadial.read;
      break;
    case PropertyTypes.strokeColor:
      keyFrameReader = KeyFrameStrokeColor.read;
      break;
    case PropertyTypes.strokeWidth:
      keyFrameReader = KeyFrameStrokeWidth.read;
      break;
    case PropertyTypes.strokeOpacity:
    case PropertyTypes.fillOpacity:
      keyFrameReader = KeyFramePaintOpacity.read;
      break;
    case PropertyTypes.shapeWidth:
      keyFrameReader = KeyFrameShapeWidth.read;
      break;
    case PropertyTypes.shapeHeight:
      keyFrameReader = KeyFrameShapeHeight.read;
      break;
    case PropertyTypes.cornerRadius:
      keyFrameReader = KeyFrameCornerRadius.read;
      break;
    case PropertyTypes.innerRadius:
      keyFrameReader = KeyFrameInnerRadius.read;
      break;
    case PropertyTypes.strokeStart:
      keyFrameReader = KeyFrameStrokeStart.read;
      break;
    case PropertyTypes.strokeEnd:
      keyFrameReader = KeyFrameStrokeEnd.read;
      break;
    case PropertyTypes.strokeOffset:
      keyFrameReader = KeyFrameStrokeOffset.read;
      break;
  }

  if (keyFrameReader == null) {
    return null;
  }

  propertyBlock.openArray("frames");
  int keyFrameCount = propertyBlock.readUint16Length();
  propertyAnimation._keyFrames = List<KeyFrame>(keyFrameCount);
  KeyFrame lastKeyFrame;
  for (int i = 0; i < keyFrameCount; i++) {
    propertyBlock.openObject("frame");
    KeyFrame frame = keyFrameReader(propertyBlock, component);
    propertyAnimation._keyFrames[i] = frame;
    if (lastKeyFrame != null) {
      lastKeyFrame.setNext(frame);
    }
    lastKeyFrame = frame;
    propertyBlock.closeObject();
  }
  propertyBlock.closeArray();
  //}

  return propertyAnimation;
}