Exemplo n.º 1
0
	//fills all remaining empty buildings of the given cathegory, only considering available workers and buildings
	bool FillRemainingSlots(WORKER::Typ type)
	{
		AssertBotE(m_WorkersLeftToSet >= 0);
		if(m_WorkersLeftToSet == 0)
			return false;
		m_WorkersLeftToSet += m_pSystem->GetWorker(type);
		m_pSystem->SetWorker(type, CSystem::SET_WORKER_MODE_SET, 0);
		const int buildings = m_pSystem->GetNumberOfWorkbuildings(type, 0);
		const int to_set = min(buildings, m_WorkersLeftToSet);
		SetWorker(type, CSystem::SET_WORKER_MODE_SET,to_set);
		return true;
	}
Exemplo n.º 2
0
	//worker setting function which makes according changes to m_WorkersLeftToSet, tracking how many
	//we still have to distribute at all
	void SetWorker(WORKER::Typ type, CSystem::SetWorkerMode mode, int value = -1)
	{
		if(mode == CSystem::SET_WORKER_MODE_INCREMENT)
		{
			AssertBotE(value == -1);
			m_pSystem->SetWorker(type, mode);
			--m_WorkersLeftToSet;
		}
		else if(mode == CSystem::SET_WORKER_MODE_DECREMENT)
		{
			AssertBotE(value == -1);
			m_pSystem->SetWorker(type, mode);
			++m_WorkersLeftToSet;
		}
		else if(mode == CSystem::SET_WORKER_MODE_SET)
		{
			AssertBotE(value >= 0);
			m_pSystem->SetWorker(type, mode, value);
			m_WorkersLeftToSet -= value;
		}
		AssertBotE(m_WorkersLeftToSet >= 0);
	}