当前位置: 首页>>代码示例>>C++>>正文


C++ CSystem类代码示例

本文整理汇总了C++中CSystem的典型用法代码示例。如果您正苦于以下问题:C++ CSystem类的具体用法?C++ CSystem怎么用?C++ CSystem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CSystem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ShipsNearPort

bool CDockingPorts::ShipsNearPort (CSpaceObject *pOwner, CSpaceObject *pRequestingObj, const CVector &vPortPos)

//	ShipsNearPort
//
//	Returns TRUE if there are ships near the given port

	{
	int i;
	CSystem *pSystem = pOwner->GetSystem();

	for (i = 0; i < pSystem->GetObjectCount(); i++)
		{
		CSpaceObject *pObj = pSystem->GetObject(i);
		if (pObj
				&& pObj->GetCategory() == CSpaceObject::catShip
				&& !pObj->IsInactive()
				&& pObj != pRequestingObj)
			{
			Metric rDist2 = (pObj->GetPos() - vPortPos).Length2();
			if (rDist2 < MIN_PORT_DISTANCE2 && !IsDockedOrDocking(pObj))
				return true;
			}
		}

	return false;
	}
开发者ID:alanhorizon,项目名称:Transcendence,代码行数:26,代码来源:CDockingPorts.cpp

示例2: CheckFamine

bool CSystemManager::CheckFamine(const CSystem& system)
{
	const int food_prod = system.GetProduction()->GetFoodProd();
	if(food_prod >= 0)
		return false;
	const int food_store = system.GetFoodStore();
	return food_store + food_prod < 0;
}
开发者ID:bote-team,项目名称:bote,代码行数:8,代码来源:Manager.cpp

示例3: SafeMoral

	//puts an additional worker into industry, to prevent not finishing the project because
	//industry prod decreased due to loss of moral
	void SafeMoral()
	{
		const CAssemblyList& assembly_list = *m_pSystem->GetAssemblyList();
		AssertBotE(m_WorkersLeftToSet >= 0);
		if(assembly_list.IsEmpty() || m_WorkersLeftToSet == 0)
			return;
		const int max_buildings = m_pSystem->GetNumberOfWorkbuildings(WORKER::INDUSTRY_WORKER, 0);
		if(m_pSystem->GetWorker(WORKER::INDUSTRY_WORKER) < max_buildings)
			SetWorker(WORKER::INDUSTRY_WORKER, CSystem::SET_WORKER_MODE_INCREMENT);
	}
开发者ID:bote-team,项目名称:bote,代码行数:12,代码来源:Manager.cpp

示例4: InRangeOfThreat

bool CFerianShipAI::InRangeOfThreat (CSpaceObject **retpThreat)

//	InRangeOfThreat
//
//	Returns the nearest threat

	{
	if (m_pShip->IsDestinyTime(19))
		{
		CSystem *pSystem = m_pShip->GetSystem();
		int iDestiny = m_pShip->GetDestiny();

		//	Get the list of objects that intersect the object

		SSpaceObjectGridEnumerator i;
		pSystem->EnumObjectsInBoxStart(i, m_pShip->GetPos(), MAX_THREAT_DIST);

		//	Loop over all objects

		Metric rNearestDist2 = MAX_THREAT_DIST * MAX_THREAT_DIST2;
		CSpaceObject *pNearestObj = NULL;

		while (pSystem->EnumObjectsInBoxHasMore(i))
			{
			CSpaceObject *pObj = pSystem->EnumObjectsInBoxGetNext(i);

			//	If the object is in the bounding box then remember
			//	it so that we can do a more accurate calculation.

			if (pObj->GetCategory() == CSpaceObject::catShip
					&& (!m_pShip->IsFriend(pObj) || pObj->GetDestiny() < iDestiny)
					&& pObj->CanAttack())
				{
				Metric rDist2 = m_pShip->GetDistance2(pObj);
				if (rDist2 < rNearestDist2)
					{
					pNearestObj = pObj;
					rNearestDist2 = rDist2;
					}
				}
			}

		//	Done

		if (pNearestObj)
			{
			*retpThreat = pNearestObj;
			return true;
			}
		}

	return false;
	}
