Esempio n. 1
0
        // Check inventory/gather count. checkOre = check for ore, if false, check for ignots
        void CheckInventoryOfBlock(IMyTerminalBlock block, bool checkOre)
        {
            MaterialStatus currentStatus = _ignotStatus;
            string         typeId        = "MyObjectBuilder_Ignot";

            if (checkOre)
            {
                currentStatus = _oreStatus;
                typeId        = "MyObjectBuilder_Ore";
            }

            var inventory = block.GetInventory();

            foreach (var item in inventory.GetItems())
            {
                if (item.Content.TypeId.ToString() == typeId)
                {
                    switch (item.Content.SubtypeId.ToString())
                    {
                    case "Iron":
                        currentStatus.SetMaterial(ItemType.Iron);
                        currentStatus.AddAmount(ItemType.Iron, (float)item.Amount.RawValue / 1000000);
                        break;

                    case "Nickel":
                        currentStatus.SetMaterial(ItemType.Nickel);
                        currentStatus.AddAmount(ItemType.Nickel, (float)item.Amount.RawValue / 1000000);
                        break;

                    case "Cobalt":
                        currentStatus.SetMaterial(ItemType.Cobalt);
                        currentStatus.AddAmount(ItemType.Cobalt, (float)item.Amount.RawValue / 1000000);
                        break;

                    case "Magnesium":
                        currentStatus.SetMaterial(ItemType.Magnesium);
                        currentStatus.AddAmount(ItemType.Magnesium, (float)item.Amount.RawValue / 1000000);
                        break;

                    case "Silicon":
                        currentStatus.SetMaterial(ItemType.Silicon);
                        currentStatus.AddAmount(ItemType.Silicon, (float)item.Amount.RawValue / 1000000);
                        break;

                    case "Silver":
                        currentStatus.SetMaterial(ItemType.Silver);
                        currentStatus.AddAmount(ItemType.Silver, (float)item.Amount.RawValue / 1000000);
                        break;

                    case "Gold":
                        currentStatus.SetMaterial(ItemType.Gold);
                        currentStatus.AddAmount(ItemType.Gold, (float)item.Amount.RawValue / 1000000);
                        break;

                    case "Platinum":
                        currentStatus.SetMaterial(ItemType.Platinum);
                        currentStatus.AddAmount(ItemType.Platinum, (float)item.Amount.RawValue / 1000000);
                        break;

                    case "Uranium":
                        currentStatus.SetMaterial(ItemType.Uranium);
                        currentStatus.AddAmount(ItemType.Uranium, (float)item.Amount.RawValue / 1000000);
                        break;

                    default:
                        break;
                    }
                }
            }
        }