コード例 #1
0
        public static List <UMAPackedDna> GetPackedDNA(UMAData.UMARecipe umaRecipe)
        {
            List <UMAPackedDna> PackedDNAlist = new List <UMAPackedDna>();

            foreach (var dna in umaRecipe.GetAllDna())
            {
                UMAPackedDna packedDna = new UMAPackedDna();
                //DynamicUMADna:: needs the typeHash as this is randomly generated by the DynamicDnaConverter
                packedDna.dnaTypeHash = dna.DNATypeHash;
                packedDna.dnaType     = dna.GetType().Name;
                packedDna.packedDna   = UMA.UMADna.SaveInstance(dna);
                PackedDNAlist.Add(packedDna);
            }
            return(PackedDNAlist);
        }
コード例 #2
0
/*
 *      public static UMAPackRecipe PackRecipeV1(UMA.UMAData.UMARecipe umaRecipe)
 *      {
 *              UMAPackRecipe umaPackRecipe = new UMAPackRecipe();
 *
 *              //var umaPackRecipe = new Packed
 *              int slotCount = umaRecipe.slotDataList.Length - umaRecipe.AdditionalSlots;
 *              umaPackRecipe.packedSlotDataList = new packedSlotData[slotCount];
 *              umaPackRecipe.race = umaRecipe.raceData.raceName;
 *
 *              foreach (var dna in umaRecipe.GetAllDna())
 *              {
 *                      UMAPackedDna packedDna = new UMAPackedDna();
 *                      packedDna.dnaType = dna.GetType().Name;
 *                      packedDna.packedDna = UMA.UMADna.SaveInstance(dna);
 *                      umaPackRecipe.packedDna.Add(packedDna);
 *              }
 *
 *              for (int i = 0; i < slotCount; i++)
 *              {
 *                      if (umaRecipe.slotDataList[i] != null)
 *                      {
 *                              packedSlotData tempPackedSlotData = new packedSlotData();
 *                              umaPackRecipe.packedSlotDataList[i] = tempPackedSlotData;
 *
 *                              tempPackedSlotData.slotID = umaRecipe.slotDataList[i].asset.slotName;
 *                              tempPackedSlotData.overlayScale = Mathf.FloorToInt(umaRecipe.slotDataList[i].overlayScale * 100);
 *
 *                              bool copiedOverlays = false;
 *                              for (int i2 = 0; i2 < i; i2++)
 *                              {
 *                                      if (umaRecipe.slotDataList[i2] != null && umaPackRecipe.packedSlotDataList[i2] != null)
 *                                      {
 *                                              if (umaRecipe.slotDataList[i].GetOverlayList() == umaRecipe.slotDataList[i2].GetOverlayList())
 *                                              {
 *                                                      tempPackedSlotData.copyOverlayIndex = i2;
 *                                                      copiedOverlays = true;
 *                                                      break;
 *                                              }
 *                                      }
 *                              }
 *                              if( copiedOverlays ) continue;
 *
 *                              tempPackedSlotData.OverlayDataList = new packedOverlayData[umaRecipe.slotDataList[i].OverlayCount];
 *
 *                              for (int overlayID = 0; overlayID < tempPackedSlotData.OverlayDataList.Length; overlayID++)
 *                              {
 *                                      tempPackedSlotData.OverlayDataList[overlayID] = new packedOverlayData();
 *                                      tempPackedSlotData.OverlayDataList[overlayID].overlayID = umaRecipe.slotDataList[i].GetOverlay(overlayID).asset.overlayName;
 *                                      OverlayColorData colorData = umaRecipe.slotDataList[i].GetOverlay(overlayID).colorData;
 *                                      if (colorData.color != Color.white)
 *                                      {
 *                                              Color32 color = umaRecipe.slotDataList[i].GetOverlay(overlayID).colorData.color;
 *                                              tempPackedSlotData.OverlayDataList[overlayID].colorList = new int[4];
 *                                              tempPackedSlotData.OverlayDataList[overlayID].colorList[0] = color.r;
 *                                              tempPackedSlotData.OverlayDataList[overlayID].colorList[1] = color.g;
 *                                              tempPackedSlotData.OverlayDataList[overlayID].colorList[2] = color.b;
 *                                              tempPackedSlotData.OverlayDataList[overlayID].colorList[3] = color.a;
 *                                      }
 *
 *                                      if (umaRecipe.slotDataList[i].GetOverlay(overlayID).rect != new Rect(0, 0, 0, 0))
 *                                      {
 *                                              //Might need float in next version
 *                                              tempPackedSlotData.OverlayDataList[overlayID].rectList = new int[4];
 *                                              tempPackedSlotData.OverlayDataList[overlayID].rectList[0] = (int)umaRecipe.slotDataList[i].GetOverlay(overlayID).rect.x;
 *                                              tempPackedSlotData.OverlayDataList[overlayID].rectList[1] = (int)umaRecipe.slotDataList[i].GetOverlay(overlayID).rect.y;
 *                                              tempPackedSlotData.OverlayDataList[overlayID].rectList[2] = (int)umaRecipe.slotDataList[i].GetOverlay(overlayID).rect.width;
 *                                              tempPackedSlotData.OverlayDataList[overlayID].rectList[3] = (int)umaRecipe.slotDataList[i].GetOverlay(overlayID).rect.height;
 *                                      }
 *
 *                                      if (colorData.channelMask != null && colorData.channelMask.Length > 0)
 *                                      {
 *                                              tempPackedSlotData.OverlayDataList[overlayID].channelMaskList = new int[colorData.channelMask.Length][];
 *
 *                                              for (int channelAdjust = 0; channelAdjust < colorData.channelMask.Length; channelAdjust++)
 *                                              {
 *                                                      tempPackedSlotData.OverlayDataList[overlayID].channelMaskList[channelAdjust] = new int[4];
 *                                                      tempPackedSlotData.OverlayDataList[overlayID].channelMaskList[channelAdjust][0] = colorData.channelMask[channelAdjust].r;
 *                                                      tempPackedSlotData.OverlayDataList[overlayID].channelMaskList[channelAdjust][1] = colorData.channelMask[channelAdjust].g;
 *                                                      tempPackedSlotData.OverlayDataList[overlayID].channelMaskList[channelAdjust][2] = colorData.channelMask[channelAdjust].b;
 *                                                      tempPackedSlotData.OverlayDataList[overlayID].channelMaskList[channelAdjust][3] = colorData.channelMask[channelAdjust].a;
 *                                              }
 *
 *                                      }
 *                                      if (colorData.channelAdditiveMask != null)
 *                                      {
 *                                              tempPackedSlotData.OverlayDataList[overlayID].channelAdditiveMaskList = new int[colorData.channelAdditiveMask.Length][];
 *                                              for (int channelAdjust = 0; channelAdjust < colorData.channelAdditiveMask.Length; channelAdjust++)
 *                                              {
 *                                                      tempPackedSlotData.OverlayDataList[overlayID].channelAdditiveMaskList[channelAdjust] = new int[4];
 *                                                      tempPackedSlotData.OverlayDataList[overlayID].channelAdditiveMaskList[channelAdjust][0] = colorData.channelAdditiveMask[channelAdjust].r;
 *                                                      tempPackedSlotData.OverlayDataList[overlayID].channelAdditiveMaskList[channelAdjust][1] = colorData.channelAdditiveMask[channelAdjust].g;
 *                                                      tempPackedSlotData.OverlayDataList[overlayID].channelAdditiveMaskList[channelAdjust][2] = colorData.channelAdditiveMask[channelAdjust].b;
 *                                                      tempPackedSlotData.OverlayDataList[overlayID].channelAdditiveMaskList[channelAdjust][3] = colorData.channelAdditiveMask[channelAdjust].a;
 *                                              }
 *
 *                                      }
 *                              }
 *                      }
 *              }
 *              return umaPackRecipe;
 *      }
 */

    public static UMAPackRecipe PackRecipeV2(UMA.UMAData.UMARecipe umaRecipe)
    {
        UMAPackRecipe umaPackRecipe = new UMAPackRecipe();

        umaPackRecipe.version = 2;

        int slotCount = umaRecipe.slotDataList.Length - umaRecipe.additionalSlotCount;

        umaPackRecipe.slotsV2 = new PackedSlotDataV2[slotCount];
        if (umaRecipe.raceData != null)
        {
            umaPackRecipe.race = umaRecipe.raceData.raceName;
        }

        foreach (var dna in umaRecipe.GetAllDna())
        {
            UMAPackedDna packedDna = new UMAPackedDna();
            packedDna.dnaType   = dna.GetType().Name;
            packedDna.packedDna = UMA.UMADna.SaveInstance(dna);
            umaPackRecipe.packedDna.Add(packedDna);
        }

        umaPackRecipe.sharedColorCount = 0;
        if (umaRecipe.sharedColors != null)
        {
            umaPackRecipe.sharedColorCount = umaRecipe.sharedColors.Length;
        }
        List <OverlayColorData>         colorEntries       = new List <OverlayColorData>(umaPackRecipe.sharedColorCount);
        List <PackedOverlayColorDataV3> packedColorEntries = new List <PackedOverlayColorDataV3>(umaPackRecipe.sharedColorCount);

        for (int i = 0; i < umaPackRecipe.sharedColorCount; i++)
        {
            colorEntries.Add(umaRecipe.sharedColors[i]);
            packedColorEntries.Add(new PackedOverlayColorDataV3(umaRecipe.sharedColors[i]));
        }

        for (int i = 0; i < slotCount; i++)
        {
            if (umaRecipe.slotDataList[i] != null)
            {
                PackedSlotDataV2 tempPackedSlotData = new PackedSlotDataV2();
                umaPackRecipe.slotsV2[i] = tempPackedSlotData;

                tempPackedSlotData.id    = umaRecipe.slotDataList[i].asset.slotName;
                tempPackedSlotData.scale = Mathf.FloorToInt(umaRecipe.slotDataList[i].overlayScale * 100);

                bool copiedOverlays = false;
                for (int i2 = 0; i2 < i; i2++)
                {
                    if (umaRecipe.slotDataList[i2] != null && umaPackRecipe.slotsV2[i2] != null)
                    {
                        if (umaRecipe.slotDataList[i].GetOverlayList() == umaRecipe.slotDataList[i2].GetOverlayList())
                        {
                            tempPackedSlotData.copyIdx = i2;
                            copiedOverlays             = true;
                            break;
                        }
                    }
                }
                if (copiedOverlays)
                {
                    continue;
                }

                tempPackedSlotData.overlays = new PackedOverlayDataV2[umaRecipe.slotDataList[i].OverlayCount];

                for (int overlayIdx = 0; overlayIdx < tempPackedSlotData.overlays.Length; overlayIdx++)
                {
                    PackedOverlayDataV2 tempPackedOverlay = new PackedOverlayDataV2();

                    OverlayData overlayData = umaRecipe.slotDataList[i].GetOverlay(overlayIdx);
                    tempPackedOverlay.id      = overlayData.asset.overlayName;
                    tempPackedOverlay.rect    = new int[4];
                    tempPackedOverlay.rect[0] = Mathf.FloorToInt(overlayData.rect.x);
                    tempPackedOverlay.rect[1] = Mathf.FloorToInt(overlayData.rect.y);
                    tempPackedOverlay.rect[2] = Mathf.FloorToInt(overlayData.rect.width);
                    tempPackedOverlay.rect[3] = Mathf.FloorToInt(overlayData.rect.height);

                    OverlayColorData colorData = overlayData.colorData;
                    // Could not use IndexOf to find color, since operator == overriden in OverlayColorData
                    int colorIndex = -1;
                    for (int col = 0; col < colorEntries.Count; col++)
                    {
                        if (colorEntries[col].GetHashCode() == colorData.GetHashCode())
                        {
                            colorIndex = col;
                        }
                    }


                    if (colorIndex < 0)
                    {
                        PackedOverlayColorDataV3 newColorEntry = new PackedOverlayColorDataV3(colorData);
                        packedColorEntries.Add(newColorEntry);
                        colorIndex = colorEntries.Count;
                        colorEntries.Add(colorData);
                    }
                    tempPackedOverlay.colorIdx = colorIndex;

                    tempPackedSlotData.overlays[overlayIdx] = tempPackedOverlay;
                }
            }
        }

        umaPackRecipe.fColors = packedColorEntries.ToArray();
        return(umaPackRecipe);
    }
