Exemplo n.º 1
0
        public override IEnumerable <CraftingRecipe> GetProceduralCraftingRecipes()
        {
            string[] additives = new string[4]
            {
                BlocksManager.Blocks[43].CraftingId,
                BlocksManager.Blocks[24].CraftingId,
                BlocksManager.Blocks[103].CraftingId,
                BlocksManager.Blocks[22].CraftingId
            };
            int color = 0;

            while (color < 16)
            {
                int num2;
                for (int additive = 0; additive < 4; additive = num2)
                {
                    int num = CombineColors(color, 1 << additive);
                    if (num != color)
                    {
                        CraftingRecipe craftingRecipe = new CraftingRecipe
                        {
                            Description       = $"ÖÆ×÷ {SubsystemPalette.GetName(null, num, null)} ÑÕÁÏ",
                            ResultValue       = Terrain.MakeBlockValue(129, 0, num),
                            ResultCount       = 1,
                            RequiredHeatLevel = 1f
                        };
                        craftingRecipe.Ingredients[0] = BlocksManager.Blocks[129].CraftingId + ":" + color.ToString(CultureInfo.InvariantCulture);
                        craftingRecipe.Ingredients[1] = additives[additive];
                        yield return(craftingRecipe);
                    }
                    num2 = additive + 1;
                }
                num2  = color + 1;
                color = num2;
            }
        }
        public static void Initialize()
        {
            if (Initialize1 != null)
            {
                Initialize1(); return;
            }
            XElement source1 = ContentManager.Get <XElement>("CraftingRecipes");

            ModsManager.CombineXml(source1, ModsManager.GetEntries(".cr"), "Description", "Result", "Recipes");
            IEnumerable <XElement> source2 = source1.Descendants("Recipe");

            foreach (XElement item in source2)
            {
                CraftingRecipe craftingRecipe = new CraftingRecipe();
                string         attributeValue = XmlUtils.GetAttributeValue <string>(item, "Result");
                string         desc           = LanguageControl.GetBlock(attributeValue, "CRDescription");
                if (item.Attribute("Description") != null)
                {
                    desc = XmlUtils.GetAttributeValue <string>(item, "Description");
                }
                craftingRecipe.ResultValue = DecodeResult(attributeValue);
                craftingRecipe.ResultCount = XmlUtils.GetAttributeValue <int>(item, "ResultCount");
                string attributeValue2 = XmlUtils.GetAttributeValue(item, "Remains", string.Empty);
                if (!string.IsNullOrEmpty(attributeValue2))
                {
                    craftingRecipe.RemainsValue = DecodeResult(attributeValue2);
                    craftingRecipe.RemainsCount = XmlUtils.GetAttributeValue <int>(item, "RemainsCount");
                }
                craftingRecipe.RequiredHeatLevel   = XmlUtils.GetAttributeValue <float>(item, "RequiredHeatLevel");
                craftingRecipe.RequiredPlayerLevel = XmlUtils.GetAttributeValue(item, "RequiredPlayerLevel", 1f);
                craftingRecipe.Description         = desc;
                craftingRecipe.Message             = XmlUtils.GetAttributeValue <string>(item, "Message", null);
                if (craftingRecipe.ResultCount > BlocksManager.Blocks[Terrain.ExtractContents(craftingRecipe.ResultValue)].MaxStacking)
                {
                    throw new InvalidOperationException($"In recipe for \"{attributeValue}\" ResultCount is larger than max stacking of result block.");
                }
                if (craftingRecipe.RemainsValue != 0 && craftingRecipe.RemainsCount > BlocksManager.Blocks[Terrain.ExtractContents(craftingRecipe.RemainsValue)].MaxStacking)
                {
                    throw new InvalidOperationException($"In Recipe for \"{attributeValue2}\" RemainsCount is larger than max stacking of remains block.");
                }
                Dictionary <char, string> dictionary = new Dictionary <char, string>();
                foreach (XAttribute item2 in from a in item.Attributes()
                         where a.Name.LocalName.Length == 1 && char.IsLower(a.Name.LocalName[0])
                         select a)
                {
                    DecodeIngredient(item2.Value, out string craftingId, out int?data);
                    if (BlocksManager.FindBlocksByCraftingId(craftingId).Length == 0)
                    {
                        throw new InvalidOperationException($"Block with craftingId \"{item2.Value}\" not found.");
                    }
                    if (data.HasValue && (data.Value < 0 || data.Value > 262143))
                    {
                        throw new InvalidOperationException($"Data in recipe ingredient \"{item2.Value}\" must be between 0 and 0x3FFFF.");
                    }
                    dictionary.Add(item2.Name.LocalName[0], item2.Value);
                }
                string[] array = item.Value.Trim().Split(new string[] { "\n" }, StringSplitOptions.None);
                for (int i = 0; i < array.Length; i++)
                {
                    int num  = array[i].IndexOf('"');
                    int num2 = array[i].LastIndexOf('"');
                    if (num < 0 || num2 < 0 || num2 <= num)
                    {
                        throw new InvalidOperationException("Invalid recipe line.");
                    }
                    string text = array[i].Substring(num + 1, num2 - num - 1);
                    for (int j = 0; j < text.Length; j++)
                    {
                        char c = text[j];
                        if (char.IsLower(c))
                        {
                            string text2 = dictionary[c];
                            craftingRecipe.Ingredients[j + i * 3] = text2;
                        }
                    }
                }
                m_recipes.Add(craftingRecipe);
            }
            Block[] blocks = BlocksManager.Blocks;
            foreach (Block block in blocks)
            {
                m_recipes.AddRange(block.GetProceduralCraftingRecipes());
            }
            m_recipes.Sort(delegate(CraftingRecipe r1, CraftingRecipe r2)
            {
                int y = r1.Ingredients.Count((string s) => !string.IsNullOrEmpty(s));
                int x = r2.Ingredients.Count((string s) => !string.IsNullOrEmpty(s));
                return(Comparer <int> .Default.Compare(x, y));
            });
        }
