protected virtual UMACrowdRandomSet.CrowdRaceData SetGeneratedUMARace(UMAData.UMARecipe umaRecipe) { if (randomPool != null && randomPool.Length > 0) { int randomResult = Random.Range(0, randomPool.Length); UMACrowdRandomSet.CrowdRaceData race = randomPool[randomResult].data; umaRecipe.SetRace(raceLibrary.GetRace(race.raceID)); return race; } else { umaRecipe.SetRace(raceLibrary.GetRace("RACHumanFemale")); return null; } }
/// <summary> /// Fills in a UMA recipe with random partial fragments from the sections. /// </summary> /// <param name="umaRecipe">UMA recipe.</param> /// <param name="context">Context.</param> public void FillUMARecipe(UMAData.UMARecipe umaRecipe, UMAContext context) { if (raceData == null) { Debug.LogWarning("Race Data must be set!"); return; } umaRecipe.SetRace(raceData); int sectionCount = (recipeSections == null) ? 0 : recipeSections.Length; for (int i = 0; i < sectionCount; i++) { RecipeSection section = recipeSections[i]; if ((section.recipes == null) || (section.recipes.Length == 0)) continue; switch (section.selectionRule) { case SelectionType.IncludeNone: break; case SelectionType.IncludeAll: for (int j = 0; j < section.recipes.Length; j++) { IncludeRecipe(section.recipes[j], umaRecipe, context, false); } break; case SelectionType.IncludeSome: float chance = 1f / (float)(section.recipes.Length + 1); for (int j = 0; j < section.recipes.Length; j++) { if (Random.value < chance) { IncludeRecipe(section.recipes[j], umaRecipe, context, false); } } break; case SelectionType.IncludeOne: default: int index = Random.Range(0, section.recipes.Length); IncludeRecipe(section.recipes[index], umaRecipe, context, false); break; } } for (int i = 0; i < additionalRecipes.Length; i++) { IncludeRecipe(additionalRecipes[i], umaRecipe, context, true); } }