public void AddItemToggle(WearableItem item, int amount) { if (item == null) { return; } if (itemToggles.ContainsKey(item.id)) { return; } ItemToggle newToggle; if (item.IsCollectible()) { newToggle = itemToggleFactory.CreateItemToggleFromRarity(item.rarity, itemContainer); newToggle.transform.SetAsFirstSibling(); } else { newToggle = itemToggleFactory.CreateBaseWearable(itemContainer); } newToggle.Initialize(item, false, amount); newToggle.OnClicked += ToggleClicked; newToggle.OnSellClicked += SellClicked; itemToggles.Add(item.id, newToggle); bool active = string.IsNullOrEmpty(currentBodyShape) || item.SupportsBodyShape(currentBodyShape); newToggle.gameObject.SetActive(active); }
private void EquipWearable(WearableItem wearable) { if (!wearablesByCategory.ContainsKey(wearable.category)) { return; } if (wearablesByCategory[wearable.category].Contains(wearable) && wearable.SupportsBodyShape(model.bodyShape.id) && !model.wearables.Contains(wearable)) { var toReplace = GetWearablesReplacedBy(wearable); toReplace.ForEach(UnequipWearable); model.wearables.Add(wearable); view.SelectWearable(wearable); } }