public override void OnBlockGenerated(int value, int x, int y, int z, bool isLoaded)
 {
     if (FurnaceNBlock.GetHeatLevel(value) != 0)
     {
         AddFire(value, x, y, z);
     }
 }
 public override void OnBlockRemoved(int value, int newValue, int x, int y, int z)
 {
     base.OnBlockRemoved(value, newValue, x, y, z);
     if (FurnaceNBlock.GetHeatLevel(value) != 0)
     {
         RemoveFire(new Point3(x, y, z));
     }
 }
 public override void OnBlockAdded(int value, int oldValue, int x, int y, int z)
 {
     base.OnBlockAdded(value, oldValue, x, y, z);
     if (FurnaceNBlock.GetHeatLevel(value) != 0)
     {
         AddFire(value, x, y, z);
     }
 }
        public override void OnBlockModified(int value, int oldValue, int x, int y, int z)
        {
            switch (FurnaceNBlock.GetHeatLevel(oldValue).CompareTo(FurnaceNBlock.GetHeatLevel(value)))
            {
            case -1: AddFire(value, x, y, z); return;

            case 1: RemoveFire(new Point3(x, y, z)); return;
            }
        }
Example #5
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;
                }
            }
        }
Example #6
0
        public void Update(float dt)
        {
            Point3 coordinates = m_componentBlockEntity.Coordinates;

            if (HeatLevel > 0f)
            {
                m_fireTimeRemaining = MathUtils.Max(0f, m_fireTimeRemaining - dt);
                if (m_fireTimeRemaining == 0f)
                {
                    HeatLevel = 0f;
                }
            }
            if (m_updateSmeltingRecipe)
            {
                m_updateSmeltingRecipe = false;
                m_smeltingRecipe2      = FindSmeltingRecipe();
                if (m_smeltingRecipe2 != m_smeltingRecipe)
                {
                    m_smeltingRecipe = m_smeltingRecipe2;
                    SmeltingProgress = 0f;
                    m_time           = 0;
                    //m_music = 0;
                }
            }

            if (m_smeltingRecipe2 != null && Utils.SubsystemTime.PeriodicGameTimeEvent(0.2, 0.0))
            {
                int num  = 1;
                int num2 = 0;
                int num3 = coordinates.X;
                int num4 = coordinates.Y;
                int num5 = coordinates.Z;
                for (int i = -1; i < 2; i++)
                {
                    for (int j = -1; j < 2; j++)
                    {
                        for (int k = 0; k < 4; k++)
                        {
                            int cellContents = Utils.Terrain.GetCellContents(num3 + i, num4 + j, num5 + k);
                            if (k != 0 && cellContents != MetalBlock.Index)
                            {
                                num = 0;
                                break;
                            }
                            if (k == 0 && i * i + j * j > 1 && cellContents != MetalBlock.Index)
                            {
                                num = 0;
                                break;
                            }
                        }
                    }
                }
                int cellValue = Utils.Terrain.GetCellValue(num3, num4, num5 - 1);
                if ((Terrain.ExtractContents(cellValue) != FireBoxBlock.Index) || FurnaceNBlock.GetHeatLevel(cellValue) == 0)
                {
                    num = 0;
                }
                if (num == 0 || num2 == 0)
                {
                    m_smeltingRecipe = null;
                }
                if (num == 1 && num2 >= 1 && m_smeltingRecipe == null)
                {
                    m_smeltingRecipe = m_smeltingRecipe2;
                }
            }
            if (m_smeltingRecipe == null)
            {
                HeatLevel           = 0f;
                m_fireTimeRemaining = 0f;
                //m_music = -1;
            }
            else
            {
                m_fireTimeRemaining = 100f;
            }
            if (m_fireTimeRemaining <= 0f)
            {
                m_smeltingRecipe = null;
                SmeltingProgress = 0f;
                m_time           = 0;
                //m_music = -1;
            }
            if (m_smeltingRecipe != null)
            {
                SmeltingProgress = MathUtils.Min(SmeltingProgress + 0.1f * dt, 1f);
                if (SmeltingProgress >= 1f)
                {
                    if (m_slots[0].Count > 0)
                    {
                        m_slots[0].Count--;
                    }
                    for (int j = 0; j < 3; j++)
                    {
                        if (result[j] != 0)
                        {
                            int value = result[j];
                            m_slots[1 + j].Value = value;
                            m_slots[1 + j].Count++;
                            m_smeltingRecipe       = null;
                            SmeltingProgress       = 0f;
                            m_updateSmeltingRecipe = true;
                        }
                    }
                }
            }
        }
