protected static List <CASParts.Wrapper> GetVisibleCASParts(CASLogic ths, BodyTypes bodyType, uint categories) { uint alteredCategories = categories; ths.AdjustAvailableCategoriesForCASMode(ref alteredCategories); SimBuilder builder = ths.mBuilder; CASAgeGenderFlags age = builder.Age; CASAgeGenderFlags gender = builder.Gender; CASAgeGenderFlags species = builder.Species; List <CASParts.Wrapper> list = new List <CASParts.Wrapper>(); foreach (CASParts.Wrapper part in CASBase.HairParts) { InvalidPartBase.Reason reason = InvalidPartBooter.Allow(part, age, gender, species, false, (OutfitCategories)categories); if (reason != InvalidPartBase.Reason.None) { continue; } if ((part.mPart.BodyType == bodyType) && OutfitUtils.PartMatchesSim(builder, alteredCategories, part.mPart)) { list.Add(part); } } return(list); }
public static InvalidPartBase.Reason Allow(CASParts.Wrapper part, CASAgeGenderFlags age, CASAgeGenderFlags gender, CASAgeGenderFlags species, bool maternity, OutfitCategories category) { OutfitCategoriesExtended extended = (OutfitCategoriesExtended)0; if ((part.ExtendedCategory & OutfitCategoriesExtended.IsHat) == OutfitCategoriesExtended.IsHat) { extended |= OutfitCategoriesExtended.IsHat; } if (maternity) { extended |= OutfitCategoriesExtended.ValidForMaternity; } if (species == CASAgeGenderFlags.Human) { switch (part.BodyType) { case BodyTypes.FullBody: case BodyTypes.LowerBody: case BodyTypes.UpperBody: case BodyTypes.Shoes: case BodyTypes.Hair: switch (age) { case CASAgeGenderFlags.Baby: case CASAgeGenderFlags.Toddler: case CASAgeGenderFlags.Child: if (part.Age != age) { return(InvalidPartBase.Reason.ImproperAge); } break; default: if ((part.Age & (CASAgeGenderFlags.Baby | CASAgeGenderFlags.Toddler | CASAgeGenderFlags.Child)) != CASAgeGenderFlags.None) { return(InvalidPartBase.Reason.ImproperAge); } break; } break; } } InvalidPartBase.Reason reason = InvalidPartBase.Reason.None; if ((sValidPartsByKey.Count > 0) || (sValidPartsByType.Count > 0)) { List <InvalidPartBase> tests; if (sValidPartsByKey.TryGetValue(part.Key, out tests)) { foreach (InvalidPartBase test in tests) { if (test.Allow(age, gender, species, category, extended, out reason)) { return(InvalidPartBase.Reason.None); } } } if (sValidPartsByType.TryGetValue(part.BodyType, out tests)) { foreach (InvalidPartBase test in tests) { if (test.Allow(age, gender, species, category, extended, out reason)) { return(InvalidPartBase.Reason.None); } } } return(InvalidPartBase.Reason.ValidFail); } else { List <InvalidPartBase> tests; if (sInvalidPartsByKey.TryGetValue(part.Key, out tests)) { foreach (InvalidPartBase test in tests) { if (!test.Allow(age, gender, species, category, extended, out reason)) { return(reason); } } } if (sInvalidPartsByType.TryGetValue(part.BodyType, out tests)) { foreach (InvalidPartBase test in tests) { if (!test.Allow(age, gender, species, category, extended, out reason)) { return(reason); } } } return(InvalidPartBase.Reason.None); } }
public override ArrayList GetVisibleCASParts(BodyTypes bodyType, uint categories) { try { List <CASParts.Wrapper> list = SubGetVisibleCASParts(bodyType, categories); //ArrayList list = base.GetVisibleCASParts(bodyType, categories); StackTrace trace = new StackTrace(false); int blackListCount = 0; CASClothingCategory clothingCategory = CASClothingCategory.gSingleton; if (clothingCategory != null) { // Fix for an issue where this listing is never cleared by the Core if (clothingCategory.PartPresetsList != null) { clothingCategory.PartPresetsList.Clear(); } } bool truncate = false; if (list.Count > 0) { bool found = false; foreach (StackFrame frame in trace.GetFrames()) { if (frame.GetMethod().DeclaringType == sDelayedCategoryUpdate) { found = true; break; } } if (!found) { foreach (StackFrame frame in trace.GetFrames()) { if ((frame.GetMethod().DeclaringType == sCASClothingCategory) && (frame.GetMethod().ToString() == "Void HideUnusedIcons()")) { truncate = true; break; } else if ((frame.GetMethod().DeclaringType == sCASClothingCategory) && (frame.GetMethod().ToString() == "Void LoadParts()")) { truncate = true; if ((clothingCategory != null) && (clothingCategory.mClothingTypesGrid != null)) { clothingCategory.mClothingTypesGrid.Clear(); } CASClothingCategoryEx.DelayedCategoryUpdate.Perform(); break; } } if (truncate) { List <CASParts.Wrapper> newList = new List <CASParts.Wrapper>(); newList.Add(list[0]); list = newList; } } } if ((!truncate) && (InvalidPartBooter.HasInvalidParts)) { SimBuilder builder = CASLogic.Instance.mBuilder; CASAgeGenderFlags age = builder.Age; CASAgeGenderFlags gender = builder.Gender; CASAgeGenderFlags species = builder.Species; List <CASParts.Wrapper> newList = new List <CASParts.Wrapper>(); foreach (CASParts.Wrapper part in list) { InvalidPartBase.Reason reason = InvalidPartBooter.Allow(part, age, gender, species, false, (OutfitCategories)categories); if (reason == InvalidPartBase.Reason.None) { newList.Add(part); } else { blackListCount++; } } list.Clear(); list = newList; } ArrayList results = new ArrayList(); foreach (CASParts.Wrapper part in list) { results.Add(part.mPart); } return(results); } catch (Exception e) { Common.Exception("GetVisibleCASParts", e); return(new ArrayList()); } }