private void Setup(
     HairType type,
     HairSetCollection hair,
     int meshIndex,
     float typeNum,
     float dyeNum,
     MaterialPropertyBlock block)
 {
     this.CacheOriginalMaterials();
     HairSetCollection.HairSetEntry hairSetEntry = hair.Get(type, typeNum);
     if (Object.op_Equality((Object)hairSetEntry.HairSet, (Object)null))
     {
         Debug.LogWarning((object)"Hair.Get returned a NULL hair");
     }
     else
     {
         int blendShapeIndex = -1;
         if (type == HairType.Facial || type == HairType.Eyebrow)
         {
             blendShapeIndex = meshIndex;
         }
         HairDye           dye = (HairDye)null;
         HairDyeCollection hairDyeCollection = hairSetEntry.HairDyeCollection;
         if (Object.op_Inequality((Object)hairDyeCollection, (Object)null))
         {
             dye = hairDyeCollection.Get(dyeNum);
         }
         hairSetEntry.HairSet.Process(this, hairDyeCollection, dye, block);
         hairSetEntry.HairSet.ProcessMorphs(((Component)this).get_gameObject(), blendShapeIndex);
     }
 }
    public void SetupHairCap(SkinSetCollection skin, float hairNum, float meshNum, MaterialPropertyBlock block)
    {
        float   single;
        float   single1;
        int     index = skin.GetIndex(meshNum);
        SkinSet skins = skin.Skins[index];

        if (skins != null)
        {
            for (int i = 0; i < 5; i++)
            {
                if (((int)this.hairCapMask & 1 << (i & 31)) != 0)
                {
                    PlayerModelHair.GetRandomVariation(hairNum, i, index, out single, out single1);
                    HairType hairType = (HairType)i;
                    HairSetCollection.HairSetEntry hairSetEntry = skins.HairCollection.Get(hairType, single);
                    if (hairSetEntry.HairSet != null)
                    {
                        HairDyeCollection hairDyeCollection = hairSetEntry.HairDyeCollection;
                        if (hairDyeCollection != null)
                        {
                            HairDye hairDye = hairDyeCollection.Get(single1);
                            if (hairDye != null)
                            {
                                hairDye.ApplyCap(hairDyeCollection, hairType, block);
                            }
                        }
                    }
                }
            }
        }
    }
Beispiel #3
0
 public void Apply(HairDyeCollection collection, MaterialPropertyBlock block)
 {
     if (!(sourceMaterial != null))
     {
         return;
     }
     for (int i = 0; i < 8; i++)
     {
         if (((uint)copyProperties & (uint)(1 << i)) == 0)
         {
             continue;
         }
         MaterialPropertyDesc materialPropertyDesc = transferableProps[i];
         if (sourceMaterial.HasProperty(materialPropertyDesc.nameID))
         {
             if (materialPropertyDesc.type == typeof(Color))
             {
                 block.SetColor(materialPropertyDesc.nameID, sourceMaterial.GetColor(materialPropertyDesc.nameID));
             }
             else if (materialPropertyDesc.type == typeof(float))
             {
                 block.SetFloat(materialPropertyDesc.nameID, sourceMaterial.GetFloat(materialPropertyDesc.nameID));
             }
         }
     }
 }
    private void Setup(HairType type, HairSetCollection hair, int meshIndex, float typeNum, float dyeNum, MaterialPropertyBlock block)
    {
        this.CacheOriginalMaterials();
        HairSetCollection.HairSetEntry hairSetEntry = hair.Get(type, typeNum);
        if (hairSetEntry.HairSet == null)
        {
            Debug.LogWarning("Hair.Get returned a NULL hair");
            return;
        }
        int num = -1;

        if (type == HairType.Facial || type == HairType.Eyebrow)
        {
            num = meshIndex;
        }
        HairDye           hairDye           = null;
        HairDyeCollection hairDyeCollection = hairSetEntry.HairDyeCollection;

        if (hairDyeCollection != null)
        {
            hairDye = hairDyeCollection.Get(dyeNum);
        }
        hairSetEntry.HairSet.Process(this, hairDyeCollection, hairDye, block);
        hairSetEntry.HairSet.ProcessMorphs(base.gameObject, num);
    }