开发者ID:Sdw195,项目名称:Transcendence,代码行数:53,代码来源:CFerianShipAI.cpp

示例5: FillRemainingSlots

	//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;
	}
开发者ID:bote-team,项目名称:bote,代码行数:13,代码来源:Manager.cpp

示例6: ASSERT

void CPlayerGameStats::OnKeyEvent (EEventTypes iType, CSpaceObject *pObj, DWORD dwCauseUNID)

//	OnKeyEvent
//
//	Adds a key event involving an object

	{
	ASSERT(pObj);

	CSystem *pSystem = pObj->GetSystem();
	if (pSystem == NULL)
		return;

	//	Get the NodeID where the event happened

	CTopologyNode *pNode = pSystem->GetTopology();
	if (pNode == NULL)
		return;

	const CString &sNodeID = pNode->GetID();

	//	Get the object's type

	CDesignType *pType = pObj->GetType();
	if (pType == NULL)
		return;

	//	Get the object's name

	DWORD dwNameFlags;
	CString sName = pObj->GetName(&dwNameFlags);
	
	//	If the object name is the same as the type name then we don't bother
	//	storing it in the event (to save memory)

	if (strEquals(sName, pType->GetTypeName()))
		{
		sName = NULL_STR;
		dwNameFlags = 0;
		}

	//	Look for the list of events for this NodeID

	TArray<SKeyEventStats> *pEventList = m_KeyEventStats.Set(sNodeID);
	SKeyEventStats *pStats = pEventList->Insert();
	pStats->iType = iType;
	pStats->dwTime = g_pUniverse->GetTicks();
	pStats->dwObjUNID = pObj->GetType()->GetUNID();
	pStats->sObjName = sName;
	pStats->dwObjNameFlags = dwNameFlags;
	pStats->dwCauseUNID = dwCauseUNID;
	}
开发者ID:Sdw195,项目名称:Transcendence,代码行数:52,代码来源:CPlayerGameStats.cpp

示例7: main

int main(void) {
	int testCase = 0;	// 测试用例数
	cin >> testCase;
	for(int t = 0; t < testCase; t++) {
		int eqNum = 0;	// 设备数
		cin >> eqNum;

		CSystem* cSystem = new CSystem(eqNum);
		cSystem->init();	// 初始化路由系统参数
		cSystem->solve();	// 使用DP计算路由系统各种设备组合下的性价比
		cSystem->print();	// 打印结果(最优性价比)
		delete cSystem;
	}
	return 0;
}
开发者ID:lyy289065406,项目名称:expcodes,代码行数:15,代码来源:POJ1018-Communication+System.cpp

示例8: DecrementDueToWastedIndustry

	//removes workers from factories until they are the minimum number to finish the current project
	//in still the same number of turns (as at the start of the function)
	int DecrementDueToWastedIndustry(bool max_industry)
	{
		m_pSystem->CalculateVariables();
		const CAssemblyList& assembly_list = *m_pSystem->GetAssemblyList();
		int unset = 0;
		if(assembly_list.IsEmpty() || assembly_list.GetWasBuildingBought())
			return unset;
		const int min_rounds = m_pSystem->NeededRoundsToBuild(0, true);
		AssertBotE(min_rounds >= 1);
		if(max_industry && min_rounds > 1 || m_pSystem->GetWorker(WORKER::INDUSTRY_WORKER) == 0)
			return unset;
		while(true)
		{
			SetWorker(WORKER::INDUSTRY_WORKER, CSystem::SET_WORKER_MODE_DECREMENT);
			++unset;
			m_pSystem->CalculateVariables();
			const int current_rounds = m_pSystem->NeededRoundsToBuild(0, true, false);
			if(m_pSystem->GetWorker(WORKER::INDUSTRY_WORKER) == 0)
			{
				if(min_rounds < current_rounds)
					OnBestIndustryWorkerCountFound(unset);
				return unset;
			}
			if(min_rounds < current_rounds)
			{
				OnBestIndustryWorkerCountFound(unset);
				return unset;
			}
		}
	}
开发者ID:bote-team,项目名称:bote,代码行数:32,代码来源:Manager.cpp

