void SortingItems(ref List <MyInventoryItem> items) { foreach (var item in items) { if (item.Type.TypeId == "MyObjectBuilder_Component" && Components.ContainsKey(item.Type.SubtypeId)) // Если имя сходится с тем что в словаре { Components[item.Type.SubtypeId].Amount += item.Amount.ToIntSafe(); } else if (item.Type.TypeId == "MyObjectBuilder_Ingot" && Ingots.ContainsKey(item.Type.SubtypeId)) { Ingots[item.Type.SubtypeId].Amount += item.Amount.ToIntSafe(); } else if (item.Type.TypeId == "MyObjectBuilder_Ore" && Ores.ContainsKey(item.Type.SubtypeId)) { Ores[item.Type.SubtypeId].Amount += item.Amount.ToIntSafe(); } else if (item.Type.TypeId == "MyObjectBuilder_PhysicalGunObject" && Tools.ContainsKey(item.Type.SubtypeId)) { Tools[item.Type.SubtypeId].Amount += item.Amount.ToIntSafe(); } else if (item.Type.TypeId == "MyObjectBuilder_OxygenContainerObject" && Oxygen.ContainsKey(item.Type.SubtypeId)) { Oxygen[item.Type.SubtypeId].Amount += item.Amount.ToIntSafe(); } else if (item.Type.TypeId == "MyObjectBuilder_GasContainerObject" && Hydrogen.ContainsKey(item.Type.SubtypeId)) { Hydrogen[item.Type.SubtypeId].Amount += item.Amount.ToIntSafe(); } else if (item.Type.TypeId == "MyObjectBuilder_AmmoMagazine" && Ammo.ContainsKey(item.Type.SubtypeId)) { Ammo[item.Type.SubtypeId].Amount += item.Amount.ToIntSafe(); } else { Warning += $"\n[{item.Type.TypeId}/{item.Type.SubtypeId}] отсутствует в словарях"; } } }