Beispiel #5
0
 public void Apply(HairDyeCollection collection, MaterialPropertyBlock block)
 {
     if (!Object.op_Inequality((Object)this.sourceMaterial, (Object)null))
     {
         return;
     }
     for (int index = 0; index < 8; ++index)
     {
         if ((this.copyProperties & (HairDye.CopyPropertyMask)(1 << index)) != (HairDye.CopyPropertyMask) 0)
         {
             MaterialPropertyDesc transferableProp = HairDye.transferableProps[index];
             if (this.sourceMaterial.HasProperty(transferableProp.nameID))
             {
                 if (transferableProp.type == typeof(Color))
                 {
                     block.SetColor(transferableProp.nameID, this.sourceMaterial.GetColor(transferableProp.nameID));
                 }
                 else if (transferableProp.type == typeof(float))
                 {
                     block.SetFloat(transferableProp.nameID, this.sourceMaterial.GetFloat(transferableProp.nameID));
                 }
             }
         }
     }
 }
Beispiel #6
0
    public void Process(PlayerModelHair playerModelHair, HairDyeCollection dyeCollection, HairDye dye, MaterialPropertyBlock block)
    {
        List <SkinnedMeshRenderer> obj = Pool.GetList <SkinnedMeshRenderer>();

        playerModelHair.gameObject.GetComponentsInChildren(true, obj);
        foreach (SkinnedMeshRenderer item in obj)
        {
            if (!(item.sharedMesh == null) && !(item.sharedMaterial == null))
            {
                string materialName = item.sharedMesh.name;
                string name2        = item.sharedMaterial.name;
                if (!item.gameObject.activeSelf)
                {
                    item.gameObject.SetActive(true);
                }
                for (int i = 0; i < MeshReplacements.Length; i++)
                {
                    MeshReplacements[i].Test(materialName);
                }
                if (dye != null && item.gameObject.activeSelf)
                {
                    dye.Apply(dyeCollection, block);
                }
            }
        }
        Pool.FreeList(ref obj);
    }
Beispiel #7
0
    public void SetupHairCap(
        SkinSetCollection skin,
        float hairNum,
        float meshNum,
        MaterialPropertyBlock block)
    {
        int     index = skin.GetIndex(meshNum);
        SkinSet skin1 = skin.Skins[index];

        if (!Object.op_Inequality((Object)skin1, (Object)null))
        {
            return;
        }
        for (int typeIndex = 0; typeIndex < 5; ++typeIndex)
        {
            if ((this.hairCapMask & (HairCapMask)(1 << typeIndex)) != (HairCapMask)0)
            {
                float typeNum;
                float dyeNum;
                PlayerModelHair.GetRandomVariation(hairNum, typeIndex, index, out typeNum, out dyeNum);
                HairType hairType = (HairType)typeIndex;
                HairSetCollection.HairSetEntry hairSetEntry = skin1.HairCollection.Get(hairType, typeNum);
                if (Object.op_Inequality((Object)hairSetEntry.HairSet, (Object)null))
                {
                    HairDyeCollection hairDyeCollection = hairSetEntry.HairDyeCollection;
                    if (Object.op_Inequality((Object)hairDyeCollection, (Object)null))
                    {
                        hairDyeCollection.Get(dyeNum)?.ApplyCap(hairDyeCollection, hairType, block);
                    }
                }
            }
        }
    }
Beispiel #8
0
    public void ApplyCap(HairDyeCollection collection, HairType type, MaterialPropertyBlock block)
    {
        if (collection.applyCap)
        {
            switch (type)
            {
            case HairType.Head:
            case HairType.Armpit:
            case HairType.Pubic:
                block.SetColor(_HairBaseColorUV1, capBaseColor.gamma);
                block.SetTexture(_HairPackedMapUV1, (collection.capMask != null) ? collection.capMask : Texture2D.blackTexture);
                break;

            case HairType.Facial:
                block.SetColor(_HairBaseColorUV2, capBaseColor.gamma);
                block.SetTexture(_HairPackedMapUV2, (collection.capMask != null) ? collection.capMask : Texture2D.blackTexture);
                break;
            }
        }
    }