Exemplo n.º 3
0
        public static void Initialize()
        {
            m_recipes = new List <CraftingRecipe>();
            for (var i = ContentManager.CombineXml(ContentManager.Get <XElement>("CraftingRecipes"), ModsManager.GetEntries(".cr"), "Description", "Result", "Recipes").Descendants("Recipe").GetEnumerator(); i.MoveNext();)
            {
                var descendant      = i.Current;
                var recipe          = new CraftingRecipe();
                var attributeValue1 = XmlUtils.GetAttributeValue <string>(descendant, "Result");
                recipe.ResultValue = DecodeResult(attributeValue1);
                recipe.ResultCount = XmlUtils.GetAttributeValue <int>(descendant, "ResultCount");
                var attributeValue2 = XmlUtils.GetAttributeValue(descendant, "Remains", string.Empty);
                if (!string.IsNullOrEmpty(attributeValue2))
                {
                    recipe.RemainsValue = DecodeResult(attributeValue2);
                    recipe.RemainsCount = XmlUtils.GetAttributeValue <int>(descendant, "RemainsCount");
                }

                recipe.RequiredHeatLevel = XmlUtils.GetAttributeValue <float>(descendant, "RequiredHeatLevel");
                recipe.Description       = XmlUtils.GetAttributeValue <string>(descendant, "Description");
                if (recipe.ResultCount >
                    BlocksManager.Blocks[Terrain.ExtractContents(recipe.ResultValue)].MaxStacking)
                {
                    throw new InvalidOperationException(string.Format(
                                                            "In recipe for \"{0}\" ResultCount is larger than max stacking of result block.",
                                                            new object[1] {
                        attributeValue1
                    }));
                }
                if (recipe.RemainsValue != 0 && recipe.RemainsCount >
                    BlocksManager.Blocks[Terrain.ExtractContents(recipe.RemainsValue)].MaxStacking)
                {
                    throw new InvalidOperationException(string.Format(
                                                            "In Recipe for \"{0}\" RemainsCount is larger than max stacking of remains block.",
                                                            new object[1] {
                        attributeValue2
                    }));
                }
                var dictionary = new Dictionary <char, string>();
                foreach (var xattribute in descendant.Attributes().Where(a =>
                                                                         a.Name.LocalName.Length == 1 && char.IsLower(a.Name.LocalName[0])))
                {
                    string craftingId;
                    int?   data;
                    DecodeIngredient(xattribute.Value, out craftingId, out data);
                    if (BlocksManager.FindBlocksByCraftingId(craftingId).Length == 0)
                    {
                        throw new InvalidOperationException(string.Format("Block with craftingId \"{0}\" not found.",
                                                                          new object[1] {
                            xattribute.Value
                        }));
                    }
                    if (data.HasValue && (data.Value < 0 || data.Value > 262143))
                    {
                        throw new InvalidOperationException(string.Format(
                                                                "Data in recipe ingredient \"{0}\" must be between 0 and 0x3FFFF.",
                                                                new object[1] {
                            xattribute.Value
                        }));
                    }
                    dictionary.Add(xattribute.Name.LocalName[0], xattribute.Value);
                }

                var strArray = descendant.Value.Trim().Split('\n');
                for (var index1 = 0; index1 < strArray.Length; ++index1)
                {
                    var num1 = strArray[index1].IndexOf('"');
                    var num2 = strArray[index1].LastIndexOf('"');
                    if (num1 < 0 || num2 < 0 || num2 <= num1)
                    {
                        throw new InvalidOperationException("Invalid recipe line.");
                    }
                    var str1 = strArray[index1].Substring(num1 + 1, num2 - num1 - 1);
                    for (var index2 = 0; index2 < str1.Length; ++index2)
                    {
                        var c = str1[index2];
                        if (char.IsLower(c))
                        {
                            recipe.Ingredients[index2 + index1 * 3] = dictionary[c];
                        }
                    }
                }

                m_recipes.Add(recipe);
            }

            var blocks = BlocksManager.Blocks;

            for (int i = 0; i < blocks.Length; i++)
            {
                m_recipes.AddRange(blocks[i].GetProceduralCraftingRecipes());
            }
            m_recipes.Sort((r1, r2) =>
            {
                return(Comparer <int> .Default.Compare(r2.Ingredients.Count(s => !string.IsNullOrEmpty(s)), r1.Ingredients.Count(s => !string.IsNullOrEmpty(s))));
            });
        }