Example #7
0
        public void Update(float dt)
        {
            Point3 coordinates = m_componentBlockEntity.Coordinates;

            if (HeatLevel > 0f)
            {
                m_fireTimeRemaining = MathUtils.Max(0f, m_fireTimeRemaining - dt);
                if (m_fireTimeRemaining == 0f)
                {
                    HeatLevel = 0f;
                }
            }
            Slot slot;

            if (m_updateSmeltingRecipe)
            {
                m_updateSmeltingRecipe = false;
                float heatLevel = 0f;
                if (HeatLevel > 0f)
                {
                    heatLevel = HeatLevel;
                }
                else
                {
                    slot = m_slots[FuelSlotIndex];
                    if (slot.Count > 0)
                    {
                        Block block = BlocksManager.Blocks[Terrain.ExtractContents(slot.Value)];
                        heatLevel = block is IFuel fuel?fuel.GetHeatLevel(slot.Value) : block.FuelHeatLevel;
                    }
                }
                string text = FindSmeltingRecipe(heatLevel);
                if (text != m_smeltingRecipe)
                {
                    m_smeltingRecipe = text;
                    SmeltingProgress = 0f;
                    //m_music = 0;
                }
            }
            if (m_smeltingRecipe == null)
            {
                HeatLevel           = 0f;
                m_fireTimeRemaining = 0f;
                //m_music = -1;
            }
            if (m_smeltingRecipe != null && m_fireTimeRemaining <= 0f)
            {
                slot = m_slots[FuelSlotIndex];
                if (slot.Count > 0)
                {
                    var block = BlocksManager.Blocks[Terrain.ExtractContents(slot.Value)];
                    if (block.GetExplosionPressure(slot.Value) > 0f)
                    {
                        slot.Count = 0;
                        Utils.SubsystemExplosions.TryExplodeBlock(coordinates.X, coordinates.Y, coordinates.Z, slot.Value);
                    }
                    else if (block.FuelHeatLevel > 0f)
                    {
                        slot.Count--;
                        if (block is IFuel fuel)
                        {
                            HeatLevel           = fuel.GetHeatLevel(slot.Value);
                            m_fireTimeRemaining = fuel.GetFuelFireDuration(slot.Value);
                        }
                        else
                        {
                            HeatLevel           = block.FuelHeatLevel;
                            m_fireTimeRemaining = block.FuelFireDuration;
                        }
                    }
                }
            }
            if (m_fireTimeRemaining <= 0f)
            {
                m_smeltingRecipe = null;
                SmeltingProgress = 0f;
                //m_music = -1;
            }
            if (m_smeltingRecipe != null)
            {
                SmeltingProgress = MathUtils.Min(SmeltingProgress + 0.02f * dt, 1f);
                if (SmeltingProgress >= 1f)
                {
                    for (int i = 0; i < m_furnaceSize; i++)
                    {
                        if (m_slots[i].Count > 0)
                        {
                            m_slots[i].Count--;
                        }
                    }
                    if (string.Equals(m_smeltingRecipe, "SteelWheel") || string.Equals(m_smeltingRecipe, "SteelGear") || string.Equals(m_smeltingRecipe, "ScrapIron"))
                    {
                        m_slots[ResultSlotIndex].Value = ItemBlock.IdTable[m_smeltingRecipe];
                        m_slots[ResultSlotIndex].Count++;
                    }
                    m_smeltingRecipe       = null;
                    SmeltingProgress       = 0f;
                    m_updateSmeltingRecipe = true;
                }
            }
            if (Utils.Terrain.GetCellContents(coordinates.X, coordinates.Y, coordinates.Z) != 0)
            {
                int cellValue = Utils.Terrain.GetCellValue(coordinates.X, coordinates.Y, coordinates.Z);
                Utils.SubsystemTerrain.ChangeCell(coordinates.X, coordinates.Y, coordinates.Z, Terrain.ReplaceData(cellValue, FurnaceNBlock.SetHeatLevel(Terrain.ExtractData(cellValue), HeatLevel > 0f ? 1 : 0)));
            }
        }