Beispiel #9
0
    public void ApplyCap(HairDyeCollection collection, HairType type, MaterialPropertyBlock block)
    {
        if (!collection.applyCap)
        {
            return;
        }
        switch (type)
        {
        case HairType.Head:
        case HairType.Armpit:
        case HairType.Pubic:
            block.SetColor(HairDye._HairBaseColorUV1, ((Color) ref this.capBaseColor).get_gamma());
            block.SetTexture(HairDye._HairPackedMapUV1, Object.op_Inequality((Object)collection.capMask, (Object)null) ? collection.capMask : (Texture)Texture2D.get_blackTexture());
            break;

        case HairType.Facial:
            block.SetColor(HairDye._HairBaseColorUV2, ((Color) ref this.capBaseColor).get_gamma());
            block.SetTexture(HairDye._HairPackedMapUV2, Object.op_Inequality((Object)collection.capMask, (Object)null) ? collection.capMask : (Texture)Texture2D.get_blackTexture());
            break;
        }
    }
Beispiel #10
0
    public void ApplyCap(HairDyeCollection collection, HairType type, MaterialPropertyBlock block)
    {
        Texture texture;
        Texture texture1;

        if (collection.applyCap)
        {
            if (type == HairType.Head || type == HairType.Armpit || type == HairType.Pubic)
            {
                block.SetColor(HairDye._HairBaseColorUV1, this.capBaseColor.gamma);
                MaterialPropertyBlock materialPropertyBlock = block;
                int num = HairDye._HairPackedMapUV1;
                if (collection.capMask != null)
                {
                    texture = collection.capMask;
                }
                else
                {
                    texture = Texture2D.blackTexture;
                }
                materialPropertyBlock.SetTexture(num, texture);
                return;
            }
            if (type == HairType.Facial)
            {
                block.SetColor(HairDye._HairBaseColorUV2, this.capBaseColor.gamma);
                MaterialPropertyBlock materialPropertyBlock1 = block;
                int num1 = HairDye._HairPackedMapUV2;
                if (collection.capMask != null)
                {
                    texture1 = collection.capMask;
                }
                else
                {
                    texture1 = Texture2D.blackTexture;
                }
                materialPropertyBlock1.SetTexture(num1, texture1);
            }
        }
    }
Beispiel #11
0
 public void Apply(HairDyeCollection collection, MaterialPropertyBlock block)
 {
     if (this.sourceMaterial != null)
     {
         for (int i = 0; i < 8; i++)
         {
             if (((int)this.copyProperties & 1 << (i & 31)) != 0)
             {
                 MaterialPropertyDesc materialPropertyDesc = HairDye.transferableProps[i];
                 if (this.sourceMaterial.HasProperty(materialPropertyDesc.nameID))
                 {
                     if (materialPropertyDesc.type == typeof(Color))
                     {
                         block.SetColor(materialPropertyDesc.nameID, this.sourceMaterial.GetColor(materialPropertyDesc.nameID));
                     }
                     else if (materialPropertyDesc.type == typeof(float))
                     {
                         block.SetFloat(materialPropertyDesc.nameID, this.sourceMaterial.GetFloat(materialPropertyDesc.nameID));
                     }
                 }
             }
         }
     }
 }
    public void Process(PlayerModelHair playerModelHair, HairDyeCollection dyeCollection, HairDye dye, MaterialPropertyBlock block)
    {
        PlayerModelHair.RendererMaterials replace;
        List <SkinnedMeshRenderer>        list = Pool.GetList <SkinnedMeshRenderer>();

        playerModelHair.gameObject.GetComponentsInChildren <SkinnedMeshRenderer>(true, list);
        foreach (SkinnedMeshRenderer bones in list)
        {
            if (bones.sharedMesh == null || bones.sharedMaterial == null)
            {
                continue;
            }
            string str  = bones.sharedMesh.name;
            string str1 = bones.sharedMaterial.name;
            if (!bones.gameObject.activeSelf)
            {
                bones.gameObject.SetActive(true);
            }
            for (int i = 0; i < (int)this.MeshReplacements.Length; i++)
            {
                if (this.MeshReplacements[i].Test(str))
                {
                    SkinnedMeshRenderer skinnedMeshRenderer = this.MeshReplacements[i].Replace;
                    if (skinnedMeshRenderer != null)
                    {
                        bones.sharedMesh = skinnedMeshRenderer.sharedMesh;
                        bones.rootBone   = skinnedMeshRenderer.rootBone;
                        bones.bones      = this.MeshReplacements[i].GetBones();
                    }
                    else
                    {
                        bones.gameObject.SetActive(false);
                    }
                }
            }
            if (!playerModelHair.Materials.TryGetValue(bones, out replace))
            {
                Debug.LogWarning(string.Concat("[HairSet.Process] Missing cached renderer materials in ", playerModelHair.name));
            }
            else
            {
                Array.Copy(replace.original, replace.replacement, (int)replace.original.Length);
                for (int j = 0; j < (int)replace.original.Length; j++)
                {
                    for (int k = 0; k < (int)this.MaterialReplacements.Length; k++)
                    {
                        if (this.MaterialReplacements[k].Test(replace.names[j]))
                        {
                            replace.replacement[j] = this.MaterialReplacements[k].Replace;
                        }
                    }
                }
                bones.sharedMaterials = replace.replacement;
            }
            if (dye == null || !bones.gameObject.activeSelf)
            {
                continue;
            }
            dye.Apply(dyeCollection, block);
        }
        Pool.FreeList <SkinnedMeshRenderer>(ref list);
    }
