using System.Collections; using System.Collections.Generic; using UnityEngine; public class TWS_ItemCustomizationApplier : MonoBehaviour { public string catagoryName = "Hairstyle"; public List availableCustomizableVariations; private List currentAppliedCustomizations=new List(); public void ApplyCustomizationData(TWS_AppliedCustomizationsData appliedCustomization) { RemoveAllAppliedCustomizationData(); availableCustomizableVariations.ForEach(item => item.DisableCustomization()); TWS_CustomizableItem fetchedItem = availableCustomizableVariations.Find(x=>x.customizableItemData.itemMetaData.itemID.Equals(appliedCustomization.customizationData.itemMetaData.itemID)); Debug.LogError("Item found: " + appliedCustomization.catagoryName + "___" + fetchedItem.customizableItemData.itemMetaData.itemID); fetchedItem.EnableCustomization(); AddToCurrentAppliedCustomizations(appliedCustomization); } void AddToCurrentAppliedCustomizations(TWS_AppliedCustomizationsData data) { if (!CheckIfItemExists(data)) { currentAppliedCustomizations.Add(data); } } bool CheckIfItemExists(TWS_AppliedCustomizationsData data) { int index = currentAppliedCustomizations.FindIndex(x => x.customizationData.itemMetaData.itemID == data.customizationData.itemMetaData.itemID); return index >= 0; } void RemoveAllAppliedCustomizationData() { currentAppliedCustomizations.Clear(); } public List GetAppliedCustomizationData() { return currentAppliedCustomizations; } }