public UMADynamicCharacterAvatarRecipe(DynamicCharacterAvatar dca, string recipeName = "", DynamicCharacterAvatar.SaveOptions customSaveOptions = DynamicCharacterAvatar.SaveOptions.useDefaults)
 {
     recipeType = "DynamicCharacterAvatar";
     if (customSaveOptions.HasFlag(DynamicCharacterAvatar.SaveOptions.useDefaults))
     {
         customSaveOptions = dca.defaultSaveOptions;
     }
     if (recipeName == "")
     {
         recipeName = dca.gameObject.name;
     }
     recipeString = JsonUtility.ToJson(new DCSPackRecipe(dca, recipeName, "DynamicCharacterAvatar", customSaveOptions));
 }
Example #2
0
        /// <summary>
        /// Use this model for saving a DCS Avatar to a light weight json string. Use the save options flags to determine what aspects of the avatar are saved
        /// </summary>
        /// <param name="dcaToSave"></param>
        /// <param name="recipeName"></param>
        /// <param name="recipeType"></param>
        /// <param name="saveOptions"></param>
        /// <param name="slotsToSave"></param>
        public DCSPackRecipe(DynamicCharacterAvatar dcaToSave, string recipeName, string pRecipeType, DynamicCharacterAvatar.SaveOptions saveOptions, params string[] slotsToSave)
        {
            if (pRecipeType != "DynamicCharacterAvatar")
            {
                Debug.LogWarning("DCSPackRecipe Type can only be used for recipeTypes 'DynamicCharacterAvatar'");
                return;
            }
            var recipeToSave = dcaToSave.umaData.umaRecipe;

            packedRecipeType = pRecipeType;
            name             = recipeName;
            race             = dcaToSave.activeRace.racedata.raceName;
            if (saveOptions.HasFlag(DynamicCharacterAvatar.SaveOptions.saveDNA))
            {
                dna = GetPackedDNA(recipeToSave);
            }
            if (saveOptions.HasFlag(DynamicCharacterAvatar.SaveOptions.saveColors))
            {
                characterColors = new List <PackedOverlayColorDataV3>();
                for (int i = 0; i < recipeToSave.sharedColors.Length; i++)
                {
                    characterColors.Add(new PackedOverlayColorDataV3(recipeToSave.sharedColors[i]));
                }
            }
            if (saveOptions.HasFlag(DynamicCharacterAvatar.SaveOptions.saveWardrobe))
            {
                wardrobeSet = GenerateWardrobeSet(dcaToSave.WardrobeRecipes, slotsToSave);
            }
            if (saveOptions.HasFlag(DynamicCharacterAvatar.SaveOptions.saveAnimator))
            {
                if (dcaToSave.animationController != null)
                {
                    raceAnimatorController = (dcaToSave.animationController.name);
                }
            }
        }