コード例 #3
0
ファイル: UMAPackedRecipeBase.cs プロジェクト: Jaimi/UMA
    /*
    public static UMAPackRecipe PackRecipeV1(UMA.UMAData.UMARecipe umaRecipe)
    {
        UMAPackRecipe umaPackRecipe = new UMAPackRecipe();

        //var umaPackRecipe = new Packed
        int slotCount = umaRecipe.slotDataList.Length - umaRecipe.AdditionalSlots;
        umaPackRecipe.packedSlotDataList = new packedSlotData[slotCount];
        umaPackRecipe.race = umaRecipe.raceData.raceName;

        foreach (var dna in umaRecipe.GetAllDna())
        {
            UMAPackedDna packedDna = new UMAPackedDna();
            packedDna.dnaType = dna.GetType().Name;
            packedDna.packedDna = UMA.UMADna.SaveInstance(dna);
            umaPackRecipe.packedDna.Add(packedDna);
        }

        for (int i = 0; i < slotCount; i++)
        {
            if (umaRecipe.slotDataList[i] != null)
            {
                packedSlotData tempPackedSlotData = new packedSlotData();
                umaPackRecipe.packedSlotDataList[i] = tempPackedSlotData;

                tempPackedSlotData.slotID = umaRecipe.slotDataList[i].asset.slotName;
                tempPackedSlotData.overlayScale = Mathf.FloorToInt(umaRecipe.slotDataList[i].overlayScale * 100);

                bool copiedOverlays = false;
                for (int i2 = 0; i2 < i; i2++)
                {
                    if (umaRecipe.slotDataList[i2] != null && umaPackRecipe.packedSlotDataList[i2] != null)
                    {
                        if (umaRecipe.slotDataList[i].GetOverlayList() == umaRecipe.slotDataList[i2].GetOverlayList())
                        {
                            tempPackedSlotData.copyOverlayIndex = i2;
                            copiedOverlays = true;
                            break;
                        }
                    }
                }
                if( copiedOverlays ) continue;

                tempPackedSlotData.OverlayDataList = new packedOverlayData[umaRecipe.slotDataList[i].OverlayCount];

                for (int overlayID = 0; overlayID < tempPackedSlotData.OverlayDataList.Length; overlayID++)
                {
                    tempPackedSlotData.OverlayDataList[overlayID] = new packedOverlayData();
                    tempPackedSlotData.OverlayDataList[overlayID].overlayID = umaRecipe.slotDataList[i].GetOverlay(overlayID).asset.overlayName;
                    OverlayColorData colorData = umaRecipe.slotDataList[i].GetOverlay(overlayID).colorData;
                    if (colorData.color != Color.white)
                    {
                        Color32 color = umaRecipe.slotDataList[i].GetOverlay(overlayID).colorData.color;
                        tempPackedSlotData.OverlayDataList[overlayID].colorList = new int[4];
                        tempPackedSlotData.OverlayDataList[overlayID].colorList[0] = color.r;
                        tempPackedSlotData.OverlayDataList[overlayID].colorList[1] = color.g;
                        tempPackedSlotData.OverlayDataList[overlayID].colorList[2] = color.b;
                        tempPackedSlotData.OverlayDataList[overlayID].colorList[3] = color.a;
                    }

                    if (umaRecipe.slotDataList[i].GetOverlay(overlayID).rect != new Rect(0, 0, 0, 0))
                    {
                        //Might need float in next version
                        tempPackedSlotData.OverlayDataList[overlayID].rectList = new int[4];
                        tempPackedSlotData.OverlayDataList[overlayID].rectList[0] = (int)umaRecipe.slotDataList[i].GetOverlay(overlayID).rect.x;
                        tempPackedSlotData.OverlayDataList[overlayID].rectList[1] = (int)umaRecipe.slotDataList[i].GetOverlay(overlayID).rect.y;
                        tempPackedSlotData.OverlayDataList[overlayID].rectList[2] = (int)umaRecipe.slotDataList[i].GetOverlay(overlayID).rect.width;
                        tempPackedSlotData.OverlayDataList[overlayID].rectList[3] = (int)umaRecipe.slotDataList[i].GetOverlay(overlayID).rect.height;
                    }

                    if (colorData.channelMask != null && colorData.channelMask.Length > 0)
                    {
                        tempPackedSlotData.OverlayDataList[overlayID].channelMaskList = new int[colorData.channelMask.Length][];

                        for (int channelAdjust = 0; channelAdjust < colorData.channelMask.Length; channelAdjust++)
                        {
                            tempPackedSlotData.OverlayDataList[overlayID].channelMaskList[channelAdjust] = new int[4];
                            tempPackedSlotData.OverlayDataList[overlayID].channelMaskList[channelAdjust][0] = colorData.channelMask[channelAdjust].r;
                            tempPackedSlotData.OverlayDataList[overlayID].channelMaskList[channelAdjust][1] = colorData.channelMask[channelAdjust].g;
                            tempPackedSlotData.OverlayDataList[overlayID].channelMaskList[channelAdjust][2] = colorData.channelMask[channelAdjust].b;
                            tempPackedSlotData.OverlayDataList[overlayID].channelMaskList[channelAdjust][3] = colorData.channelMask[channelAdjust].a;
                        }

                    }
                    if (colorData.channelAdditiveMask != null)
                    {
                        tempPackedSlotData.OverlayDataList[overlayID].channelAdditiveMaskList = new int[colorData.channelAdditiveMask.Length][];
                        for (int channelAdjust = 0; channelAdjust < colorData.channelAdditiveMask.Length; channelAdjust++)
                        {
                            tempPackedSlotData.OverlayDataList[overlayID].channelAdditiveMaskList[channelAdjust] = new int[4];
                            tempPackedSlotData.OverlayDataList[overlayID].channelAdditiveMaskList[channelAdjust][0] = colorData.channelAdditiveMask[channelAdjust].r;
                            tempPackedSlotData.OverlayDataList[overlayID].channelAdditiveMaskList[channelAdjust][1] = colorData.channelAdditiveMask[channelAdjust].g;
                            tempPackedSlotData.OverlayDataList[overlayID].channelAdditiveMaskList[channelAdjust][2] = colorData.channelAdditiveMask[channelAdjust].b;
                            tempPackedSlotData.OverlayDataList[overlayID].channelAdditiveMaskList[channelAdjust][3] = colorData.channelAdditiveMask[channelAdjust].a;
                        }

                    }
                }
            }
        }
        return umaPackRecipe;
    }
    */
    public static UMAPackRecipe PackRecipeV2(UMA.UMAData.UMARecipe umaRecipe)
    {
        UMAPackRecipe umaPackRecipe = new UMAPackRecipe();
        umaPackRecipe.version = 2;

        int slotCount = umaRecipe.slotDataList.Length - umaRecipe.additionalSlotCount;
        umaPackRecipe.slotsV2 = new PackedSlotDataV2[slotCount];
        if (umaRecipe.raceData != null)
        {
            umaPackRecipe.race = umaRecipe.raceData.raceName;
        }

        foreach (var dna in umaRecipe.GetAllDna())
        {
            UMAPackedDna packedDna = new UMAPackedDna();
            packedDna.dnaType = dna.GetType().Name;
            packedDna.packedDna = UMA.UMADna.SaveInstance(dna);
            umaPackRecipe.packedDna.Add(packedDna);
        }

        umaPackRecipe.sharedColorCount = 0;
        if (umaRecipe.sharedColors != null)
            umaPackRecipe.sharedColorCount = umaRecipe.sharedColors.Length;
        List<OverlayColorData> colorEntries = new List<OverlayColorData>(umaPackRecipe.sharedColorCount);
        List<PackedOverlayColorDataV3> packedColorEntries = new List<PackedOverlayColorDataV3>(umaPackRecipe.sharedColorCount);
        for (int i = 0; i < umaPackRecipe.sharedColorCount; i++)
        {
            colorEntries.Add(umaRecipe.sharedColors[i]);
            packedColorEntries.Add(new PackedOverlayColorDataV3(umaRecipe.sharedColors[i]));
        }

        for (int i = 0; i < slotCount; i++)
        {
            if (umaRecipe.slotDataList[i] != null)
            {
                PackedSlotDataV2 tempPackedSlotData = new PackedSlotDataV2();
                umaPackRecipe.slotsV2[i] = tempPackedSlotData;

                tempPackedSlotData.id = umaRecipe.slotDataList[i].asset.slotName;
                tempPackedSlotData.scale = Mathf.FloorToInt(umaRecipe.slotDataList[i].overlayScale * 100);

                bool copiedOverlays = false;
                for (int i2 = 0; i2 < i; i2++)
                {
                    if (umaRecipe.slotDataList[i2] != null && umaPackRecipe.slotsV2[i2] != null)
                    {
                        if (umaRecipe.slotDataList[i].GetOverlayList() == umaRecipe.slotDataList[i2].GetOverlayList())
                        {
                            tempPackedSlotData.copyIdx = i2;
                            copiedOverlays = true;
                            break;
                        }
                    }
                }
                if( copiedOverlays ) continue;

                tempPackedSlotData.overlays = new PackedOverlayDataV2[umaRecipe.slotDataList[i].OverlayCount];

                for (int overlayIdx = 0; overlayIdx < tempPackedSlotData.overlays.Length; overlayIdx++)
                {
                    PackedOverlayDataV2 tempPackedOverlay = new PackedOverlayDataV2();

                    OverlayData overlayData = umaRecipe.slotDataList[i].GetOverlay(overlayIdx);
                    tempPackedOverlay.id = overlayData.asset.overlayName;
                    tempPackedOverlay.rect = new int[4];
                    tempPackedOverlay.rect[0] = Mathf.FloorToInt(overlayData.rect.x);
                    tempPackedOverlay.rect[1] = Mathf.FloorToInt(overlayData.rect.y);
                    tempPackedOverlay.rect[2] = Mathf.FloorToInt(overlayData.rect.width);
                    tempPackedOverlay.rect[3] = Mathf.FloorToInt(overlayData.rect.height);

                    OverlayColorData colorData = overlayData.colorData;
                    int colorIndex = colorEntries.IndexOf(colorData);
                    if (colorIndex < 0)
                    {
                        PackedOverlayColorDataV3 newColorEntry = new PackedOverlayColorDataV3(colorData);
                        packedColorEntries.Add(newColorEntry);
                        colorIndex = colorEntries.Count;
                        colorEntries.Add(colorData);
                    }
                    tempPackedOverlay.colorIdx = colorIndex;

                    tempPackedSlotData.overlays[overlayIdx] = tempPackedOverlay;
                }
            }
        }

        umaPackRecipe.fColors = packedColorEntries.ToArray();
        return umaPackRecipe;
    }
