public List <WearableItem> GetWearablesReplacedBy(WearableItem wearableItem) { List <WearableItem> wearablesToReplace = new List <WearableItem>(); HashSet <string> categoriesToReplace = new HashSet <string>(wearableItem.GetReplacesList(model.bodyShape.id) ?? new string[0]); int wearableCount = model.wearables.Count; for (int i = 0; i < wearableCount; i++) { var wearable = model.wearables[i]; if (wearable == null) { continue; } if (categoriesToReplace.Contains(wearable.category)) { wearablesToReplace.Add(wearable); } else { //For retrocompatibility's sake we check current wearables against new one (compatibility matrix is symmetrical) HashSet <string> replacesList = new HashSet <string>(wearable.GetReplacesList(model.bodyShape.id) ?? new string[0]); if (replacesList.Contains(wearableItem.category)) { wearablesToReplace.Add(wearable); } } } return(wearablesToReplace); }
public void BeRetrievedProperly() { WearableItem wearableItem = new WearableItem { replaces = new [] { "category1", "category2", "category3" } }; var replaces = wearableItem.GetReplacesList(null); Assert.AreEqual("category1", replaces[0]); Assert.AreEqual("category2", replaces[1]); Assert.AreEqual("category3", replaces[2]); }
public void BeRetrievedProperly() { WearableItem wearableItem = new WearableItem { replaces = new [] { "category1", "category2", "category3" }, representations = new [] { new WearableItem.Representation() { bodyShapes = new [] { "bodyShape1" }, overrideReplaces = new [] { "override1", "override2", "override3" }, } } }; var replaces = wearableItem.GetReplacesList("bodyShape1"); Assert.AreEqual("override1", replaces[0]); Assert.AreEqual("override2", replaces[1]); Assert.AreEqual("override3", replaces[2]); }
public void BeRetrievedWhenBodyShapeDoesntMatchOverride() { WearableItem wearableItem = new WearableItem { data = new WearableItem.Data() { replaces = new [] { "category1", "category2", "category3" }, representations = new [] { new WearableItem.Representation() { bodyShapes = new [] { "bodyShape1" }, overrideReplaces = new [] { "override1", "override2", "override3" }, } } } }; var replaces = wearableItem.GetReplacesList("not_bodyShape1"); Assert.AreEqual("category1", replaces[0]); Assert.AreEqual("category2", replaces[1]); Assert.AreEqual("category3", replaces[2]); }