/// <summary> /// Shallow copy of UMARecipe. /// </summary> public UMARecipe Mirror() { var newRecipe = new UMARecipe(); newRecipe.raceData = raceData; newRecipe.umaDna = umaDna; newRecipe.slotDataList = slotDataList; return(newRecipe); }
/// <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); } } }
void Awake() { firstBake = true; if (!umaGenerator) { umaGenerator = GameObject.Find("UMAGenerator").GetComponent <UMAGeneratorBase>(); } if (umaRecipe == null) { umaRecipe = new UMARecipe(); } else { SetupOnAwake(); } }
/// <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); } } }
void init(UMAGeneratorBase generator, [InjectOptional] UMARecipe recipe) { this.umaGenerator = generator; this.umaRecipe = recipe; }