Exemplo n.º 4
0
        public new void Update(float dt)
        {
            Point3 coordinates = m_componentBlockEntity.Coordinates;

            if (HeatLevel > 0f)
            {
                m_fireTimeRemaining = MathUtils.Max(0f, m_fireTimeRemaining - dt);
                if (m_fireTimeRemaining == 0f)
                {
                    m_heatLevel = 0f;
                }
            }
            if (m_updateSmeltingRecipe)
            {
                m_updateSmeltingRecipe = false;
                float          heatLevel      = HeatLevel > 0f ? HeatLevel : 2000f;
                CraftingRecipe craftingRecipe = FindSmeltingRecipe(2000f);
                if (craftingRecipe != m_smeltingRecipe)
                {
                    m_smeltingRecipe   = craftingRecipe;
                    m_smeltingRecipe2  = craftingRecipe;
                    m_smeltingProgress = 0f;
                }
            }
            if (m_smeltingRecipe2 != null)
            {
                if (!Powered)
                {
                    m_smeltingProgress = 0f;
                    m_heatLevel        = 0f;
                    m_smeltingRecipe   = null;
                }
                else if (m_smeltingRecipe == null)
                {
                    m_smeltingRecipe = m_smeltingRecipe2;
                }
            }
            if (!Powered)
            {
                m_smeltingProgress = 0f;
                m_heatLevel        = 0f;
                m_smeltingRecipe   = null;
            }
            if (m_smeltingRecipe == null)
            {
                m_heatLevel         = 0f;
                m_fireTimeRemaining = 0f;
            }
            if (m_smeltingRecipe != null && m_fireTimeRemaining <= 0f)
            {
                m_heatLevel         = 2000f;
                m_fireTimeRemaining = 100f;
            }
            if (m_fireTimeRemaining <= 0f)
            {
                m_smeltingRecipe   = null;
                m_smeltingProgress = 0f;
            }
            if (m_smeltingRecipe != null)
            {
                m_smeltingProgress = MathUtils.Min(SmeltingProgress + 0.2f * dt, 1f);
                if (SmeltingProgress >= 1f)
                {
                    for (int i = 0; i < m_furnaceSize; i++)
                    {
                        if (m_slots[i].Count > 0)
                        {
                            m_slots[i].Count--;
                        }
                    }
                    m_slots[ResultSlotIndex].Value  = m_smeltingRecipe.ResultValue;
                    m_slots[ResultSlotIndex].Count += m_smeltingRecipe.ResultCount;
                    if (m_smeltingRecipe.RemainsValue != 0 && m_smeltingRecipe.RemainsCount > 0)
                    {
                        m_slots[RemainsSlotIndex].Value  = m_smeltingRecipe.RemainsValue;
                        m_slots[RemainsSlotIndex].Count += m_smeltingRecipe.RemainsCount;
                    }
                    m_smeltingRecipe       = null;
                    m_smeltingRecipe2      = null;
                    m_smeltingProgress     = 0f;
                    m_updateSmeltingRecipe = true;
                }
            }
        }
