SWFProcessing.SWFModeller.SWFReader.ReadPlaceObject2 C# (CSharp) Method

ReadPlaceObject2() private method

private ReadPlaceObject2 ( ) : PlaceObject
return PlaceObject
        private PlaceObject ReadPlaceObject2()
        {
            bool hasClipActions = this.sdtr.ReadBit();
            bool hasClipDepth = this.sdtr.ReadBit();
            bool hasName = this.sdtr.ReadBit();
            bool hasRatio = this.sdtr.ReadBit();
            bool hasColorTransform = this.sdtr.ReadBit();
            bool hasMatrix = this.sdtr.ReadBit();
            bool hasCharacter = this.sdtr.ReadBit();
            bool isMove = this.sdtr.ReadBit();

            int depth = this.sdtr.ReadUI16();

            int? id = null;
            if (hasCharacter)
            {
                id = this.sdtr.ReadUI16();
            }

            Matrix matrix = null;
            if (hasMatrix)
            {
                matrix = this.sdtr.ReadMatrix();
            }

            #if DEBUG
            this.Log("id=" + id + ", depth=" + depth + " matrix=" + matrix);
            #endif

            ColorTransform cxform = null;
            if (hasColorTransform)
            {
                cxform = this.sdtr.ReadColorTransformWithAlpha();
            #if DEBUG
                this.Log("cxform=" + cxform);
            #endif
            }

            int? ratio = null;
            if (hasRatio)
            {
                ratio = this.sdtr.ReadUI16();
            #if DEBUG
                this.Log("ratio=" + ratio);
            #endif
            }

            string name = null;
            if (hasName)
            {
                name = this.sdtr.ReadString();
            #if DEBUG
                this.Log("name=" + name);
            #endif
            }

            int? clipDepth = null;
            if (hasClipDepth)
            {
                clipDepth = this.sdtr.ReadUI16();
            #if DEBUG
                this.Log("clipDepth=" + clipDepth);
            #endif
            }

            if (hasClipActions)
            {
                throw new SWFModellerException(
                        SWFModellerError.SWFParsing,
                        @"Clip actions are not supported by the target flash player version.", swf.Context);
            }

            /* ISSUE 40: A null id means something in the spec. Look up how to find out what ID this should be.
             * After that, fix the writer so that it knows when it can omit IDs of its own. This is one of
             * those areas where we're kinda exposing part of the SWF spec into the model, which feels dirty
             * and wrong. */
            ICharacter ch = id == null ? null : this.characterUnmarshaller[(int)id];

            return new PlaceObject(ch, this.currentTimeline.GetLayer(depth), clipDepth, matrix, name, isMove, cxform, null, ratio);
        }