예제 #1
0
            /// <summary>
            /// Shallow copy of UMARecipe.
            /// </summary>
            public UMARecipe Mirror()
            {
                var newRecipe = new UMARecipe();

                newRecipe.raceData     = raceData;
                newRecipe.umaDna       = umaDna;
                newRecipe.slotDataList = slotDataList;
                return(newRecipe);
            }
예제 #2
0
 /// <summary>
 /// Adds additional, non serialized, recipes.
 /// </summary>
 /// <param name="umaAdditionalRecipes">Additional recipes.</param>
 /// <param name="context">Context.</param>
 public void AddAdditionalRecipes(UMARecipeBase[] umaAdditionalRecipes, UMAContext context)
 {
     if (umaAdditionalRecipes != null)
     {
         foreach (var umaAdditionalRecipe in umaAdditionalRecipes)
         {
             UMARecipe cachedRecipe = umaAdditionalRecipe.GetCachedRecipe(context);
             umaRecipe.Merge(cachedRecipe, true);
         }
     }
 }
예제 #3
0
        void Awake()
        {
            firstBake = true;

            if (!umaGenerator)
            {
                umaGenerator = GameObject.Find("UMAGenerator").GetComponent <UMAGeneratorBase>();
            }

            if (umaRecipe == null)
            {
                umaRecipe = new UMARecipe();
            }
            else
            {
                SetupOnAwake();
            }
        }
예제 #4
0
            /// <summary>
            /// Combine additional recipe with current data.
            /// </summary>
            /// <param name="recipe">Recipe.</param>
            /// <param name="additional">If set to <c>true</c> recipe will not be serialized.</param>
            public void Merge(UMARecipe recipe, bool additional)
            {
                if (recipe == null)
                {
                    return;
                }

                if ((recipe.raceData != null) && (recipe.raceData != raceData))
                {
                    Debug.LogWarning("Merging recipe with conflicting race data: " + recipe.raceData.name);
                }

                foreach (var dnaEntry in recipe.umaDna)
                {
                    var destDNA = GetOrCreateDna(dnaEntry.Key);
                    destDNA.Values = dnaEntry.Value.Values;
                }

                mergedSharedColors.Clear();
                if (sharedColors == null)
                {
                    sharedColors = new OverlayColorData[0];
                }
                if (recipe.sharedColors != null)
                {
                    for (int i = 0; i < sharedColors.Length; i++)
                    {
                        if ((sharedColors[i] != null) && sharedColors[i].HasName())
                        {
                            mergedSharedColors.Add(sharedColors[i].name, i);
                        }
                    }

                    for (int i = 0; i < recipe.sharedColors.Length; i++)
                    {
                        OverlayColorData sharedColor = recipe.sharedColors[i];
                        if (sharedColor.HasName())
                        {
                            int sharedIndex;
                            if (!mergedSharedColors.TryGetValue(sharedColor.name, out sharedIndex))
                            {
                                int index = sharedColors.Length;
                                mergedSharedColors.Add(sharedColor.name, index);
                                Array.Resize <OverlayColorData>(ref sharedColors, index + 1);
                                sharedColors[index] = sharedColor.Duplicate();
                            }
                        }
                    }
                }

                if (slotDataList == null)
                {
                    slotDataList = new SlotData[0];
                }
                if (recipe.slotDataList != null)
                {
                    for (int i = 0; i < recipe.slotDataList.Length; i++)
                    {
                        MergeSlot(recipe.slotDataList[i], additional);
                    }
                }
            }
예제 #5
0
 void init(UMAGeneratorBase generator, [InjectOptional] UMARecipe recipe)
 {
     this.umaGenerator = generator;
     this.umaRecipe    = recipe;
 }