示例9: update

// Actualizar el sistema (emuladores)
void CSystem::update(CSystem& p_system){
	Gtk::TreeModel::iterator l_iter;
	CEmulator l_emulator;

	GELIDE_DEBUG("System " << getName().data() << ": Updating...");
	// Intentamos añadir cada uno de los emuladores del sistema
	for(l_iter = p_system.getEmulatorList()->children().begin();
		l_iter != p_system.getEmulatorList()->children().end(); l_iter++){
		l_emulator.setId(0);
		l_emulator.setIconFile((*l_iter)[m_emulator_columns.m_icon_file]);
		l_emulator.setName((*l_iter)[m_emulator_columns.m_name]);
		l_emulator.setDescription((*l_iter)[m_emulator_columns.m_description]);
		l_emulator.setVersion((*l_iter)[m_emulator_columns.m_version]);
		l_emulator.setAuthor((*l_iter)[m_emulator_columns.m_author]);
		l_emulator.setHomepage((*l_iter)[m_emulator_columns.m_homepage]);
		l_emulator.setPath((*l_iter)[m_emulator_columns.m_path]);
		l_emulator.setParams((*l_iter)[m_emulator_columns.m_params]);
		addEmulator(l_emulator);
	}
}
开发者ID:mckayemu,项目名称:vemulator,代码行数:21,代码来源:system.cpp

示例10: IncreaseWorkersUntilSufficient

	//Indreases workers in cathegories energy and food until we produce enough to suffice for the consumption we have
	bool IncreaseWorkersUntilSufficient(WORKER::Typ type, bool allow_insufficient)
	{
		AssertBotE(type == WORKER::ENERGY_WORKER || type == WORKER::FOOD_WORKER);
		if(m_pSystem->GetDisabledProductions()[type])
			return true;
		while(true)
		{
			const int value = (type == WORKER::ENERGY_WORKER) ? m_pProd->GetEnergyProd() : m_pProd->GetFoodProd();
			if(value >= 0)
				return true;
			if(m_WorkersLeftToSet <= 0)
				return allow_insufficient;
			const int number_of_buildings = m_pSystem->GetNumberOfWorkbuildings(type, 0);
			const int workers_set = m_pSystem->GetWorker(type);
			AssertBotE(workers_set <= number_of_buildings);
			if(workers_set == number_of_buildings)
				return allow_insufficient;
			SetWorker(type, CSystem::SET_WORKER_MODE_INCREMENT);
			m_pSystem->CalculateVariables();
		}
	}
开发者ID:bote-team,项目名称:bote,代码行数:22,代码来源:Manager.cpp

示例11: DestroyIntroShips

void CTranscendenceWnd::DestroyIntroShips (void)

//	DestroyIntroShips
//
//	Destroys all ships of the same class as the POV

	{
	int i;

	CShip *pShip = g_pUniverse->GetPOV()->AsShip();
	if (pShip == NULL)
		return;

	//	Destroy all ships of the current class

	CSystem *pSystem = pShip->GetSystem();
	CShipClass *pClassToDestroy = pShip->GetClass();
	TArray<CSpaceObject *> ShipsToDestroy;
	CSpaceObject *pOtherShip = NULL;
	for (i = 0; i < pSystem->GetObjectCount(); i++)
		{
		CSpaceObject *pObj = pSystem->GetObject(i);
		CShip *pShip;
		if (pObj 
				&& !pObj->IsInactive()
				&& !pObj->IsVirtual()
				&& (pShip = pObj->AsShip()))
			{
			if (pShip->GetClass() == pClassToDestroy)
				ShipsToDestroy.Insert(pObj);
			else if (pOtherShip == NULL)
				pOtherShip = pObj;
			}
		}

	//	Destroy ships

	for (i = 0; i < ShipsToDestroy.GetCount(); i++)
		ShipsToDestroy[i]->Destroy(removedFromSystem, CDamageSource());
	}
开发者ID:AvanWolf,项目名称:Transcendence,代码行数:40,代码来源:IntroScreen.cpp

示例12: SetWorker

	//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);
	}
开发者ID:bote-team,项目名称:bote,代码行数:24,代码来源:Manager.cpp