Exemplo n.º 5
0
        public override IEnumerable <CraftingRecipe> GetProceduralCraftingRecipes()
        {
            int shape = 0;

            while (shape < 8)
            {
                int num;
                for (int altitude = 0; altitude < 2; altitude = num)
                {
                    for (int flickering = 0; flickering < 2; flickering = num)
                    {
                        for (int color = 0; color < 8; color = num)
                        {
                            CraftingRecipe craftingRecipe = new CraftingRecipe
                            {
                                ResultCount       = 20,
                                ResultValue       = Terrain.MakeBlockValue(215, 0, SetColor(SetAltitude(SetShape(SetFlickering(0, flickering != 0), (Shape)shape), altitude), color)),
                                RemainsCount      = 1,
                                RemainsValue      = Terrain.MakeBlockValue(90),
                                RequiredHeatLevel = 0f,
                                Description       = "ÖÆ×÷ÑÌ»¨"
                            };
                            if (shape == 0)
                            {
                                craftingRecipe.Ingredients[0] = null;
                                craftingRecipe.Ingredients[1] = "sulphurchunk";
                                craftingRecipe.Ingredients[2] = null;
                            }
                            if (shape == 1)
                            {
                                craftingRecipe.Ingredients[0] = "sulphurchunk";
                                craftingRecipe.Ingredients[1] = "coalchunk";
                                craftingRecipe.Ingredients[2] = "sulphurchunk";
                            }
                            if (shape == 2)
                            {
                                craftingRecipe.Ingredients[0] = "sulphurchunk";
                                craftingRecipe.Ingredients[1] = null;
                                craftingRecipe.Ingredients[2] = "sulphurchunk";
                            }
                            if (shape == 3)
                            {
                                craftingRecipe.Ingredients[0] = "sulphurchunk";
                                craftingRecipe.Ingredients[1] = "sulphurchunk";
                                craftingRecipe.Ingredients[2] = "sulphurchunk";
                            }
                            if (shape == 4)
                            {
                                craftingRecipe.Ingredients[0] = "coalchunk";
                                craftingRecipe.Ingredients[1] = "coalchunk";
                                craftingRecipe.Ingredients[2] = "coalchunk";
                            }
                            if (shape == 5)
                            {
                                craftingRecipe.Ingredients[0] = null;
                                craftingRecipe.Ingredients[1] = "saltpeterchunk";
                                craftingRecipe.Ingredients[2] = null;
                            }
                            if (shape == 6)
                            {
                                craftingRecipe.Ingredients[0] = "sulphurchunk";
                                craftingRecipe.Ingredients[1] = "saltpeterchunk";
                                craftingRecipe.Ingredients[2] = "sulphurchunk";
                            }
                            if (shape == 7)
                            {
                                craftingRecipe.Ingredients[0] = "coalchunk";
                                craftingRecipe.Ingredients[1] = "saltpeterchunk";
                                craftingRecipe.Ingredients[2] = "coalchunk";
                            }
                            if (flickering == 0)
                            {
                                craftingRecipe.Ingredients[3] = "canvas";
                                craftingRecipe.Ingredients[5] = "canvas";
                            }
                            if (flickering == 1)
                            {
                                craftingRecipe.Ingredients[3] = "gunpowder";
                                craftingRecipe.Ingredients[5] = "gunpowder";
                            }
                            if (altitude == 0)
                            {
                                craftingRecipe.Ingredients[6] = "gunpowder";
                                craftingRecipe.Ingredients[7] = null;
                                craftingRecipe.Ingredients[8] = "gunpowder";
                            }
                            if (altitude == 1)
                            {
                                craftingRecipe.Ingredients[6] = "gunpowder";
                                craftingRecipe.Ingredients[7] = "gunpowder";
                                craftingRecipe.Ingredients[8] = "gunpowder";
                            }
                            craftingRecipe.Ingredients[4] = "paintbucket:" + ((color != 7) ? color : 10).ToString(CultureInfo.InvariantCulture);
                            yield return(craftingRecipe);

                            num = color + 1;
                        }
                        num = flickering + 1;
                    }
                    num = altitude + 1;
                }
                num   = shape + 1;
                shape = num;
            }
        }
