You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.7 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TWS_ItemCustomizationApplier : MonoBehaviour
{
public string catagoryName = "Hairstyle";
public List<TWS_CustomizableItem> availableCustomizableVariations;
private List<TWS_AppliedCustomizationsData> currentAppliedCustomizations=new List<TWS_AppliedCustomizationsData>();
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<TWS_AppliedCustomizationsData> GetAppliedCustomizationData()
{
return currentAppliedCustomizations;
}
}