コード例 #1
0
ファイル: FurnaceEntity.cpp プロジェクト: Jothle12/MCServer
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;
}
コード例 #2
0
ファイル: FurnaceEntity.cpp プロジェクト: 4264/cuberite
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;
}