Exemplo n.º 6
0
        public void Update(float dt)
        {
            Point3 coordinates = m_componentBlockEntity.Coordinates;

            if (m_heatLevel > 0f)
            {
                m_fireTimeRemaining = MathUtils.Max(0f, m_fireTimeRemaining - dt);
                if (m_fireTimeRemaining == 0f)
                {
                    m_heatLevel = 0f;
                }
            }
            if (m_updateSmeltingRecipe)
            {
                m_updateSmeltingRecipe = false;
                float heatLevel = 0f;
                if (m_heatLevel > 0f)
                {
                    heatLevel = m_heatLevel;
                }
                else
                {
                    Slot slot = m_slots[FuelSlotIndex];
                    if (slot.Count > 0)
                    {
                        int num = Terrain.ExtractContents(slot.Value);
                        heatLevel = BlocksManager.Blocks[num].FuelHeatLevel;
                    }
                }
                CraftingRecipe craftingRecipe = FindSmeltingRecipe(heatLevel);
                if (craftingRecipe != m_smeltingRecipe)
                {
                    m_smeltingRecipe   = ((craftingRecipe != null && craftingRecipe.ResultValue != 0) ? craftingRecipe : null);
                    m_smeltingProgress = 0f;
                }
            }
            if (m_smeltingRecipe == null)
            {
                m_heatLevel         = 0f;
                m_fireTimeRemaining = 0f;
            }
            if (m_smeltingRecipe != null && m_fireTimeRemaining <= 0f)
            {
                Slot slot2 = m_slots[FuelSlotIndex];
                if (slot2.Count > 0)
                {
                    int   num2  = Terrain.ExtractContents(slot2.Value);
                    Block block = BlocksManager.Blocks[num2];
                    if (block.GetExplosionPressure(slot2.Value) > 0f)
                    {
                        slot2.Count = 0;
                        m_subsystemExplosions.TryExplodeBlock(coordinates.X, coordinates.Y, coordinates.Z, slot2.Value);
                    }
                    else if (block.FuelHeatLevel > 0f)
                    {
                        slot2.Count--;
                        m_fireTimeRemaining = block.FuelFireDuration;
                        m_heatLevel         = block.FuelHeatLevel;
                    }
                }
            }
            if (m_fireTimeRemaining <= 0f)
            {
                m_smeltingRecipe   = null;
                m_smeltingProgress = 0f;
            }
            if (m_smeltingRecipe != null)
            {
                m_smeltingProgress = MathUtils.Min(m_smeltingProgress + 0.15f * dt, 1f);
                if (m_smeltingProgress >= 1f)
                {
                    for (int i = 0; i < m_furnaceSize; i++)
                    {
                        if (m_slots[i].Count > 0)
                        {
                            m_slots[i].Count--;
                        }
                    }
                    m_slots[ResultSlotIndex].Value  = m_smeltingRecipe.ResultValue;
                    m_slots[ResultSlotIndex].Count += m_smeltingRecipe.ResultCount;
                    if (m_smeltingRecipe.RemainsValue != 0 && m_smeltingRecipe.RemainsCount > 0)
                    {
                        m_slots[RemainsSlotIndex].Value  = m_smeltingRecipe.RemainsValue;
                        m_slots[RemainsSlotIndex].Count += m_smeltingRecipe.RemainsCount;
                    }
                    m_smeltingRecipe       = null;
                    m_smeltingProgress     = 0f;
                    m_updateSmeltingRecipe = true;
                }
            }
            TerrainChunk chunkAtCell = m_subsystemTerrain.Terrain.GetChunkAtCell(coordinates.X, coordinates.Z);

            if (chunkAtCell != null && chunkAtCell.State == TerrainChunkState.Valid)
            {
                int cellValue = m_subsystemTerrain.Terrain.GetCellValue(coordinates.X, coordinates.Y, coordinates.Z);
                m_subsystemTerrain.ChangeCell(coordinates.X, coordinates.Y, coordinates.Z, Terrain.ReplaceContents(cellValue, (m_heatLevel > 0f) ? 65 : 64));
            }
        }
