コード例 #1
0
 public override void OnBlockGenerated(int value, int x, int y, int z, bool isLoaded)
 {
     if (FurnaceNBlock.GetHeatLevel(value) != 0)
     {
         AddFire(value, x, y, z);
     }
 }
コード例 #2
0
 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));
     }
 }
コード例 #3
0
 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);
     }
 }
コード例 #4
0
        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;
            }
        }
コード例 #5
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;
                        }
                    }
                }
            }
        }
コード例 #6
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);
        }
コード例 #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;
                }
            }
            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;
                }
            }
        }