/// <summary> /// Adds the reagent to inventory. /// </summary> /// <param name="reagent">Reagent to be added.</param> /// <param name="r">The component info.</param> public void AddReagentToInventory(ReagentPot reagent, Compound r) { ItemInventoryBase item = new ItemInventoryBase(); item.HoldItem(reagent); item.addReagent(r); addItem(ref item); }
public void onClick(int index) { if (item is Glassware) { switch (actualIDs[index]) { case 0: if (!item.GetComponent <Glassware>().hasReagents()) { GameObject temp = null; for (int i = 0; i < prefabs.Count; i++) { if (((item as Glassware).gl.Contains(prefabs[i].GetComponent <Glassware>().name))) { temp = prefabs[i]; } } GameObject.Find("InventoryManager").GetComponent <InventoryManager>().AddGlasswareToInventory(temp.GetComponent <Glassware>()); Destroy(item.gameObject); } else { if (GetComponentInParent <WorkBench>().equipmentController != null && item.transform.parent == GetComponentInParent <WorkBench>().positionGlassEquipament) { GetComponentInParent <WorkBench>().equipmentController.RemoveObjectInEquipament(item.gameObject); } GameObject.Find("InventoryManager").GetComponent <InventoryManager>().AddProductToInventory(item.gameObject); } break; case 1: GetComponentInParent <WorkBench>().PutGlassInEquip(item.gameObject); break; case 2: GetComponentInParent <WorkBench>().PutItemFromEquip(item.gameObject); break; } } if (item is ReagentPot) { switch (actualIDs[index]) { case 0: ItemInventoryBase reagent = new ItemInventoryBase(); Compound r = (item as ReagentPot).reagent.Clone() as Compound; reagent.addReagent(r); int prefabIndex = reagent.getItemType() == ItemType.Liquids?0:1; GameObject.Find("InventoryManager").GetComponent <InventoryManager>().AddReagentToInventory(prefabs[prefabIndex].GetComponent <ReagentPot>(), r); Destroy(item.gameObject); break; } } ui_manager.CloseAll(); }