Exemplo n.º 7
0
 public CraftingRecipe FindSmeltingRecipe(float heatLevel)
 {
     if (heatLevel > 0f)
     {
         for (int i = 0; i < m_furnaceSize; i++)
         {
             int slotValue = GetSlotValue(i);
             int num       = Terrain.ExtractContents(slotValue);
             int num2      = Terrain.ExtractData(slotValue);
             if (GetSlotCount(i) > 0)
             {
                 Block block = BlocksManager.Blocks[num];
                 m_matchedIngredients[i] = block.CraftingId + ":" + num2.ToString(CultureInfo.InvariantCulture);
             }
             else
             {
                 m_matchedIngredients[i] = null;
             }
         }
         ComponentPlayer componentPlayer = FindInteractingPlayer();
         float           playerLevel     = componentPlayer?.PlayerData.Level ?? 1f;
         CraftingRecipe  craftingRecipe  = null;
         craftingRecipe = CraftingRecipesManager.FindMatchingRecipe(m_subsystemTerrain, m_matchedIngredients, heatLevel, playerLevel);
         if (craftingRecipe != null && craftingRecipe.ResultValue != 0)
         {
             if (craftingRecipe.RequiredHeatLevel <= 0f)
             {
                 craftingRecipe = null;
             }
             if (craftingRecipe != null)
             {
                 Slot slot = m_slots[ResultSlotIndex];
                 int  num3 = Terrain.ExtractContents(craftingRecipe.ResultValue);
                 if (slot.Count != 0 && (craftingRecipe.ResultValue != slot.Value || craftingRecipe.ResultCount + slot.Count > BlocksManager.Blocks[num3].MaxStacking))
                 {
                     craftingRecipe = null;
                 }
             }
             if (craftingRecipe != null && craftingRecipe.RemainsValue != 0 && craftingRecipe.RemainsCount > 0)
             {
                 if (m_slots[RemainsSlotIndex].Count == 0 || m_slots[RemainsSlotIndex].Value == craftingRecipe.RemainsValue)
                 {
                     if (BlocksManager.Blocks[Terrain.ExtractContents(craftingRecipe.RemainsValue)].MaxStacking - m_slots[RemainsSlotIndex].Count < craftingRecipe.RemainsCount)
                     {
                         craftingRecipe = null;
                     }
                 }
                 else
                 {
                     craftingRecipe = null;
                 }
             }
         }
         if (craftingRecipe != null && !string.IsNullOrEmpty(craftingRecipe.Message))
         {
             componentPlayer?.ComponentGui.DisplaySmallMessage(craftingRecipe.Message, Color.White, blinking: true, playNotificationSound: true);
         }
         return(craftingRecipe);
     }
     return(null);
 }