Beispiel #13
0
    public void Process(
        PlayerModelHair playerModelHair,
        HairDyeCollection dyeCollection,
        HairDye dye,
        MaterialPropertyBlock block)
    {
        List <SkinnedMeshRenderer> list = (List <SkinnedMeshRenderer>)Pool.GetList <SkinnedMeshRenderer>();

        ((Component)playerModelHair).get_gameObject().GetComponentsInChildren <SkinnedMeshRenderer>(true, (List <M0>)list);
        using (List <SkinnedMeshRenderer> .Enumerator enumerator = list.GetEnumerator())
        {
            while (enumerator.MoveNext())
            {
                SkinnedMeshRenderer current = enumerator.Current;
                if (!Object.op_Equality((Object)current.get_sharedMesh(), (Object)null) && !Object.op_Equality((Object)((Renderer)current).get_sharedMaterial(), (Object)null))
                {
                    string name = ((Object)current.get_sharedMesh()).get_name();
                    ((Object)((Renderer)current).get_sharedMaterial()).get_name();
                    if (!((Component)current).get_gameObject().get_activeSelf())
                    {
                        ((Component)current).get_gameObject().SetActive(true);
                    }
                    for (int index = 0; index < this.MeshReplacements.Length; ++index)
                    {
                        if (this.MeshReplacements[index].Test(name))
                        {
                            SkinnedMeshRenderer replace = this.MeshReplacements[index].Replace;
                            if (Object.op_Equality((Object)replace, (Object)null))
                            {
                                ((Component)current).get_gameObject().SetActive(false);
                            }
                            else
                            {
                                current.set_sharedMesh(replace.get_sharedMesh());
                                current.set_rootBone(replace.get_rootBone());
                                current.set_bones(this.MeshReplacements[index].GetBones());
                            }
                        }
                    }
                    PlayerModelHair.RendererMaterials rendererMaterials;
                    if (playerModelHair.Materials.TryGetValue((Renderer)current, out rendererMaterials))
                    {
                        Array.Copy((Array)rendererMaterials.original, (Array)rendererMaterials.replacement, rendererMaterials.original.Length);
                        for (int index1 = 0; index1 < rendererMaterials.original.Length; ++index1)
                        {
                            for (int index2 = 0; index2 < this.MaterialReplacements.Length; ++index2)
                            {
                                if (this.MaterialReplacements[index2].Test(rendererMaterials.names[index1]))
                                {
                                    rendererMaterials.replacement[index1] = this.MaterialReplacements[index2].Replace;
                                }
                            }
                        }
                        ((Renderer)current).set_sharedMaterials(rendererMaterials.replacement);
                    }
                    else
                    {
                        Debug.LogWarning((object)("[HairSet.Process] Missing cached renderer materials in " + ((Object)playerModelHair).get_name()));
                    }
                    if (dye != null && ((Component)current).get_gameObject().get_activeSelf())
                    {
                        dye.Apply(dyeCollection, block);
                    }
                }
            }
        }
        // ISSUE: cast to a reference type
        Pool.FreeList <SkinnedMeshRenderer>((List <M0>&) ref list);
    }