Example #8
0
        public void Update(float dt)
        {
            Point3 coordinates = m_componentBlockEntity.Coordinates;

            if (coordinates.Y < 0 || coordinates.Y > 127)
            {
                return;
            }
            if (HeatLevel > 0f)
            {
                m_fireTimeRemaining = MathUtils.Max(0f, m_fireTimeRemaining - dt * m_speed);
                if (m_fireTimeRemaining == 0f)
                {
                    HeatLevel = 0f;
                }
            }
            Slot slot;

            if (m_updateSmeltingRecipe)
            {
                m_updateSmeltingRecipe = false;
                if (HeatLevel <= 0f)
                {
                    slot = m_slots[FuelSlotIndex];
                    if (slot.Count > 0)
                    {
                        Block block = BlocksManager.Blocks[Terrain.ExtractContents(slot.Value)];
                        HeatLevel = block is IFuel fuel?fuel.GetHeatLevel(slot.Value) : block.FuelHeatLevel;
                    }
                }
                if (!"text".Equals(m_smeltingRecipe))
                {
                    m_smeltingRecipe = "text";
                    SmeltingProgress = 0f;
                    //m_music = 0;
                }
            }
            if (m_smeltingRecipe == null)
            {
                HeatLevel           = 0f;
                m_fireTimeRemaining = 0f;
                //m_music = -1;
            }
            else if (m_fireTimeRemaining <= 0f)
            {
                slot = m_slots[FuelSlotIndex];
                if (slot.Count > 0)
                {
                    var block = BlocksManager.Blocks[Terrain.ExtractContents(slot.Value)];
                    if (block.GetExplosionPressure(slot.Value) > 0f)
                    {
                        slot.Count = 0;
                        Utils.SubsystemExplosions.TryExplodeBlock(coordinates.X, coordinates.Y, coordinates.Z, slot.Value);
                    }
                    else
                    {
                        slot.Count--;
                        if (block is IFuel fuel)
                        {
                            HeatLevel  = fuel.GetHeatLevel(slot.Value);
                            m_fireTime = m_fireTimeRemaining = fuel.GetFuelFireDuration(slot.Value);
                        }
                        else
                        {
                            HeatLevel  = block.FuelHeatLevel;
                            m_fireTime = m_fireTimeRemaining = block.FuelFireDuration;
                        }
                    }
                }
            }
            if (m_fireTimeRemaining <= 0f)
            {
                m_smeltingRecipe = null;
                SmeltingProgress = 0f;
                //m_music = -1;
            }
            if (m_smeltingRecipe != null)
            {
                if (m_fireTime == 0f)
                {
                    m_fireTime = m_fireTimeRemaining;
                }
                SmeltingProgress = MathUtils.Min(m_fireTimeRemaining / m_fireTime, 1f);
                if (SmeltingProgress >= 2f)
                {
                    m_smeltingRecipe       = null;
                    SmeltingProgress       = 0f;
                    m_updateSmeltingRecipe = true;
                }
            }
            TerrainChunk chunk = Utils.Terrain.GetChunkAtCell(coordinates.X, coordinates.Z);

            if (chunk != null && chunk.State == TerrainChunkState.Valid)
            {
                int cellValue = chunk.GetCellValueFast(coordinates.X & 15, coordinates.Y, coordinates.Z & 15);
                Utils.SubsystemTerrain.ChangeCell(coordinates.X, coordinates.Y, coordinates.Z, Terrain.ReplaceData(cellValue, FurnaceNBlock.SetHeatLevel(Terrain.ExtractData(cellValue), HeatLevel > 0f ? 1 : 0)));
            }
        }
