private void CookItems() { var items = AttachedContainer.Container.Items.ToArray(); foreach (Item item in items) { Microwaveable microwaveable = item.GetComponent <Microwaveable>(); if (microwaveable != null) { ItemHelpers.ReplaceItem(item, ItemHelpers.CreateItem(microwaveable.ResultingObject)); } else { ItemHelpers.ReplaceItem(item, ItemHelpers.CreateItem(DestroyedItemPrefab)); } } }
private void CookItems() { var items = AttachedContainer.Container.Items.ToArray(); // tries to get a microweavable in each item that is in the container foreach (Item item in items) { Microwaveable microwaveable = item.GetComponent <Microwaveable>(); if (microwaveable != null) { // if the microwaveable has a result we produce it ItemHelpers.ReplaceItem(item, ItemHelpers.CreateItem(microwaveable.ResultingObject)); } else { // if there's no recipe we throw trash ItemHelpers.ReplaceItem(item, ItemHelpers.CreateItem(DestroyedItemPrefab)); } } }
private void CookItems() { List <Item> items = container.GetItems(); for (var i = 0; i < items.Count; i++) { Item item = items[i]; if (item == null) { continue; } Microwaveable microwaveable = item.GetComponent <Microwaveable>(); if (microwaveable != null) { ItemHelpers.ReplaceItem(item, ItemHelpers.CreateItem(microwaveable.ResultingObject)); } else { ItemHelpers.ReplaceItem(item, ItemHelpers.CreateItem(DestroyedItemPrefab)); } } }