Exemple #1
0
        public void Dispense()
        {
            Point3 coordinates = m_componentBlockEntity.Coordinates;
            int    data        = Terrain.ExtractData(Utils.Terrain.GetCellValue(coordinates.X, coordinates.Y, coordinates.Z));
            int    direction   = FourDirectionalBlock.GetDirection(Utils.Terrain.GetCellValue(coordinates.X, coordinates.Y, coordinates.Z));

            Driller(coordinates, direction);
            int num = 0;
            int slotValue;

            while (true)
            {
                if (num >= SlotsCount - 1)
                {
                    return;
                }
                slotValue = GetSlotValue(num);
                int slotCount = GetSlotCount(num);
                if (slotValue != 0 && slotCount > 0)
                {
                    break;
                }
                num++;
            }
            MachineMode mode = DrillerBlock.GetMode(data);

            if (mode == MachineMode.Shoot)
            {
                int num2 = RemoveSlotItems(num, 1);
                for (int i = 0; i < num2; i++)
                {
                    DispenseItem(coordinates, direction, slotValue, mode);
                }
            }
        }
        public new void Dispense()
        {
            Point3 coordinates = m_componentBlockEntity.Coordinates;

            //DispenserNew2Block.GetMode(data);
            Driller(coordinates, FourDirectionalBlock.GetDirection(Utils.Terrain.GetCellValue(coordinates.X, coordinates.Y, coordinates.Z)));
        }
Exemple #3
0
        public bool Place()
        {
            Point3 coordinates = m_componentBlockEntity.Coordinates;
            int    cellValue   = Utils.Terrain.GetCellValue(coordinates.X, coordinates.Y, coordinates.Z);

            if (Terrain.ExtractContents(cellValue) != Bullet2Block.Index || (Terrain.ExtractData(cellValue) >> 10) == 0)
            {
                return(false);
            }
            int num = 0;
            int slotValue;

            while (true)
            {
                if (num >= SlotsCount - 1)
                {
                    return(false);
                }
                slotValue = GetSlotValue(num);
                int slotCount = GetSlotCount(num);
                if (slotValue != 0 && slotCount > 0)
                {
                    break;
                }
                num++;
            }
            int face = FourDirectionalBlock.GetDirection(cellValue);

            for (num = RemoveSlotItems(num, 1); num-- > 0;)
            {
                var     position = new Vector3(coordinates) + new Vector3(0.5f);
                Vector3 vector   = CellFace.FaceToVector3(face);
                if (!Place(position + vector, face, slotValue) && DispenseItem)
                {
                    Vector3 vector2 = position + 0.6f * vector;
                    Utils.SubsystemPickables.AddPickable(slotValue, 1, vector2, 1.8f * (vector + m_random.Vector3(0.2f, false)), null);
                    Utils.SubsystemAudio.PlaySound("Audio/DispenserDispense", 1f, 0f, new Vector3(vector2.X, vector2.Y, vector2.Z), 3f, true);
                }
            }
            return(true);
        }
