protected override Stream UnParse()
        {
            Stream s  = new MemoryStream();
            var    bw = new BinaryWriter(s);

            bw.Write(mVersion);
            var  keys     = new ResourceKeyTable();
            long startPos = keys.BeginWrite(s);

            if (mShaderKeyList == null)
            {
                mShaderKeyList = new ShaderKeyList(OnResourceChanged);
            }
            mShaderKeyList.UnParse(s);
            if (mSkinSubSRampKey == null)
            {
                mSkinSubSRampKey = new TGIBlock(0, OnResourceChanged);
            }
            if (mToneRampKey == null)
            {
                mToneRampKey = new TGIBlock(0, OnResourceChanged);
            }
            bw.Write(keys.Add(mSkinSubSRampKey));
            bw.Write(keys.Add(mToneRampKey));
            if (mTextureKeyList == null)
            {
                mTextureKeyList = new TextureKeyList(OnResourceChanged, this);
            }
            mTextureKeyList.UnParse(s, keys);
            bw.Write(mIsDominant ? (byte)1 : (byte)0);
            keys.EndWrite(s, startPos);
            return(s);
        }
 public void UnParse(Stream s, ResourceKeyTable keys)
 {
     WriteCount(s, Count);
     for (int i = 0; i < Count; i++)
     {
         this[i].UnParse(s, keys);
     }
 }
            protected void Parse(Stream s, ResourceKeyTable keys)
            {
                int c = ReadCount(s);

                for (int i = 0; i < c; i++)
                {
                    ((IList <TextureKey>) this).Add(new TextureKey(0, handler, s, mOwner, keys));
                }
            }
        private void Parse(Stream s)
        {
            var br = new BinaryReader(s);

            mVersion = br.ReadUInt32();
            var keys = new ResourceKeyTable();

            ResourceKeyTable.TablePtr ptr = keys.BeginRead(s);
            mShaderKeyList   = new ShaderKeyList(OnResourceChanged, s);
            mSkinSubSRampKey = new TGIBlock(0, OnResourceChanged, keys[br.ReadInt32()]);
            mToneRampKey     = new TGIBlock(0, OnResourceChanged, keys[br.ReadInt32()]);
            mTextureKeyList  = new TextureKeyList(OnResourceChanged, s, this, keys);
            mIsDominant      = br.ReadByte() == 1;
            keys.EndRead(s, ptr);
        }
            public void UnParse(Stream s, ResourceKeyTable keys)
            {
                var bw = new BinaryWriter(s);

                mAgeGenderFlags.UnParse(s);
                bw.Write((UInt32)mTypeFlags);
                bw.Write(keys.Add(mSpecularKey));
                bw.Write(keys.Add(mDetailDarkKey));
                bw.Write(keys.Add(mDetailLightKey));
                bw.Write(keys.Add(mNormalMapKey));
                bw.Write(keys.Add(mOverlayKey));
                if (mOwner.Version >= 6)
                {
                    bw.Write(keys.Add(mMuscleNormalMapKey));
                    bw.Write(keys.Add(mCleavageNormalMapKey));
                }
            }
            public void Parse(Stream s, ResourceKeyTable keys)
            {
                var br = new BinaryReader(s);

                mAgeGenderFlags = new AgeGenderFlags(0, handler, s);
                mTypeFlags      = (DataTypeFlags)br.ReadUInt32();
                mSpecularKey    = new TGIBlock(0, handler, keys[br.ReadInt32()]);
                mDetailDarkKey  = new TGIBlock(0, handler, keys[br.ReadInt32()]);
                mDetailLightKey = new TGIBlock(0, handler, keys[br.ReadInt32()]);
                mNormalMapKey   = new TGIBlock(0, handler, keys[br.ReadInt32()]);
                mOverlayKey     = new TGIBlock(0, handler, keys[br.ReadInt32()]);
                if (mOwner.Version >= 6)
                {
                    mMuscleNormalMapKey   = new TGIBlock(0, handler, keys[br.ReadInt32()]);
                    mCleavageNormalMapKey = new TGIBlock(0, handler, keys[br.ReadInt32()]);
                }
                else
                {
                    mMuscleNormalMapKey   = new TGIBlock(0, handler);
                    mCleavageNormalMapKey = new TGIBlock(0, handler);
                }
            }
 public TextureKeyList(EventHandler handler, Stream s, SkinToneResource owner, ResourceKeyTable keys) : this(handler, owner)
 {
     Parse(s, keys);
 }
 public TextureKey(int APIversion, EventHandler handler, Stream s, SkinToneResource owner, ResourceKeyTable keys) : base(APIversion, handler)
 {
     mOwner = owner;
     Parse(s, keys);
 }