Example #9
0
        public void Update(float dt)
        {
            if (Coordinates.Y < 0 || Coordinates.Y > 127)
            {
                return;
            }
            if (HeatLevel > 0f)
            {
                m_fireTimeRemaining = MathUtils.Max(0f, m_fireTimeRemaining - dt);
                if (m_fireTimeRemaining == 0f)
                {
                    HeatLevel = 0f;
                }
            }
            Slot slot;

            if (m_updateSmeltingRecipe)
            {
                m_updateSmeltingRecipe = false;
                float heatLevel = 0f;
                if (HeatLevel > 0f)
                {
                    heatLevel = HeatLevel;
                }
                else
                {
                    slot = m_slots[FuelSlotIndex];
                    if (slot.Count > 0)
                    {
                        var block = BlocksManager.Blocks[Terrain.ExtractContents(slot.Value)];
                        heatLevel = block is IFuel fuel?fuel.GetHeatLevel(slot.Value) : block.FuelHeatLevel;
                    }
                }
                string text = FindSmeltingRecipe(heatLevel);
                if (text != m_smeltingRecipe)
                {
                    m_smeltingRecipe = text;
                    SmeltingProgress = 0f;
                    m_music          = 0;
                }
            }
            if (m_smeltingRecipe == null)
            {
                HeatLevel           = 0f;
                m_fireTimeRemaining = 0f;
                m_music             = -1;
            }
            else if (m_smeltingRecipe != null && m_fireTimeRemaining <= 0f)
            {
                slot = m_slots[FuelSlotIndex];
                if (slot.Count > 0)
                {
                    var block = BlocksManager.Blocks[Terrain.ExtractContents(slot.Value)];
                    if (block.GetExplosionPressure(slot.Value) > 0f)
                    {
                        slot.Count = 0;
                        Utils.SubsystemExplosions.TryExplodeBlock(Coordinates.X, Coordinates.Y, Coordinates.Z, slot.Value);
                    }
                    else
                    {
                        slot.Count--;
                        if (block is IFuel fuel)
                        {
                            HeatLevel           = fuel.GetHeatLevel(slot.Value);
                            m_fireTimeRemaining = fuel.GetFuelFireDuration(slot.Value);
                        }
                        else
                        {
                            HeatLevel           = block.FuelHeatLevel;
                            m_fireTimeRemaining = block.FuelFireDuration;
                        }
                    }
                }
            }
            if (m_fireTimeRemaining <= 0f)
            {
                m_smeltingRecipe = null;
                SmeltingProgress = 0f;
                m_music          = -1;
            }
            if (m_smeltingRecipe != null)
            {
                SmeltingProgress = MathUtils.Min(SmeltingProgress + 0.02f * dt, 1f);
                if (m_music % 90 == 0)
                {
                    Utils.SubsystemAudio.PlaySound("Audio/SteamEngine", 1f, 0f, new Vector3(Coordinates), 4f, true);
                }
                m_music++;
                if (SmeltingProgress >= 1.0)
                {
                    for (int i = 0; i < m_furnaceSize; i++)
                    {
                        if (m_slots[i].Count > 0)
                        {
                            m_slots[i].Count--;
                        }
                    }
                    m_slots[ResultSlotIndex].Value = 90;
                    m_slots[ResultSlotIndex].Count++;
                    m_smeltingRecipe       = null;
                    SmeltingProgress       = 0f;
                    m_updateSmeltingRecipe = true;
                }
            }
            if (m_componentBlockEntity != null)
            {
                TerrainChunk chunk = Utils.Terrain.GetChunkAtCell(Coordinates.X, Coordinates.Z);
                if (chunk != null && chunk.State == TerrainChunkState.Valid)
                {
                    int cellValue = chunk.GetCellValueFast(Coordinates.X & 15, Coordinates.Y, Coordinates.Z & 15);
                    Utils.SubsystemTerrain.ChangeCell(Coordinates.X, Coordinates.Y, Coordinates.Z, Terrain.ReplaceData(cellValue, FurnaceNBlock.SetHeatLevel(Terrain.ExtractData(cellValue), HeatLevel > 0f ? 1 : 0)));
                }
            }
        }