Exemple #4
0
        public void Update(float dt)
        {
            Point3 coordinates = m_componentBlockEntity.Coordinates;

            if (m_updateSmeltingRecipe)
            {
                m_updateSmeltingRecipe = false;
                result[0] = m_matchedIngredients[7];
                result[1] = m_matchedIngredients[8];
                result[2] = m_matchedIngredients[9];
                bool flag = FindSmeltingRecipe(5f);
                if (result[0] != m_matchedIngredients[7] || result[1] != m_matchedIngredients[8] || result[2] != m_matchedIngredients[9])
                {
                    SmeltingProgress = 0f;
                    m_time           = 0;
                }
                m_smeltingRecipe2 = flag;
                if (flag != m_smeltingRecipe)
                {
                    m_smeltingRecipe = flag;
                    SmeltingProgress = 0f;
                    m_time           = 0;
                }
            }
            if (m_smeltingRecipe2 && Utils.SubsystemTime.PeriodicGameTimeEvent(0.2, 0.0))
            {
                int num = 1;
                int num2 = 0;
                var point = CellFace.FaceToPoint3(FourDirectionalBlock.GetDirection(Utils.Terrain.GetCellValue(coordinates.X, coordinates.Y, coordinates.Z)));
                int num3 = coordinates.X - point.X;
                int num4 = coordinates.Y - point.Y;
                int num5 = coordinates.Z - point.Z, v;
                for (int i = -1; i < 2; i++)
                {
                    for (int j = -1; j < 3; j++)
                    {
                        for (int k = -1; k < 2; k++)
                        {
                            int cellValue     = Terrain.ReplaceLight(Utils.Terrain.GetCellValue(num3 + i, num4 + j, num5 + k), 0);
                            int cellContents2 = Terrain.ExtractContents(cellValue);
                            if (j == 1 && cellValue != (MetalBlock.Index | 96 << 14))
                            {
                                num = 0;
                                break;
                            }
                            if (i * i + k * k == 1 && j == 0 && cellContents2 == 0 && ((v = Utils.Terrain.GetCellValue(num3 + 2 * i, num4 + j, num5 + 2 * k)) != (BlastBlowerBlock.Index | FurnaceNBlock.SetHeatLevel(Terrain.ExtractData(v), 1) << 14)) && (num3 + i != coordinates.X || num5 + k != coordinates.Z))
                            {
                                num = 0;
                                break;
                            }
                            if (i * i + k * k == 1 && j == 0 && cellContents2 == 0)
                            {
                                num2++;
                            }
                            if (i * i + k * k == 1 && j == 0 && cellContents2 != 0 && cellValue != (MetalBlock.Index | 96 << 14) && (num3 + i != coordinates.X || num5 + k != coordinates.Z))
                            {
                                num = 0;
                                break;
                            }
                            if (i * i + k * k == 2 && j == 0 && cellValue != (MetalBlock.Index | 96 << 14))
                            {
                                num = 0;
                                break;
                            }
                            if (j < 0 && cellValue != (MetalBlock.Index | 64 << 14))
                            {
                                num = 0;
                                break;
                            }
                        }
                    }
                }
                if (num == 0 || num2 == 0)
                {
                    m_smeltingRecipe = false;
                }
                if (num == 1 && num2 >= 2 && !m_smeltingRecipe)
                {
                    m_smeltingRecipe = m_smeltingRecipe2;
                }
            }

            if (!m_smeltingRecipe)
            {
                HeatLevel           = 0f;
                m_fireTimeRemaining = 0f;
                SmeltingProgress    = 0f;
            }
            if (m_smeltingRecipe && m_fireTimeRemaining <= 0f)
            {
                HeatLevel = 5f;
            }
            if (m_smeltingRecipe)
            {
                SmeltingProgress = MathUtils.Min(SmeltingProgress + 0.1f * dt, 1f);
                if (SmeltingProgress >= 1f)
                {
                    int[] array = new int[]
                    {
                        IronIngotBlock.Index,
                        ItemBlock.IdTable["ScrapIron"],
                        ItemBlock.IdTable["AluminumOrePowder"],
                        ItemBlock.IdTable["ChromiumOrePowder"],
                        ItemBlock.IdTable["CokeCoalPowder"]
                    };
                    for (int l = 0; l < 5; l++)
                    {
                        if (m_matchedIngredients[l] > 0)
                        {
                            int b = array[l];
                            for (int m = 0; m < m_furnaceSize; m++)
                            {
                                if (m_slots[m].Count > 0 && GetSlotValue(m) == b)
                                {
                                    if (m_slots[m].Count >= m_matchedIngredients[l])
                                    {
                                        m_slots[m].Count       -= m_matchedIngredients[l];
                                        m_matchedIngredients[l] = 0;
                                    }
                                    else
                                    {
                                        m_matchedIngredients[l] -= m_slots[m].Count;
                                        m_slots[m].Count         = 0;
                                    }
                                    if (m_matchedIngredients[l] == 0)
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    if (m_matchedIngredients[5] >= 1)
                    {
                        m_slots[ResultSlotIndex].Value  = ItemBlock.IdTable["SteelIngot"];
                        m_slots[ResultSlotIndex].Count += m_matchedIngredients[5];
                    }
                    if (m_matchedIngredients[6] >= 1)
                    {
                        m_slots[ResultSlotIndex].Value  = IronIngotBlock.Index;
                        m_slots[ResultSlotIndex].Count += m_matchedIngredients[6];
                    }
                    if (m_matchedIngredients[7] >= 1)
                    {
                        m_slots[ResultSlotIndex].Value  = ItemBlock.IdTable["FeAlCrAlloyIngot"];
                        m_slots[ResultSlotIndex].Count += m_matchedIngredients[7];
                    }
                    m_smeltingRecipe       = false;
                    SmeltingProgress       = 0f;
                    m_updateSmeltingRecipe = true;
                }
            }
        }