示例13: _tWinMain

int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
                     _In_opt_ HINSTANCE hPrevInstance,
                     _In_ LPTSTR    lpCmdLine,
                     _In_ int       nCmdShow)
{
#if _DEBUG
	AllocConsole();
	freopen("CONOUT$", "w", stdout);
#endif
	CSystem system;

	// 초기화에 실패하면?
	if (!(system.Init()))
		system.Release();
	
	// 루프
	if (DataManager->bIsGameRun)
		system.MessageLoop();

	// 초기화
	system.Release();
}
开发者ID:ReoRavi,项目名称:ICETAG,代码行数:22,代码来源:Engine.cpp

示例14: return

CSpaceObject *CDamageSource::GetObj (void) const

//	GetObj
//
//	Returns the source object

	{
	CSpaceObject *pOrderGiver;

	//	If the source is the player then always return the player
	//	object (regardless of m_pSource). We do this in case
	//	the player changes ships.

	if (m_dwFlags & FLAG_IS_PLAYER)
		{
		CSystem *pSystem = g_pUniverse->GetCurrentSystem();
		return (pSystem ? pSystem->GetPlayer() : NULL);
		}

	//	Otherwise, if we're a subordinate and our order giver
	//	has changed, switch back to the player.

	else if ((m_dwFlags & FLAG_IS_PLAYER_SUBORDINATE)
			&& (m_pSource == NULL
				|| (pOrderGiver = m_pSource->GetOrderGiver()) == NULL
				|| !pOrderGiver->IsPlayer()))
		{
		CSystem *pSystem = g_pUniverse->GetCurrentSystem();
		return (pSystem ? pSystem->GetPlayer() : NULL);
		}

	//	Otherwise, return the source (even if NULL)

	else
		return m_pSource;
	}
开发者ID:Sdw195,项目名称:Transcendence,代码行数:36,代码来源:CDamageSource.cpp

示例15: DoPriorities

	//distributes workers onto priorities remaining after max priorities have been processed
	//workers that cannot be set because of number of buildings are tried to be set into
	//the cathegory with next less workers
	void DoPriorities(const std::map<WORKER::Typ, int>& priorities, bool max_industry, bool safe_moral)
	{
		SafeMoralWorkerReserve reserve(*this, safe_moral);
		std::map<WORKER::Typ, int> prios(priorities);
		DoMaxPriorities(prios, max_industry);
		DefaultDistributionCalculator decalc(m_WorkersLeftToSet, prios);
		const std::vector<DistributionElem>& result = decalc.Calc();
		int failed_to_set = 0;
		for(std::vector<DistributionElem>::const_iterator it = result.begin(); it != result.end(); ++it)
		{
			const int buildings = m_pSystem->GetNumberOfWorkbuildings(it->m_Type, 0);
			if(buildings >= it->m_iCount) {
				int try_set = it->m_iCount;
				if(it->m_Type != WORKER::INDUSTRY_WORKER)
					try_set += failed_to_set;
				if(buildings >= try_set) {
					if(it->m_Type != WORKER::INDUSTRY_WORKER)
						failed_to_set = 0;
					SetWorker(it->m_Type, CSystem::SET_WORKER_MODE_SET, try_set);
				}
				else {
					if(it->m_Type != WORKER::INDUSTRY_WORKER)
						failed_to_set -= buildings -it->m_iCount;
					SetWorker(it->m_Type, CSystem::SET_WORKER_MODE_SET, buildings);
				}
			}
			else {
				failed_to_set += it->m_iCount - buildings;
				SetWorker(it->m_Type, CSystem::SET_WORKER_MODE_SET, buildings);
			}
			AssertBotE(m_WorkersLeftToSet >= 0 && failed_to_set >= 0);
			failed_to_set += DecrementDueToFullStore(it->m_Type);
			if(it->m_Type == WORKER::INDUSTRY_WORKER) {
				failed_to_set += DecrementDueToWastedIndustry(max_industry);
			}
		}
	}
开发者ID:bote-team,项目名称:bote,代码行数:40,代码来源:Manager.cpp


注:本文中的CSystem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。