示例#1
0
        public GraphObject(ABinaryReader binaryReader)
        {
            Visible     = true;
            ParentIndex = binaryReader.ReadS16();
            ChildIndex  = binaryReader.ReadS16();
            NextIndex   = binaryReader.ReadS16();
            PrevIndex   = binaryReader.ReadS16();

            if (binaryReader.Read8() != 0)
            {
#if AROOKAS_DEMOLISHER_CHECKPADDING
                throw new Exception(String.Format("GraphObject padding != 0 at 0x{0:X8}.", binaryReader.Stream.Position));
#endif
            }

            RenderFlags = (GraphObjectRenderFlags)binaryReader.Read8();

            if (binaryReader.Read16() != 0)
            {
#if AROOKAS_DEMOLISHER_CHECKPADDING
                throw new Exception(String.Format("GraphObject padding != 0 at 0x{0:X8}.", binaryReader.Stream.Position));
#endif
            }

            Scale       = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
            Rotation    = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
            Position    = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
            BoundingBox = new BoundingBox(binaryReader.ReadVector3D().ToVector3(), binaryReader.ReadVector3D().ToVector3());
            unk3        = binaryReader.ReadSingle();

            int partCount = binaryReader.ReadS16();

            if (binaryReader.Read16() != 0)
            {
#if AROOKAS_DEMOLISHER_CHECKPADDING
                throw new Exception(String.Format("GraphObject padding != 0 at 0x{0:X8}.", binaryReader.Stream.Position));
#endif
            }

            int partOffset = binaryReader.ReadS32();

            if (binaryReader.Read32s(7).Any(zero => zero != 0))
            {
#if AROOKAS_DEMOLISHER_CHECKPADDING
                throw new Exception(String.Format("GraphObject padding != 0 at 0x{0:X8}.", binaryReader.Stream.Position));
#endif
            }

            binaryReader.Goto(partOffset);
            parts = CollectionHelper.Initialize <Part>(partCount, () => new Part(binaryReader));
            binaryReader.Back();
        }