/// <summary> /// Deep copy of the OverlayData. /// </summary> public OverlayData Duplicate() { var res = new OverlayData(asset); res.rect = rect; if (colorData != null) { res.colorData = colorData.Duplicate(); } return(res); }
/// <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); } } }