bool cFurnaceEntity::Tick(float a_Dt, cChunk & a_Chunk) { UNUSED(a_Dt); UNUSED(a_Chunk); if (m_FuelBurnTime <= 0) { // No fuel is burning, reset progressbars and bail out if ((m_LastProgressCook > 0) || (m_LastProgressFuel > 0)) { UpdateProgressBars(); } return false; } if (m_IsCooking) { m_TimeCooked++; if (m_TimeCooked >= m_NeedCookTime) { // Finished smelting one item FinishOne(); } } m_TimeBurned++; if (m_TimeBurned >= m_FuelBurnTime) { // The current fuel has been exhausted, use another one, if possible BurnNewFuel(); } UpdateProgressBars(); return true; }
/// Updates the current recipe, based on the current input void cFurnaceEntity::UpdateInput(void) { if (!m_Contents.GetSlot(fsInput).IsEqual(m_LastInput)) { // The input is different from what we had before, reset the cooking time m_TimeCooked = 0; } m_LastInput = m_Contents.GetSlot(fsInput); cFurnaceRecipe * FR = cRoot::Get()->GetFurnaceRecipe(); m_CurrentRecipe = FR->GetRecipeFrom(m_Contents.GetSlot(fsInput)); if (!CanCookInputToOutput()) { // This input cannot be cooked m_NeedCookTime = 0; SetIsCooking(false); } else { m_NeedCookTime = m_CurrentRecipe->CookTime; SetIsCooking(true); // Start burning new fuel if there's no flame now: if (GetFuelBurnTimeLeft() <= 0) { BurnNewFuel(); } } }
void cFurnaceEntity::UpdateFuel(void) { if (m_FuelBurnTime > m_TimeBurned) { // The current fuel is still burning, don't modify anything: return; } // The current fuel is spent, try to burn some more: BurnNewFuel(); }
bool cFurnaceEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { UNUSED(a_Dt); if (m_FuelBurnTime <= 0) { // If a furnace is out of fuel, the progress bar reverses at twice the speed of cooking. m_TimeCooked = std::max((m_TimeCooked - 2), 0); // Reset progressbars, block type, and bail out m_BlockType = E_BLOCK_FURNACE; a_Chunk.FastSetBlock(GetRelX(), m_PosY, GetRelZ(), E_BLOCK_FURNACE, m_BlockMeta); UpdateProgressBars(); return false; } if (m_IsCooking) { m_TimeCooked++; if (m_TimeCooked >= m_NeedCookTime) { // Finished smelting one item FinishOne(); } } m_TimeBurned++; if (m_TimeBurned >= m_FuelBurnTime) { // The current fuel has been exhausted, use another one, if possible BurnNewFuel(); } UpdateProgressBars(); return true; }
void cFurnaceEntity::UpdateOutput(void) { if (!CanCookInputToOutput()) { // Cannot cook anymore: SetCookTimes(0, 0); SetIsCooking(false); return; } // Can cook, start cooking if not already underway: m_NeedCookTime = m_CurrentRecipe->CookTime; // Check if fuel needs to start a burn if (GetFuelBurnTimeLeft() <= 0) { BurnNewFuel(); } // Already burning, set cooking to ensure that cooking is occuring else { SetIsCooking(true); } }
void cFurnaceEntity::UpdateInput(void) { if (!m_Contents.GetSlot(fsInput).IsEqual(m_LastInput)) { // The input is different from what we had before, reset the cooking time if (!m_IsLoading) { m_TimeCooked = 0; } } m_LastInput = m_Contents.GetSlot(fsInput); cFurnaceRecipe * FR = cRoot::Get()->GetFurnaceRecipe(); m_CurrentRecipe = FR->GetRecipeFrom(m_Contents.GetSlot(fsInput)); if (!CanCookInputToOutput()) { // This input cannot be cooked, reset cook counter immediately SetCookTimes(0, 0); SetIsCooking(false); } else { m_NeedCookTime = m_CurrentRecipe->CookTime; // Start burning new fuel if there's no flame now: if (GetFuelBurnTimeLeft() <= 0) { BurnNewFuel(); } // Already burning, set cooking to ensure that cooking is occuring else { SetIsCooking(true); } } }