Example #1
0
        public PartData(BasePart part, PartListing partListInstance)
        {
            PartListing.PartData.partList = partListInstance;
            this.parts = new Dictionary <BasePart.PartTier, List <BasePart> >();
            this.parts.Add(part.m_partTier, new List <BasePart>());
            this.parts[part.m_partTier].Add(part);
            this.type = part.m_partType;
            CustomPartInfo customPart = WPFMonoBehaviour.gameData.GetCustomPart(part.m_partType);

            this.partInstances = new Dictionary <BasePart.PartTier, List <GameObject> >();
            this.partInstances.Add(part.m_partTier, new List <GameObject>());
            this.selectedIcon = null;
            if (customPart == null)
            {
                return;
            }
            for (int i = 0; i < customPart.PartList.Count; i++)
            {
                if (customPart.PartList[i].VisibleOnPartListBeforeUnlocking)
                {
                    if (!this.parts.ContainsKey(customPart.PartList[i].m_partTier))
                    {
                        this.parts.Add(customPart.PartList[i].m_partTier, new List <BasePart>());
                    }
                    this.parts[customPart.PartList[i].m_partTier].Add(customPart.PartList[i]);
                    if (!this.partInstances.ContainsKey(customPart.PartList[i].m_partTier))
                    {
                        this.partInstances.Add(customPart.PartList[i].m_partTier, new List <GameObject>());
                    }
                }
            }
        }
Example #2
0
    public BasePart GetCustomPart(BasePart.PartType type, int customIndex)
    {
        if (customIndex <= 0)
        {
            GameObject part = this.GetPart(type);
            return((!(part == null)) ? part.GetComponent <BasePart>() : null);
        }
        CustomPartInfo customPart = this.GetCustomPart(type);

        if (customIndex > 0 && customIndex - 1 < customPart.PartList.Count)
        {
            return(customPart.PartList[customIndex - 1]);
        }
        return(null);
    }
Example #3
0
 // Helpers to get ready to Build
 static void GetPartInfos(IEnumerable <string> strPartInfos, List <CustomPartInfo> outPartInfos)
 {
     //List<CustomPartInfo> infos = new List<CustomPartInfo> ();
     foreach (string partInfo in strPartInfos)
     {
         if (!string.IsNullOrEmpty(partInfo))
         {
             CustomPartInfo info = new CustomPartInfo(partInfo);
             if (info.Smr != null)
             {
                 outPartInfos.Add(info);
             }
         }
     }
 }
Example #4
0
    public int GetCustomPartIndex(BasePart.PartType type, string partName)
    {
        GameObject part = this.GetPart(type);

        if (part != null && part.name.Equals(partName))
        {
            return(0);
        }
        CustomPartInfo customPart = this.GetCustomPart(type);

        for (int i = 0; i < customPart.PartList.Count; i++)
        {
            if (customPart.PartList[i].name.Equals(partName))
            {
                return(i + 1);
            }
        }
        return(-1);
    }
Example #5
0
        static Mesh BakeToMesh(CustomPartInfo partInfo, AppearData appearData)
        {
            SkinnedMeshRenderer smr = partInfo.Smr;

            if (string.IsNullOrEmpty(partInfo.ModelName) || smr.sharedMesh.blendShapeCount == 0)
            {
                return(smr.sharedMesh);
            }

            EMorphItem indexStart = EMorphItem.Max;
            EMorphItem indexEnd   = EMorphItem.Max;

            if (partInfo.ModelName.Contains("head"))
            {
                indexStart = EMorphItem.MinFace;
                indexEnd   = EMorphItem.MaxFace;
            }
            else if (partInfo.ModelName.Contains("torso"))
            {
                indexStart = EMorphItem.MinUpperbody;
                indexEnd   = EMorphItem.MaxUpperbody;
            }
            else if (partInfo.ModelName.Contains("legs"))
            {
                indexStart = EMorphItem.MinLowerbody;
                indexEnd   = EMorphItem.MaxLowerbody;
            }
            else if (partInfo.ModelName.Contains("feet"))
            {
                indexStart = EMorphItem.MinFoot;
                indexEnd   = EMorphItem.MaxFoot;
            }
            else if (partInfo.ModelName.Contains("hand"))
            {
                indexStart = EMorphItem.MinHand;
                indexEnd   = EMorphItem.MaxHand;
            }

            if (indexStart != indexEnd)
            {
                _tmpWeightIdxs.Clear();
                _tmpWeightVals.Clear();
                for (int i = (int)indexStart; i < (int)indexEnd; i++)
                {
                    float w     = appearData.GetWeight((EMorphItem)i) * 100f;
                    int   index = i - (int)indexStart;
                    if (w > 0f)
                    {
                        index = index * 2;
                    }
                    else
                    {
                        w     = -w;
                        index = index * 2 + 1;
                    }

                    if (smr.sharedMesh.blendShapeCount > index)
                    {
                        _tmpWeightIdxs.Add(index);
                        _tmpWeightVals.Add(smr.GetBlendShapeWeight(index));
                        smr.SetBlendShapeWeight(index, w);
                    }
                }
                Mesh msh = PeekTmpMesh();
                smr.BakeMesh(msh);
                msh.boneWeights = smr.sharedMesh.boneWeights;
                msh.bindposes   = smr.sharedMesh.bindposes;
                if (_tmpWeightIdxs.Count > 0)
                {
                    for (int i = 0; i < _tmpWeightIdxs.Count; i++)
                    {
                        smr.SetBlendShapeWeight(_tmpWeightIdxs[i], _tmpWeightVals[i]);
                    }
                }
                return(msh);
            }
            return(smr.sharedMesh);
        }