public static int CalculateChangedOutfits(Sim sim, Dictionary<OutfitCategories, List<SimOutfit>> beforeCas) { int outfitCount = 0; //How many parts need to match so we declare it a match int kFullPartCount = 2; int kCurrentFullPartCount = kFullPartCount; try { Dictionary<OutfitCategories, List<SimOutfit>> afterCas = ReturnClothingInfo(sim); foreach (KeyValuePair<OutfitCategories, List<SimOutfit>> itemBeforeCas in beforeCas) { List<ResourceKey> newOutfitsThatMatch = new List<ResourceKey>(); if (itemBeforeCas.Key == OutfitCategories.Everyday || itemBeforeCas.Key == OutfitCategories.Formalwear || itemBeforeCas.Key == OutfitCategories.Sleepwear || itemBeforeCas.Key == OutfitCategories.Athletic || itemBeforeCas.Key == OutfitCategories.Swimwear || itemBeforeCas.Key == OutfitCategories.Outerwear) { int index = 0; int matchCount = 0; int numberOfNewOutfits = afterCas[itemBeforeCas.Key].Count; foreach (SimOutfit oldOutfit in itemBeforeCas.Value) { foreach (SimOutfit newOutfit in afterCas[itemBeforeCas.Key]) { //Reset values matchCount = 0; kCurrentFullPartCount = kFullPartCount; for (int i = 0; i < oldOutfit.Parts.Length; i++) { if (/*oldOutfit.Parts[i].DisplayIndex > 0 && */( (oldOutfit.Parts[i].BodyType == BodyTypes.UpperBody) || oldOutfit.Parts[i].BodyType == BodyTypes.LowerBody || oldOutfit.Parts[i].BodyType == BodyTypes.FullBody)) { //If full body, there is 1 less part to match if (oldOutfit.Parts[i].BodyType == BodyTypes.FullBody) kCurrentFullPartCount--; for (int j = 0; j < newOutfit.Parts.Length; j++) { if (newOutfit.Parts[j].BodyType == BodyTypes.UpperBody || newOutfit.Parts[j].BodyType == BodyTypes.LowerBody || newOutfit.Parts[j].BodyType == BodyTypes.FullBody) { NRaas.CommonSpace.Helpers.CASParts.Wrapper wrapperOld = new NRaas.CommonSpace.Helpers.CASParts.Wrapper(oldOutfit.Parts[i]); NRaas.CommonSpace.Helpers.CASParts.Wrapper wrapperNew = new NRaas.CommonSpace.Helpers.CASParts.Wrapper(newOutfit.Parts[j]); if (wrapperNew.mPart.Key == wrapperOld.mPart.Key) { matchCount++; break; } } } } } //If the outfit is a match if (matchCount >= kCurrentFullPartCount) { numberOfNewOutfits--; break; } } //CMShopping.PrintMessage("bare feet: " + barefootOldOutfit + " " + barefootNewOutfit); //CMShopping.PrintMessage(itemBeforeCas.Key.ToString() + ": " + index + ": " + matchCount + " " + kCurrentFullPartCount); index++; } //Number of new outfits outfitCount += numberOfNewOutfits; } } } catch (System.Exception ex) { CMShopping.PrintMessage(ex.Message); } if (outfitCount > 0) return outfitCount; return 0; }
public static int CalculateChangedOutfits(Sim sim, Dictionary <OutfitCategories, List <SimOutfit> > beforeCas) { int outfitCount = 0; //How many parts need to match so we declare it a match int kFullPartCount = 2; int kCurrentFullPartCount = kFullPartCount; try { Dictionary <OutfitCategories, List <SimOutfit> > afterCas = ReturnClothingInfo(sim); foreach (KeyValuePair <OutfitCategories, List <SimOutfit> > itemBeforeCas in beforeCas) { List <ResourceKey> newOutfitsThatMatch = new List <ResourceKey>(); if (itemBeforeCas.Key == OutfitCategories.Everyday || itemBeforeCas.Key == OutfitCategories.Formalwear || itemBeforeCas.Key == OutfitCategories.Sleepwear || itemBeforeCas.Key == OutfitCategories.Athletic || itemBeforeCas.Key == OutfitCategories.Swimwear || itemBeforeCas.Key == OutfitCategories.Outerwear) { int index = 0; int matchCount = 0; int numberOfNewOutfits = afterCas[itemBeforeCas.Key].Count; foreach (SimOutfit oldOutfit in itemBeforeCas.Value) { foreach (SimOutfit newOutfit in afterCas[itemBeforeCas.Key]) { //Reset values matchCount = 0; kCurrentFullPartCount = kFullPartCount; for (int i = 0; i < oldOutfit.Parts.Length; i++) { if (/*oldOutfit.Parts[i].DisplayIndex > 0 && */ ( (oldOutfit.Parts[i].BodyType == BodyTypes.UpperBody) || oldOutfit.Parts[i].BodyType == BodyTypes.LowerBody || oldOutfit.Parts[i].BodyType == BodyTypes.FullBody)) { //If full body, there is 1 less part to match if (oldOutfit.Parts[i].BodyType == BodyTypes.FullBody) { kCurrentFullPartCount--; } for (int j = 0; j < newOutfit.Parts.Length; j++) { if (newOutfit.Parts[j].BodyType == BodyTypes.UpperBody || newOutfit.Parts[j].BodyType == BodyTypes.LowerBody || newOutfit.Parts[j].BodyType == BodyTypes.FullBody) { NRaas.CommonSpace.Helpers.CASParts.Wrapper wrapperOld = new NRaas.CommonSpace.Helpers.CASParts.Wrapper(oldOutfit.Parts[i]); NRaas.CommonSpace.Helpers.CASParts.Wrapper wrapperNew = new NRaas.CommonSpace.Helpers.CASParts.Wrapper(newOutfit.Parts[j]); if (wrapperNew.mPart.Key == wrapperOld.mPart.Key) { matchCount++; break; } } } } } //If the outfit is a match if (matchCount >= kCurrentFullPartCount) { numberOfNewOutfits--; break; } } //CMShopping.PrintMessage("bare feet: " + barefootOldOutfit + " " + barefootNewOutfit); //CMShopping.PrintMessage(itemBeforeCas.Key.ToString() + ": " + index + ": " + matchCount + " " + kCurrentFullPartCount); index++; } //Number of new outfits outfitCount += numberOfNewOutfits; } } } catch (System.Exception ex) { CMShopping.PrintMessage(ex.Message); } if (outfitCount > 0) { return(outfitCount); } return(0); }