コード例 #1
0
ファイル: CBaseManager.cpp プロジェクト: RenEvo/dead6
BuildingGUID CBaseManager::GetBuildingFromInterface(EntityId nEntityId, IBuildingController **ppController) const
{
	if (NULL != ppController) *ppController = NULL;

	// Get the entity
	IEntity *pEntity = gEnv->pEntitySystem->GetEntity(nEntityId);
	if (NULL == pEntity) return GUID_INVALID;
	if (false == pEntity->CheckFlags(ENTITY_FLAG_ISINTERFACE)) return GUID_INVALID;

	// Check all controllers
	for (ControllerList::const_iterator itBuilding = m_ControllerList.begin(); itBuilding != m_ControllerList.end(); itBuilding++)
	{
		if (true == itBuilding->second->HasInterface(pEntity))
		{
			// Got it
			if (NULL != ppController) *ppController = itBuilding->second;
			return itBuilding->first;
		}
	}
	return GUID_INVALID;
}