コード例 #1
0
ファイル: HairSet.cs プロジェクト: Ailtop/RustDocuments
    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);
    }
コード例 #2
0
    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);
                            }
                        }
                    }
                }
            }
        }
    }
コード例 #3
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);
                    }
                }
            }
        }
    }
コード例 #4
0
    public void Setup(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)
        {
            Debug.LogError("Skin.Get returned a NULL skin");
            return;
        }
        int num = (int)this.type;

        PlayerModelHair.GetRandomVariation(hairNum, num, index, out single, out single1);
        this.Setup(this.type, skins.HairCollection, index, single, single1, block);
    }
コード例 #5
0
    public void Setup(
        SkinSetCollection skin,
        float hairNum,
        float meshNum,
        MaterialPropertyBlock block)
    {
        int     index = skin.GetIndex(meshNum);
        SkinSet skin1 = skin.Skins[index];

        if (Object.op_Equality((Object)skin1, (Object)null))
        {
            Debug.LogError((object)"Skin.Get returned a NULL skin");
        }
        else
        {
            int   type = (int)this.type;
            float typeNum;
            float dyeNum;
            PlayerModelHair.GetRandomVariation(hairNum, type, index, out typeNum, out dyeNum);
            this.Setup(this.type, skin1.HairCollection, index, typeNum, dyeNum, block);
        }
    }
コード例 #6
0
    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);
    }
コード例 #7
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);
    }