Beispiel #1
0
        /// <summary>
        /// Processes each material list to create the texture slots
        /// Adds the alternate skin materials to their own skin dictionary
        /// </summary>
        private void ProcessCharacterSkins()
        {
            List <KeyValuePair <int, MaterialList> > materialListMapping = new List <KeyValuePair <int, MaterialList> >();

            foreach (WldFragment materialListFragment in _fragmentTypeDictionary[0x31])
            {
                if (!(materialListFragment is MaterialList materialList))
                {
                    continue;
                }

                materialList.CreateIndexSlotMapping(_logger);
                materialListMapping.Add(new KeyValuePair <int, MaterialList>(materialList.Index, materialList));
            }

            foreach (WldFragment materialFragment in _fragmentTypeDictionary[0x30])
            {
                if (!(materialFragment is Material material))
                {
                    continue;
                }

                if (material.IsHandled)
                {
                    continue;
                }

                if (material.GetMaterialType() == Material.CharacterMaterialType.GlobalSkin)
                {
                    if (GlobalCharacterMaterials == null)
                    {
                        GlobalCharacterMaterials = new Dictionary <string, Material>();
                    }

                    if (!GlobalCharacterMaterials.ContainsKey(material.Name))
                    {
                        GlobalCharacterMaterials.Add(material.Name, material);
                    }

                    continue;
                }

                MaterialList parentList = materialListMapping.First().Value;

                foreach (var listMapping in materialListMapping)
                {
                    if (material.Index < listMapping.Key)
                    {
                        break;
                    }

                    parentList = listMapping.Value;
                }

                if (parentList == null)
                {
                    Console.WriteLine("Can't find parent material list: " + material.Name);
                    continue;
                }

                _logger.LogError("Match: " + material.Name + " to: " + parentList.Name);

                parentList.AddMaterialToSkins(material, _logger);
            }
        }