Example #10
0
        public static bool IsPowered(Terrain terrain, int x, int y, int z)
        {
            var chunk = terrain.GetChunkAtCell(x, z);

            if (y < 0 || y > 127 || chunk == null)
            {
                return(false);
            }
            int cellValue = terrain.GetCellValueFast(x + 1, y, z);

            if (FurnaceNBlock.GetHeatLevel(cellValue) != 0)
            {
                cellValue = Terrain.ExtractContents(cellValue);
                if (cellValue == EngineBlock.Index || cellValue == EngineHBlock.Index)
                {
                    return(true);
                }
            }
            cellValue = terrain.GetCellValueFast(x - 1, y, z);
            if (FurnaceNBlock.GetHeatLevel(cellValue) != 0)
            {
                cellValue = Terrain.ExtractContents(cellValue);
                if (cellValue == EngineBlock.Index || cellValue == EngineHBlock.Index)
                {
                    return(true);
                }
            }
            if (y < 127)
            {
                cellValue = chunk.GetCellValueFast(x & 15, y + 1, z & 15);
                if (FurnaceNBlock.GetHeatLevel(cellValue) != 0)
                {
                    cellValue = Terrain.ExtractContents(cellValue);
                    if (cellValue == EngineBlock.Index || cellValue == EngineHBlock.Index)
                    {
                        return(true);
                    }
                }
            }
            if (y > 0)
            {
                cellValue = chunk.GetCellValueFast(x & 15, y - 1, z & 15);
                if (FurnaceNBlock.GetHeatLevel(cellValue) != 0)
                {
                    cellValue = Terrain.ExtractContents(cellValue);
                    if (cellValue == EngineBlock.Index || cellValue == EngineHBlock.Index)
                    {
                        return(true);
                    }
                }
            }
            cellValue = terrain.GetCellValueFast(x, y, z + 1);
            if (FurnaceNBlock.GetHeatLevel(cellValue) != 0)
            {
                cellValue = Terrain.ExtractContents(cellValue);
                if (cellValue == EngineBlock.Index || cellValue == EngineHBlock.Index)
                {
                    return(true);
                }
            }
            cellValue = terrain.GetCellValueFast(x, y, z - 1);
            if (FurnaceNBlock.GetHeatLevel(cellValue) != 0)
            {
                cellValue = Terrain.ExtractContents(cellValue);
                if (cellValue == EngineBlock.Index || cellValue == EngineHBlock.Index)
                {
                    return(true);
                }
            }
            return(false);
        }
Example #11
0
        public void Update(float dt)
        {
            Point3 coordinates = m_componentBlockEntity.Coordinates;

            if (HeatLevel > 0f)
            {
                m_fireTimeRemaining = MathUtils.Max(0f, m_fireTimeRemaining - dt);
                if (m_fireTimeRemaining == 0f)
                {
                    HeatLevel = 0f;
                }
            }
            if (m_updateSmeltingRecipe)
            {
                m_updateSmeltingRecipe = false;
                string text = m_smeltingRecipe2 = FindSmeltingRecipe(0f);
                if (text != m_smeltingRecipe)
                {
                    m_smeltingRecipe  = text;
                    m_smeltingRecipe2 = text;
                    SmeltingProgress  = 0f;
                    //m_music = 0;
                }
            }
            if (m_smeltingRecipe2 != null)
            {
                int num = 0;
                for (int i = -1; i < 2; i++)
                {
                    for (int j = -1; j < 2; j++)
                    {
                        for (int k = -1; k < 2; k++)
                        {
                            int cellValue = Utils.Terrain.GetCellValue(coordinates.X + i, coordinates.Y + j, coordinates.Z + k);
                            if (i * i + j * j + k * k <= 1 && (Terrain.ExtractContents(cellValue) == FireBoxBlock.Index) && FurnaceNBlock.GetHeatLevel(cellValue) != 0)
                            {
                                num = 1;
                                break;
                            }
                        }
                    }
                }
                if (num == 0)
                {
                    m_smeltingRecipe = null;
                }
                if (num == 1 && m_smeltingRecipe == null)
                {
                    m_smeltingRecipe = m_smeltingRecipe2;
                }
            }
            if (m_smeltingRecipe == null)
            {
                HeatLevel           = 0f;
                m_fireTimeRemaining = 0f;
                //m_music = -1;
            }
            else
            {
                m_fireTimeRemaining = 100f;
            }
            if (m_fireTimeRemaining <= 0f)
            {
                m_smeltingRecipe = null;
                SmeltingProgress = 0f;
                //m_music = -1;
            }
            if (m_smeltingRecipe != null)
            {
                SmeltingProgress = MathUtils.Min(SmeltingProgress + 0.1f * dt, 1f);
                if (SmeltingProgress >= 1f)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        if (m_slots[i].Count > 0)
                        {
                            m_slots[i].Count--;
                        }
                    }
                    int value = ItemBlock.IdTable[m_smeltingRecipe];
                    m_slots[ResultSlotIndex].Value = value;
                    m_slots[ResultSlotIndex].Count++;
                    m_smeltingRecipe       = null;
                    SmeltingProgress       = 0f;
                    m_updateSmeltingRecipe = true;
                }
            }
        }