Exemplo n.º 8
0
        public static void CRInitialize()
        {
            CraftingRecipesManager.m_recipes = new List <CraftingRecipe>();
            var recipes    = new List <CraftingRecipe>();
            var enumerator = ContentManager.CombineXml(ContentManager.Get <XElement>("CraftingRecipes"), ModsManager.GetEntries(".cr"), "Description", "Result", "Recipes").Descendants("Recipe").GetEnumerator();

            while (enumerator.MoveNext())
            {
                XElement xelement       = enumerator.Current;
                var      craftingRecipe = new CraftingRecipe
                {
                    Ingredients = new string[36]
                };
                string attributeValue = XmlUtils.GetAttributeValue <string>(xelement, "Result");
                craftingRecipe.ResultValue = CraftingRecipesManager.DecodeResult(attributeValue);
                craftingRecipe.ResultCount = XmlUtils.GetAttributeValue <int>(xelement, "ResultCount");
                string attributeValue2 = XmlUtils.GetAttributeValue(xelement, "Remains", string.Empty);
                if (!string.IsNullOrEmpty(attributeValue2))
                {
                    craftingRecipe.RemainsValue = CraftingRecipesManager.DecodeResult(attributeValue2);
                    craftingRecipe.RemainsCount = XmlUtils.GetAttributeValue <int>(xelement, "RemainsCount");
                }
                craftingRecipe.RequiredHeatLevel = XmlUtils.GetAttributeValue <float>(xelement, "RequiredHeatLevel");
                craftingRecipe.Description       = XmlUtils.GetAttributeValue <string>(xelement, "Description");
                if (craftingRecipe.ResultCount > BlocksManager.Blocks[Terrain.ExtractContents(craftingRecipe.ResultValue)].MaxStacking)
                {
                    throw new InvalidOperationException($"In recipe for \"{attributeValue}\" ResultCount is larger than max stacking of result block.");
                }
                if (craftingRecipe.RemainsValue != 0 && craftingRecipe.RemainsCount > BlocksManager.Blocks[Terrain.ExtractContents(craftingRecipe.RemainsValue)].MaxStacking)
                {
                    throw new InvalidOperationException($"In Recipe for \"{attributeValue2}\" RemainsCount is larger than max stacking of remains block.");
                }
                var dictionary = new Dictionary <char, string>();
                foreach (XAttribute item in xelement.Attributes().Where(CraftingRecipesManager.c._.Initialize_b__3_1))
                {
                    CraftingRecipesManager.DecodeIngredient(item.Value, out string craftingId, out int?data);
                    if (BlocksManager.FindBlocksByCraftingId(craftingId).Length == 0)
                    {
                        throw new InvalidOperationException($"Block with craftingId \"{item.Value}\" not found.");
                    }
                    if (data.HasValue && (data.Value < 0 || data.Value > 262143))
                    {
                        throw new InvalidOperationException($"Data in recipe ingredient \"{item.Value}\" must be between 0 and 0x3FFFF.");
                    }
                    dictionary.Add(item.Name.LocalName[0], item.Value);
                }
                string[] array       = xelement.Value.Trim().Split('\n');
                string[] ingredients = craftingRecipe.Ingredients;
                for (int i = 0; i < array.Length; i++)
                {
                    int num2 = array[i].IndexOf('"');
                    int num3 = array[i].LastIndexOf('"');
                    if (num2 < 0 || num3 < 0 || num3 <= num2)
                    {
                        throw new InvalidOperationException("Invalid recipe line.");
                    }
                    string text = array[i].Substring(num2 + 1, num3 - num2 - 1);
                    for (int j = 0; j < text.Length; j++)
                    {
                        char c = text[j];
                        if (char.IsLower(c))
                        {
                            string text2 = dictionary[c];
                            if (ItemBlock.IdTable.TryGetValue(text2, out int value))
                            {
                                text2 = BlocksManager.Blocks[Terrain.ExtractContents(value)].CraftingId + ":" + Terrain.ExtractData(value);
                            }
                            ingredients[j + i * 6] = text2;
                        }
                    }
                }
                CraftingRecipesManager.m_recipes.Add(craftingRecipe);
                if (craftingRecipe.RequiredHeatLevel >= 300f)
                {
                    CraftingRecipesManager.DecodeIngredient(ingredients[0], out string craftingId, out int?num);
                    if (!num.HasValue)
                    {
                        continue;
                    }
                    recipes.Add(new CraftingRecipe
                    {
                        ResultValue       = Terrain.ReplaceData(BlocksManager.FindBlocksByCraftingId(craftingId)[0].BlockIndex, num.Value),
                        ResultCount       = GetCount(ingredients),
                        RemainsValue      = craftingRecipe.RemainsValue,
                        RemainsCount      = craftingRecipe.RemainsCount,
                        RequiredHeatLevel = 1f,
                        Ingredients       = (string[])ingredients.Clone(),
                        Description       = craftingRecipe.Description + Utils.Get(" (温度过低)")
                    });
                }
            }
            var blocks = BlocksManager.Blocks;

            for (int i = 0; i < blocks.Length; i++)
            {
                using (var enumerator2 = blocks[i].GetProceduralCraftingRecipes().GetEnumerator())
                    while (enumerator2.MoveNext())
                    {
                        var old = enumerator2.Current.Ingredients;
                        if (old.Length == 9)
                        {
                            var ingredients = new string[36];
                            ingredients[0]  = old[0];
                            ingredients[1]  = old[1];
                            ingredients[2]  = old[2];
                            ingredients[6]  = old[3];
                            ingredients[7]  = old[4];
                            ingredients[8]  = old[5];
                            ingredients[12] = old[6];
                            ingredients[13] = old[7];
                            ingredients[14] = old[8];
                            enumerator2.Current.Ingredients = ingredients;
                        }
                        CraftingRecipesManager.m_recipes.Add(enumerator2.Current);
                    }
            }
            CraftingRecipesManager.m_recipes.Sort(CraftingRecipesManager.c._.Initialize_b__3_0);
            CraftingRecipesManager.m_recipes.AddRange(recipes);
        }