public void ConnectToInventory(Dictionary <InventoryItem, uGUI_ItemIcon> lookup) { this.InventoryMapping = lookup; (BioReactor.container as IItemsContainer).onAddItem += OnAddItemLate; if (MaterialsProcessing.Count == 0) { return; } foreach (KeyValuePair <InventoryItem, uGUI_ItemIcon> pair in lookup) { InventoryItem item = pair.Key; uGUI_ItemIcon icon = pair.Value; BioEnergy bioEnergy = MaterialsProcessing.Find(m => m.Pickupable == item.item); if (bioEnergy is null) { continue; } bioEnergy.AddDisplayText(icon); } }
private void OnAddItemLate(InventoryItem item) { if (this.InventoryMapping is null) { return; } if (this.InventoryMapping.TryGetValue(item, out uGUI_ItemIcon icon)) { BioEnergy bioEnergy = MaterialsProcessing.Find(m => m.Pickupable == item.item); if (bioEnergy is null) { return; } bioEnergy.AddDisplayText(icon); } }
private void OnAddItem(InventoryItem item) { if (isLoadingSaveData) { return; } if (BaseBioReactor.charge.TryGetValue(item.item.GetTechType(), out float bioEnergyValue) && bioEnergyValue > 0f) { var bioenergy = new BioEnergy(item.item, bioEnergyValue, bioEnergyValue) { Size = item.width * item.height }; MaterialsProcessing.Add(bioenergy); } else { GameObject.Destroy(item.item); } }