public void UpdateCraftingResult() { int num = int.MaxValue; for (int i = 0; i < m_craftingGridSize; i++) { for (int j = 0; j < m_craftingGridSize; j++) { int num2 = i + j * 3; int slotIndex = i + j * m_craftingGridSize; int slotValue = GetSlotValue(slotIndex); int num3 = Terrain.ExtractContents(slotValue); int num4 = Terrain.ExtractData(slotValue); int slotCount = GetSlotCount(slotIndex); if (slotCount > 0) { Block block = BlocksManager.Blocks[num3]; m_matchedIngredients[num2] = block.CraftingId + ":" + num4.ToString(CultureInfo.InvariantCulture); num = MathUtils.Min(num, slotCount); } else { m_matchedIngredients[num2] = null; } } } ComponentPlayer componentPlayer = FindInteractingPlayer(); float playerLevel = componentPlayer?.PlayerData.Level ?? 1f; CraftingRecipe craftingRecipe = CraftingRecipesManager.FindMatchingRecipe(base.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true), m_matchedIngredients, 0f, playerLevel); if (craftingRecipe != null && craftingRecipe.ResultValue != 0) { m_matchedRecipe = craftingRecipe; m_slots[ResultSlotIndex].Value = craftingRecipe.ResultValue; m_slots[ResultSlotIndex].Count = craftingRecipe.ResultCount * num; } else { m_matchedRecipe = null; m_slots[ResultSlotIndex].Value = 0; m_slots[ResultSlotIndex].Count = 0; } if (craftingRecipe != null && !string.IsNullOrEmpty(craftingRecipe.Message)) { componentPlayer?.ComponentGui.DisplaySmallMessage(craftingRecipe.Message, Color.White, blinking: true, playNotificationSound: true); } }
public new void UpdateCraftingResult() { int num = 2147483647; for (int i = 0; i < m_craftingGridSize; i++) { for (int j = 0; j < m_craftingGridSize; j++) { int num2 = i + j * 6; int slotIndex = i + j * m_craftingGridSize; int slotValue = GetSlotValue(slotIndex); int slotCount = GetSlotCount(slotIndex); if (slotCount > 0) { m_matchedIngredients[num2] = BlocksManager.Blocks[Terrain.ExtractContents(slotValue)].CraftingId + ":" + Terrain.ExtractData(slotValue).ToString(CultureInfo.InvariantCulture); num = MathUtils.Min(num, slotCount); } else { m_matchedIngredients[num2] = null; } } } var craftingRecipe = CraftingRecipesManager.FindMatchingRecipe(Utils.SubsystemTerrain, m_matchedIngredients, 0f); if (craftingRecipe != null) { m_matchedRecipe = craftingRecipe; m_slots[ResultSlotIndex].Value = craftingRecipe.ResultValue; m_slots[ResultSlotIndex].Count = craftingRecipe.ResultCount * num; } else { m_matchedRecipe = null; m_slots[ResultSlotIndex].Value = 0; m_slots[ResultSlotIndex].Count = 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); }