コード例 #4
0
ファイル: DKUMAData.cs プロジェクト: aliasn456/Folio
    public virtual void PackRecipe()
    {
        umaPackRecipe.packedSlotDataList = new packedSlotData[umaRecipe.slotDataList.Length];
        umaPackRecipe.race = umaRecipe.raceData.raceName;
        //	Debug.Log ( " Autosaving 5 (Race) : "+umaPackRecipe.race );
        // DNA
        umaPackRecipe.packedDna.Clear();
        foreach (var dna in umaRecipe.umaDna.Values)
        {
            //	Debug.Log ( " Autosaving 6 "+dna.Names[1].ToString()+" / "/*+dna.Values[0].ToString()*/);
            // UMA
            UMAPackedDna packedDna = new UMAPackedDna();
            packedDna.dnaType = dna.GetType().Name;

            packedDna.packedDna = DKUMADna.SaveInstance(dna);

            umaPackRecipe.packedDna.Add(packedDna);
        }


        // DK UMA

/*		DK_UMAPackedDna DK_packedDna = new DK_UMAPackedDna();
 *              DK_packedDna.dnaType = "Modifyers";
 *              DK_packedDna.tmpDNAList = DNAList2;
 *              //	DK_packedDna.packedDna = UMADna.SaveInstance(dna);
 *              umaPackRecipe.DKpackedDna = DK_packedDna;
 *              //	Debug.Log ( DK_packedDna.dnaType );
 *
 *              foreach (var dna in DNAList2) {
 *                      string _value = dna.Value.ToString ("f3");
 *                      dna.Value = float.Parse (_value);
 *              }
 */
        // Slots
        for (int i = 0; i < umaRecipe.slotDataList.Length; i++)
        {
            if (umaRecipe.slotDataList[i] != null)
            {
                if (umaRecipe.slotDataList[i].listID != -1 && umaPackRecipe.packedSlotDataList[i] == null)
                {
                    packedSlotData tempPackedSlotData;

                    tempPackedSlotData = new packedSlotData();

                    tempPackedSlotData.sID = umaRecipe.slotDataList[i].slotName;
                    tempPackedSlotData.oS  = Mathf.FloorToInt(umaRecipe.slotDataList[i].overlayScale * 100);
                    tempPackedSlotData.ODL = new DKUMAData.packedOverlayData[umaRecipe.slotDataList[i].overlayList.Count];

                    for (int oID = 0; oID < tempPackedSlotData.ODL.Length; oID++)
                    {
                        tempPackedSlotData.ODL[oID]     = new packedOverlayData();
                        tempPackedSlotData.ODL[oID].oID = umaRecipe.slotDataList[i].overlayList[oID].overlayName;

                        if (umaRecipe.slotDataList[i].overlayList[oID].color != new Color(1.0f, 1.0f, 1.0f, 1.0f))
                        {
                            //Color32 instead of Color?
                            tempPackedSlotData.ODL[oID].cL    = new int[4];
                            tempPackedSlotData.ODL[oID].cL[0] = Mathf.FloorToInt(umaRecipe.slotDataList[i].overlayList[oID].color.r * 255.0f);
                            tempPackedSlotData.ODL[oID].cL[1] = Mathf.FloorToInt(umaRecipe.slotDataList[i].overlayList[oID].color.g * 255.0f);
                            tempPackedSlotData.ODL[oID].cL[2] = Mathf.FloorToInt(umaRecipe.slotDataList[i].overlayList[oID].color.b * 255.0f);
                            tempPackedSlotData.ODL[oID].cL[3] = Mathf.FloorToInt(umaRecipe.slotDataList[i].overlayList[oID].color.a * 255.0f);
                        }

                        if (umaRecipe.slotDataList[i].overlayList[oID].rect != new Rect(0, 0, 0, 0))
                        {
                            //Might need float in next version
                            tempPackedSlotData.ODL[oID].rL    = new int[4];
                            tempPackedSlotData.ODL[oID].rL[0] = (int)umaRecipe.slotDataList[i].overlayList[oID].rect.x;
                            tempPackedSlotData.ODL[oID].rL[1] = (int)umaRecipe.slotDataList[i].overlayList[oID].rect.y;
                            tempPackedSlotData.ODL[oID].rL[2] = (int)umaRecipe.slotDataList[i].overlayList[oID].rect.width;
                            tempPackedSlotData.ODL[oID].rL[3] = (int)umaRecipe.slotDataList[i].overlayList[oID].rect.height;
                        }

                        if (umaRecipe.slotDataList[i].overlayList[oID].channelMask != null)
                        {
                            tempPackedSlotData.ODL[oID].cML = new int[umaRecipe.slotDataList[i].overlayList[oID].channelMask.Length][];

                            for (int channelAdjust = 0; channelAdjust < umaRecipe.slotDataList[i].overlayList[oID].channelMask.Length; channelAdjust++)
                            {
                                tempPackedSlotData.ODL[oID].cML[channelAdjust]    = new int[4];
                                tempPackedSlotData.ODL[oID].cML[channelAdjust][0] = umaRecipe.slotDataList[i].overlayList[oID].channelMask[channelAdjust].r;
                                tempPackedSlotData.ODL[oID].cML[channelAdjust][1] = umaRecipe.slotDataList[i].overlayList[oID].channelMask[channelAdjust].g;
                                tempPackedSlotData.ODL[oID].cML[channelAdjust][2] = umaRecipe.slotDataList[i].overlayList[oID].channelMask[channelAdjust].b;
                                tempPackedSlotData.ODL[oID].cML[channelAdjust][3] = umaRecipe.slotDataList[i].overlayList[oID].channelMask[channelAdjust].a;
                            }
                        }
                        if (umaRecipe.slotDataList[i].overlayList[oID].channelAdditiveMask != null)
                        {
                            tempPackedSlotData.ODL[oID].cAML = new int[umaRecipe.slotDataList[i].overlayList[oID].channelAdditiveMask.Length][];
                            for (int channelAdjust = 0; channelAdjust < umaRecipe.slotDataList[i].overlayList[oID].channelAdditiveMask.Length; channelAdjust++)
                            {
                                tempPackedSlotData.ODL[oID].cAML[channelAdjust]    = new int[4];
                                tempPackedSlotData.ODL[oID].cAML[channelAdjust][0] = umaRecipe.slotDataList[i].overlayList[oID].channelAdditiveMask[channelAdjust].r;
                                tempPackedSlotData.ODL[oID].cAML[channelAdjust][1] = umaRecipe.slotDataList[i].overlayList[oID].channelAdditiveMask[channelAdjust].g;
                                tempPackedSlotData.ODL[oID].cAML[channelAdjust][2] = umaRecipe.slotDataList[i].overlayList[oID].channelAdditiveMask[channelAdjust].b;
                                tempPackedSlotData.ODL[oID].cAML[channelAdjust][3] = umaRecipe.slotDataList[i].overlayList[oID].channelAdditiveMask[channelAdjust].a;
                            }
                        }
                    }

                    umaPackRecipe.packedSlotDataList[i] = tempPackedSlotData;

                    //Shared overlays wont generate duplicated data
                    for (int i2 = i + 1; i2 < umaRecipe.slotDataList.Length; i2++)
                    {
                        if (umaRecipe.slotDataList[i2] != null)
                        {
                            if (umaPackRecipe.packedSlotDataList[i2] == null)
                            {
                                if (umaRecipe.slotDataList[i].overlayList == umaRecipe.slotDataList[i2].overlayList)
                                {
                                    tempPackedSlotData     = new packedSlotData();
                                    tempPackedSlotData.sID = umaRecipe.slotDataList[i2].slotName;
                                    tempPackedSlotData.cOI = i;
                                    //umaPackRecipe.packedSlotDataList[i2] = tempPackedSlotData;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
コード例 #5
0
    public static UMAPackRecipe PackRecipe(UMA.UMAData.UMARecipe umaRecipe)
    {
        UMAPackRecipe umaPackRecipe = new UMAPackRecipe();

        //var umaPackRecipe = new Packed
        umaPackRecipe.packedSlotDataList = new packedSlotData[umaRecipe.slotDataList.Length];
        umaPackRecipe.race = umaRecipe.raceData.raceName;

        umaPackRecipe.packedDna.Clear();

        foreach (var dna in umaRecipe.GetAllDna())
        {
            UMAPackedDna packedDna = new UMAPackedDna();
            packedDna.dnaType   = dna.GetType().Name;
            packedDna.packedDna = UMA.UMADna.SaveInstance(dna);
            umaPackRecipe.packedDna.Add(packedDna);
        }

        for (int i = 0; i < umaRecipe.slotDataList.Length; i++)
        {
            if (umaRecipe.slotDataList[i] != null)
            {
                if (umaRecipe.slotDataList[i].listID != -1 && umaPackRecipe.packedSlotDataList[i] == null)
                {
                    packedSlotData tempPackedSlotData;

                    tempPackedSlotData = new packedSlotData();

                    tempPackedSlotData.slotID          = umaRecipe.slotDataList[i].slotName;
                    tempPackedSlotData.overlayScale    = Mathf.FloorToInt(umaRecipe.slotDataList[i].overlayScale * 100);
                    tempPackedSlotData.OverlayDataList = new packedOverlayData[umaRecipe.slotDataList[i].OverlayCount];

                    for (int overlayID = 0; overlayID < tempPackedSlotData.OverlayDataList.Length; overlayID++)
                    {
                        tempPackedSlotData.OverlayDataList[overlayID]           = new packedOverlayData();
                        tempPackedSlotData.OverlayDataList[overlayID].overlayID = umaRecipe.slotDataList[i].GetOverlay(overlayID).overlayName;

                        if (umaRecipe.slotDataList[i].GetOverlay(overlayID).color != new Color(1.0f, 1.0f, 1.0f, 1.0f))
                        {
                            //Color32 instead of Color?
                            tempPackedSlotData.OverlayDataList[overlayID].colorList    = new int[4];
                            tempPackedSlotData.OverlayDataList[overlayID].colorList[0] = Mathf.FloorToInt(umaRecipe.slotDataList[i].GetOverlay(overlayID).color.r * 255.0f);
                            tempPackedSlotData.OverlayDataList[overlayID].colorList[1] = Mathf.FloorToInt(umaRecipe.slotDataList[i].GetOverlay(overlayID).color.g * 255.0f);
                            tempPackedSlotData.OverlayDataList[overlayID].colorList[2] = Mathf.FloorToInt(umaRecipe.slotDataList[i].GetOverlay(overlayID).color.b * 255.0f);
                            tempPackedSlotData.OverlayDataList[overlayID].colorList[3] = Mathf.FloorToInt(umaRecipe.slotDataList[i].GetOverlay(overlayID).color.a * 255.0f);
                        }

                        if (umaRecipe.slotDataList[i].GetOverlay(overlayID).rect != new Rect(0, 0, 0, 0))
                        {
                            //Might need float in next version
                            tempPackedSlotData.OverlayDataList[overlayID].rectList    = new int[4];
                            tempPackedSlotData.OverlayDataList[overlayID].rectList[0] = (int)umaRecipe.slotDataList[i].GetOverlay(overlayID).rect.x;
                            tempPackedSlotData.OverlayDataList[overlayID].rectList[1] = (int)umaRecipe.slotDataList[i].GetOverlay(overlayID).rect.y;
                            tempPackedSlotData.OverlayDataList[overlayID].rectList[2] = (int)umaRecipe.slotDataList[i].GetOverlay(overlayID).rect.width;
                            tempPackedSlotData.OverlayDataList[overlayID].rectList[3] = (int)umaRecipe.slotDataList[i].GetOverlay(overlayID).rect.height;
                        }

                        if (umaRecipe.slotDataList[i].GetOverlay(overlayID).channelMask != null)
                        {
                            tempPackedSlotData.OverlayDataList[overlayID].channelMaskList = new int[umaRecipe.slotDataList[i].GetOverlay(overlayID).channelMask.Length][];

                            for (int channelAdjust = 0; channelAdjust < umaRecipe.slotDataList[i].GetOverlay(overlayID).channelMask.Length; channelAdjust++)
                            {
                                tempPackedSlotData.OverlayDataList[overlayID].channelMaskList[channelAdjust]    = new int[4];
                                tempPackedSlotData.OverlayDataList[overlayID].channelMaskList[channelAdjust][0] = umaRecipe.slotDataList[i].GetOverlay(overlayID).channelMask[channelAdjust].r;
                                tempPackedSlotData.OverlayDataList[overlayID].channelMaskList[channelAdjust][1] = umaRecipe.slotDataList[i].GetOverlay(overlayID).channelMask[channelAdjust].g;
                                tempPackedSlotData.OverlayDataList[overlayID].channelMaskList[channelAdjust][2] = umaRecipe.slotDataList[i].GetOverlay(overlayID).channelMask[channelAdjust].b;
                                tempPackedSlotData.OverlayDataList[overlayID].channelMaskList[channelAdjust][3] = umaRecipe.slotDataList[i].GetOverlay(overlayID).channelMask[channelAdjust].a;
                            }
                        }
                        if (umaRecipe.slotDataList[i].GetOverlay(overlayID).channelAdditiveMask != null)
                        {
                            tempPackedSlotData.OverlayDataList[overlayID].channelAdditiveMaskList = new int[umaRecipe.slotDataList[i].GetOverlay(overlayID).channelAdditiveMask.Length][];
                            for (int channelAdjust = 0; channelAdjust < umaRecipe.slotDataList[i].GetOverlay(overlayID).channelAdditiveMask.Length; channelAdjust++)
                            {
                                tempPackedSlotData.OverlayDataList[overlayID].channelAdditiveMaskList[channelAdjust]    = new int[4];
                                tempPackedSlotData.OverlayDataList[overlayID].channelAdditiveMaskList[channelAdjust][0] = umaRecipe.slotDataList[i].GetOverlay(overlayID).channelAdditiveMask[channelAdjust].r;
                                tempPackedSlotData.OverlayDataList[overlayID].channelAdditiveMaskList[channelAdjust][1] = umaRecipe.slotDataList[i].GetOverlay(overlayID).channelAdditiveMask[channelAdjust].g;
                                tempPackedSlotData.OverlayDataList[overlayID].channelAdditiveMaskList[channelAdjust][2] = umaRecipe.slotDataList[i].GetOverlay(overlayID).channelAdditiveMask[channelAdjust].b;
                                tempPackedSlotData.OverlayDataList[overlayID].channelAdditiveMaskList[channelAdjust][3] = umaRecipe.slotDataList[i].GetOverlay(overlayID).channelAdditiveMask[channelAdjust].a;
                            }
                        }
                    }

                    umaPackRecipe.packedSlotDataList[i] = tempPackedSlotData;

                    //Shared overlays wont generate duplicated data
                    for (int i2 = i + 1; i2 < umaRecipe.slotDataList.Length; i2++)
                    {
                        if (umaRecipe.slotDataList[i2] != null)
                        {
                            if (umaPackRecipe.packedSlotDataList[i2] == null)
                            {
                                if (umaRecipe.slotDataList[i].GetOverlayList() == umaRecipe.slotDataList[i2].GetOverlayList())
                                {
                                    tempPackedSlotData                  = new packedSlotData();
                                    tempPackedSlotData.slotID           = umaRecipe.slotDataList[i2].slotName;
                                    tempPackedSlotData.copyOverlayIndex = i;
                                    //umaPackRecipe.packedSlotDataList[i2] = tempPackedSlotData;
                                }
                            }
                        }
                    }
                }
            }
        }
        return(umaPackRecipe);
    }
コード例 #6
0
    public static UMAPackRecipe PackRecipe(UMA.UMAData.UMARecipe umaRecipe)
    {
        UMAPackRecipe umaPackRecipe = new UMAPackRecipe();

        //var umaPackRecipe = new Packed
        umaPackRecipe.packedSlotDataList = new packedSlotData[umaRecipe.slotDataList.Length];
        umaPackRecipe.race = umaRecipe.raceData.raceName;

        umaPackRecipe.packedDna.Clear();

        foreach (var dna in umaRecipe.umaDna.Values)
        {
            UMAPackedDna packedDna = new UMAPackedDna();
            packedDna.dnaType = dna.GetType().Name;
            packedDna.packedDna = UMA.UMADna.SaveInstance(dna);
            umaPackRecipe.packedDna.Add(packedDna);
        }

        for (int i = 0; i < umaRecipe.slotDataList.Length; i++)
        {
            if (umaRecipe.slotDataList[i] != null)
            {
                if (umaRecipe.slotDataList[i].listID != -1 && umaPackRecipe.packedSlotDataList[i] == null)
                {
                    packedSlotData tempPackedSlotData;

                    tempPackedSlotData = new packedSlotData();

                    tempPackedSlotData.slotID = umaRecipe.slotDataList[i].slotName;
                    tempPackedSlotData.overlayScale = Mathf.FloorToInt(umaRecipe.slotDataList[i].overlayScale * 100);
                    tempPackedSlotData.OverlayDataList = new packedOverlayData[umaRecipe.slotDataList[i].OverlayCount];

                    for (int overlayID = 0; overlayID < tempPackedSlotData.OverlayDataList.Length; overlayID++)
                    {
                        tempPackedSlotData.OverlayDataList[overlayID] = new packedOverlayData();
                        tempPackedSlotData.OverlayDataList[overlayID].overlayID = umaRecipe.slotDataList[i].GetOverlay(overlayID).overlayName;

                        if (umaRecipe.slotDataList[i].GetOverlay(overlayID).color != new Color(1.0f, 1.0f, 1.0f, 1.0f))
                        {
                            //Color32 instead of Color?
                            tempPackedSlotData.OverlayDataList[overlayID].colorList = new int[4];
                            tempPackedSlotData.OverlayDataList[overlayID].colorList[0] = Mathf.FloorToInt(umaRecipe.slotDataList[i].GetOverlay(overlayID).color.r * 255.0f);
                            tempPackedSlotData.OverlayDataList[overlayID].colorList[1] = Mathf.FloorToInt(umaRecipe.slotDataList[i].GetOverlay(overlayID).color.g * 255.0f);
                            tempPackedSlotData.OverlayDataList[overlayID].colorList[2] = Mathf.FloorToInt(umaRecipe.slotDataList[i].GetOverlay(overlayID).color.b * 255.0f);
                            tempPackedSlotData.OverlayDataList[overlayID].colorList[3] = Mathf.FloorToInt(umaRecipe.slotDataList[i].GetOverlay(overlayID).color.a * 255.0f);
                        }

                        if (umaRecipe.slotDataList[i].GetOverlay(overlayID).rect != new Rect(0, 0, 0, 0))
                        {
                            //Might need float in next version
                            tempPackedSlotData.OverlayDataList[overlayID].rectList = new int[4];
                            tempPackedSlotData.OverlayDataList[overlayID].rectList[0] = (int)umaRecipe.slotDataList[i].GetOverlay(overlayID).rect.x;
                            tempPackedSlotData.OverlayDataList[overlayID].rectList[1] = (int)umaRecipe.slotDataList[i].GetOverlay(overlayID).rect.y;
                            tempPackedSlotData.OverlayDataList[overlayID].rectList[2] = (int)umaRecipe.slotDataList[i].GetOverlay(overlayID).rect.width;
                            tempPackedSlotData.OverlayDataList[overlayID].rectList[3] = (int)umaRecipe.slotDataList[i].GetOverlay(overlayID).rect.height;
                        }

                        if (umaRecipe.slotDataList[i].GetOverlay(overlayID).channelMask != null)
                        {
                            tempPackedSlotData.OverlayDataList[overlayID].channelMaskList = new int[umaRecipe.slotDataList[i].GetOverlay(overlayID).channelMask.Length][];

                            for (int channelAdjust = 0; channelAdjust < umaRecipe.slotDataList[i].GetOverlay(overlayID).channelMask.Length; channelAdjust++)
                            {
                                tempPackedSlotData.OverlayDataList[overlayID].channelMaskList[channelAdjust] = new int[4];
                                tempPackedSlotData.OverlayDataList[overlayID].channelMaskList[channelAdjust][0] = umaRecipe.slotDataList[i].GetOverlay(overlayID).channelMask[channelAdjust].r;
                                tempPackedSlotData.OverlayDataList[overlayID].channelMaskList[channelAdjust][1] = umaRecipe.slotDataList[i].GetOverlay(overlayID).channelMask[channelAdjust].g;
                                tempPackedSlotData.OverlayDataList[overlayID].channelMaskList[channelAdjust][2] = umaRecipe.slotDataList[i].GetOverlay(overlayID).channelMask[channelAdjust].b;
                                tempPackedSlotData.OverlayDataList[overlayID].channelMaskList[channelAdjust][3] = umaRecipe.slotDataList[i].GetOverlay(overlayID).channelMask[channelAdjust].a;
                            }

                        }
                        if (umaRecipe.slotDataList[i].GetOverlay(overlayID).channelAdditiveMask != null)
                        {
                            tempPackedSlotData.OverlayDataList[overlayID].channelAdditiveMaskList = new int[umaRecipe.slotDataList[i].GetOverlay(overlayID).channelAdditiveMask.Length][];
                            for (int channelAdjust = 0; channelAdjust < umaRecipe.slotDataList[i].GetOverlay(overlayID).channelAdditiveMask.Length; channelAdjust++)
                            {
                                tempPackedSlotData.OverlayDataList[overlayID].channelAdditiveMaskList[channelAdjust] = new int[4];
                                tempPackedSlotData.OverlayDataList[overlayID].channelAdditiveMaskList[channelAdjust][0] = umaRecipe.slotDataList[i].GetOverlay(overlayID).channelAdditiveMask[channelAdjust].r;
                                tempPackedSlotData.OverlayDataList[overlayID].channelAdditiveMaskList[channelAdjust][1] = umaRecipe.slotDataList[i].GetOverlay(overlayID).channelAdditiveMask[channelAdjust].g;
                                tempPackedSlotData.OverlayDataList[overlayID].channelAdditiveMaskList[channelAdjust][2] = umaRecipe.slotDataList[i].GetOverlay(overlayID).channelAdditiveMask[channelAdjust].b;
                                tempPackedSlotData.OverlayDataList[overlayID].channelAdditiveMaskList[channelAdjust][3] = umaRecipe.slotDataList[i].GetOverlay(overlayID).channelAdditiveMask[channelAdjust].a;
                            }

                        }
                    }

                    umaPackRecipe.packedSlotDataList[i] = tempPackedSlotData;

                    //Shared overlays wont generate duplicated data
                    for (int i2 = i + 1; i2 < umaRecipe.slotDataList.Length; i2++)
                    {
                        if (umaRecipe.slotDataList[i2] != null)
                        {
                            if (umaPackRecipe.packedSlotDataList[i2] == null)
                            {
                                if (umaRecipe.slotDataList[i].GetOverlayList() == umaRecipe.slotDataList[i2].GetOverlayList())
                                {
                                    tempPackedSlotData = new packedSlotData();
                                    tempPackedSlotData.slotID = umaRecipe.slotDataList[i2].slotName;
                                    tempPackedSlotData.copyOverlayIndex = i;
                                    //umaPackRecipe.packedSlotDataList[i2] = tempPackedSlotData;
                                }
                            }
                        }
                    }
                }
            }
        }
        return umaPackRecipe;
    }