void cFurnaceEntity::BurnNewFuel(void) { cFurnaceRecipe * FR = cRoot::Get()->GetFurnaceRecipe(); int NewTime = FR->GetBurnTime(m_Contents.GetSlot(fsFuel)); if ((NewTime == 0) || !CanCookInputToOutput()) { // The item in the fuel slot is not suitable // or the input and output isn't available for cooking SetBurnTimes(0, 0); SetIsCooking(false); return; } // Burn one new fuel: SetBurnTimes(NewTime, 0); SetIsCooking(true); if (m_Contents.GetSlot(fsFuel).m_ItemType == E_ITEM_LAVA_BUCKET) { m_Contents.SetSlot(fsFuel, cItem(E_ITEM_BUCKET)); } else { m_Contents.ChangeSlotCount(fsFuel, -1); } }
/// 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::BurnNewFuel(void) { cFurnaceRecipe * FR = cRoot::Get()->GetFurnaceRecipe(); int NewTime = FR->GetBurnTime(m_Contents.GetSlot(fsFuel)); if (NewTime == 0) { // The item in the fuel slot is not suitable m_FuelBurnTime = 0; m_TimeBurned = 0; SetIsCooking(false); return; } // Is the input and output ready for cooking? if (!CanCookInputToOutput()) { return; } // Burn one new fuel: m_FuelBurnTime = NewTime; m_TimeBurned = 0; SetIsCooking(true); if (m_Contents.GetSlot(fsFuel).m_ItemType == E_ITEM_LAVA_BUCKET) { m_Contents.SetSlot(fsFuel, cItem(E_ITEM_BUCKET)); } else { m_Contents.ChangeSlotCount(fsFuel, -1); } }
/// Updates the m_IsCooking, based on the input slot, output slot and m_FuelBurnTime / m_TimeBurned void cFurnaceEntity::UpdateIsCooking(void) { if ( !CanCookInputToOutput() || // Cannot cook this (m_FuelBurnTime <= 0) || // No fuel (m_TimeBurned >= m_FuelBurnTime) // Fuel burnt out ) { // Reset everything SetIsCooking(false); m_TimeCooked = 0; m_NeedCookTime = 0; return; } SetIsCooking(true); }
/// Called when the output slot changes; starts burning if space became available void cFurnaceEntity::UpdateOutput(void) { if (!CanCookInputToOutput()) { // Cannot cook anymore: m_TimeCooked = 0; m_NeedCookTime = 0; SetIsCooking(false); return; } // No need to burn new fuel, the Tick() function will take care of that // Can cook, start cooking if not already underway: m_NeedCookTime = m_CurrentRecipe->CookTime; SetIsCooking(m_FuelBurnTime > 0); }
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); } } }