// Token: 0x0600025D RID: 605 RVA: 0x00015254 File Offset: 0x00013454
        public void TransferMaterial(BinaryReader reader, BinaryWriter writer, TargetMaterial trgtMat, bool overwrite)
        {
            reader.ReadString();
            writer.Write(trgtMat.editname);
            string text  = reader.ReadString();
            string value = reader.ReadString();

            if (trgtMat.shaderChanged)
            {
                text  = trgtMat.ShaderNameOrDefault(text);
                value = ShaderType.GetMateName(text);
            }
            writer.Write(text);
            writer.Write(value);
            ShaderType        type    = trgtMat.editedMat.type;
            HashSet <PropKey> hashSet = new HashSet <PropKey>();

            for (;;)
            {
                string text2 = reader.ReadString();
                if (text2 == "end")
                {
                    break;
                }
                string     text3      = reader.ReadString();
                ShaderProp shaderProp = type.GetShaderProp(text3);
                if (shaderProp == null)
                {
                    this.DiscardMateProp(reader, text2);
                }
                else
                {
                    string a;
                    if (!overwrite)
                    {
                        this.TransferMateProp(reader, writer, text2, text3);
                    }
                    else if ((a = text2) != null)
                    {
                        if (!(a == "tex"))
                        {
                            if (!(a == "col") && !(a == "vec"))
                            {
                                if (a == "f")
                                {
                                    this.Write(writer, new string[]
                                    {
                                        text2,
                                        text3
                                    });
                                    this.Write(writer, trgtMat.editedMat.material.GetFloat(text3));
                                    this.DiscardMateProp(reader, text2);
                                }
                            }
                            else
                            {
                                this.Write(writer, new string[]
                                {
                                    text2,
                                    text3
                                });
                                this.Write(writer, trgtMat.editedMat.material.GetColor(text3));
                                this.DiscardMateProp(reader, text2);
                            }
                        }
                        else
                        {
                            TargetTexture targetTexture;
                            trgtMat.texDic.TryGetValue(shaderProp.key, out targetTexture);
                            if (targetTexture == null || targetTexture.tex == null || targetTexture.fileChanged || targetTexture.colorChanged)
                            {
                                if (targetTexture != null)
                                {
                                    targetTexture.worksuffix = trgtMat.worksuffix;
                                }
                                string workfilename = null;
                                this.TransferMateProp(reader, null, text2, null, ref workfilename);
                                if (targetTexture != null)
                                {
                                    targetTexture.workfilename = workfilename;
                                }
                                this.WriteTex(writer, text3, trgtMat, targetTexture);
                            }
                            else
                            {
                                this.TransferMateProp(reader, writer, text2, text3);
                            }
                        }
                    }
                    hashSet.Add(shaderProp.key);
                }
            }
            if (type.KeyCount() != hashSet.Count)
            {
                foreach (ShaderPropTex shaderPropTex in type.texProps)
                {
                    if (!hashSet.Contains(shaderPropTex.key))
                    {
                        TargetTexture trgtTex;
                        trgtMat.texDic.TryGetValue(shaderPropTex.key, out trgtTex);
                        this.WriteTex(writer, shaderPropTex.keyName, trgtMat, trgtTex);
                    }
                }
                foreach (ShaderPropColor shaderPropColor in type.colProps)
                {
                    if (!hashSet.Contains(shaderPropColor.key))
                    {
                        this.Write(writer, new string[]
                        {
                            shaderPropColor.type.ToString(),
                            shaderPropColor.keyName
                        });
                        this.Write(writer, trgtMat.editedMat.material.GetColor(shaderPropColor.propId));
                    }
                }
                foreach (ShaderPropFloat shaderPropFloat in type.fProps)
                {
                    if (!hashSet.Contains(shaderPropFloat.key))
                    {
                        this.Write(writer, new string[]
                        {
                            shaderPropFloat.type.ToString(),
                            shaderPropFloat.keyName
                        });
                        this.Write(writer, trgtMat.editedMat.material.GetFloat(shaderPropFloat.propId));
                    }
                }
            }
            writer.Write("end");
        }
        // modelファイル内のマテリアル情報を対象とした転送処理
        // .mateファイルのheader, version, name1は存在しない
        public void TransferMaterial(BinaryReader reader, BinaryWriter writer, TargetMaterial trgtMat, bool overwrite)
        {
            // マテリアル名
            reader.ReadString();
            writer.Write(trgtMat.editname);

            var shaderName1 = reader.ReadString();
            var shaderName2 = reader.ReadString();

            if (trgtMat.shaderChanged)
            {
                shaderName1 = trgtMat.ShaderNameOrDefault(shaderName1);
                shaderName2 = ShaderType.GetMateName(shaderName1);
            }
            writer.Write(shaderName1);
            writer.Write(shaderName2);

            //var matType = trgtMat.editedMat.type1;
            var shaderType = trgtMat.editedMat.type;
            var writed     = new HashSet <PropKey>();

            while (true)
            {
                var type = reader.ReadString();
                //writer.Write(type);
                if (type == "end")
                {
                    break;
                }

                var propName = reader.ReadString();
                //shaderType.
                var shaderProp = shaderType.GetShaderProp(propName);
                if (shaderProp == null)
                {
                    // シェーダに対応していないプロパティは読み捨て
                    DiscardMateProp(reader, type);
                    continue;
                }

                if (!overwrite)
                {
                    // .mateからマテリアル変更で書き換えるため、そのまま転送
                    // ただし、model上に記述されたマテリアルで指定されたtexファイルは存在する必要あり
                    TransferMateProp(reader, writer, type, propName);
                }
                else
                {
                    switch (type)
                    {
                    case "tex":
                        // .mateによるマテリアル変更がないケースのみ書き換える
                        //
                        // texプロパティがある場合にのみ設定
                        TargetTexture trgtTex;
                        trgtMat.texDic.TryGetValue(shaderProp.key, out trgtTex);
                        if (trgtTex == null || trgtTex.tex == null || trgtTex.fileChanged || trgtTex.colorChanged)
                        {
                            // 変更がある場合にのみ書き換え (空のものはnull指定)
                            if (trgtTex != null)
                            {
                                trgtTex.worksuffix = trgtMat.worksuffix;
                            }
                            string srcfile = null;
                            TransferMateProp(reader, null, type, null, ref srcfile);
                            if (trgtTex != null)
                            {
                                trgtTex.workfilename = srcfile;
                            }

                            WriteTex(writer, propName, trgtMat, trgtTex);
                        }
                        else
                        {
                            // 変更がないものはそのまま転送
                            TransferMateProp(reader, writer, type, propName);
                        }
                        break;

                    case "col":
                    case "vec":
                        Write(writer, type, propName);
                        Write(writer, trgtMat.editedMat.material.GetColor(propName));

                        DiscardMateProp(reader, type);
                        break;

                    case "f":
                        Write(writer, type, propName);
                        Write(writer, trgtMat.editedMat.material.GetFloat(propName));

                        DiscardMateProp(reader, type);
                        break;
                    }
                }
                writed.Add(shaderProp.key);
            }

            // シェーダで設定されるプロパティ数が一致しない場合、不足propを追記

            if (shaderType.KeyCount() != writed.Count)
            {
                foreach (var texProp in shaderType.texProps)
                {
                    if (writed.Contains(texProp.key))
                    {
                        continue;
                    }

                    TargetTexture trgtTex;
                    trgtMat.texDic.TryGetValue(texProp.key, out trgtTex);
                    WriteTex(writer, texProp.keyName, trgtMat, trgtTex);
                }

                foreach (var prop in shaderType.colProps)
                {
                    if (writed.Contains(prop.key))
                    {
                        continue;
                    }

                    Write(writer, prop.type.ToString(), prop.keyName);
                    Write(writer, trgtMat.editedMat.material.GetColor(prop.propId));
                }

                foreach (var prop in shaderType.fProps)
                {
                    if (writed.Contains(prop.key))
                    {
                        continue;
                    }

                    Write(writer, prop.type.ToString(), prop.keyName);
                    Write(writer, trgtMat.editedMat.material.GetFloat(prop.propId));
                }
            }

            writer.Write("end");
        }