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


C++ IEntitySystem类代码示例

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


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

示例1: FUNCTION_PROFILER

bool CVisibleObjectsHelper::CheckObjectViewDist(const Agent& agent, const SVisibleObject &visibleObject) const
{
	FUNCTION_PROFILER(GetISystem(), PROFILE_GAME);

	assert(agent.IsValid());

	bool bInViewDist = true;

	IEntitySystem *pEntitySystem = gEnv->pEntitySystem;
	assert(pEntitySystem);

	IEntity *pAIEntity = pEntitySystem->GetEntity(agent.GetEntityID());
	IEntity *pObjectEntity = pEntitySystem->GetEntity(visibleObject.entityId);

	IComponentRender *pObjectRenderProxy = (pAIEntity != NULL && pObjectEntity ? static_cast<IComponentRender *>(pObjectEntity->GetComponent<IComponentRender>().get()) : NULL);
	if (pObjectRenderProxy != NULL)
	{
		IRenderNode *pObjectRenderNode = pObjectRenderProxy->GetRenderNode();
		if (pObjectRenderNode != NULL)
		{
			const float fDistanceSq = pAIEntity->GetWorldPos().GetSquaredDistance(pObjectEntity->GetWorldPos());
			const float fMaxViewDistSq = sqr(pObjectRenderNode->GetMaxViewDist());
			
			bInViewDist = (fDistanceSq <= fMaxViewDistSq);
		}
	}

	return bInViewDist;
}
开发者ID:danielasun,项目名称:dbho-GameSDK,代码行数:29,代码来源:VisibleObjectsHelper.cpp

示例2: GameWarning

int CScriptBind_Action::GetPlayerList( IFunctionHandler *pH )
{
	CGameServerNub * pNub = m_pCryAction->GetGameServerNub();
	if (!pNub)
	{
		GameWarning("No game server nub");
		return pH->EndFunction();
	}
	TServerChannelMap *playerMap = m_pCryAction->GetGameServerNub()->GetServerChannelMap();
	if (!playerMap)
		return pH->EndFunction();

	IEntitySystem *pES = gEnv->pEntitySystem;

	int	k=1;
	SmartScriptTable playerList(m_pSS);
	
	for (TServerChannelMap::iterator it = playerMap->begin(); it != playerMap->end(); it++)
	{
		EntityId playerId = it->second->GetPlayerId();
		
		if (!playerId)
			continue;

		IEntity *pPlayer = pES->GetEntity(playerId);
		if (!pPlayer)
			continue;
		if (pPlayer->GetScriptTable())
			playerList->SetAt(k++, pPlayer->GetScriptTable());
	}

	return pH->EndFunction(*playerList);
}
开发者ID:aronarts,项目名称:FireNET,代码行数:33,代码来源:ScriptBind_Action.cpp

示例3: FindPrev

//------------------------------------------------------------------------
int CInventory::FindPrev(IEntityClass *pClass, const char *category, int firstSlot, bool wrap) const
{
	IEntitySystem *pEntitySystem = gEnv->pEntitySystem;
	for (int i = (firstSlot > -1)?firstSlot+1:0; i < m_stats.slots.size(); i++)
	{
		IEntity *pEntity = pEntitySystem->GetEntity(m_stats.slots[firstSlot-i]);
		bool ok=true;
		if (pEntity->GetClass() != pClass)
			ok=false;
		if (ok && category && category[0] && strcmp(m_pGameFrameWork->GetIItemSystem()->GetItemCategory(pEntity->GetClass()->GetName()), category))
			ok=false;

		if (ok)
			return i;
	}

	if (wrap && firstSlot > 0)
	{
		int count = GetCount();
		for (int i = 0; i < firstSlot; i++)
		{
			IEntity *pEntity = pEntitySystem->GetEntity(m_stats.slots[count-i+firstSlot]);
			bool ok=true;
			if (pEntity->GetClass() != pClass)
				ok=false;
			if (ok && category && category[0] && strcmp(m_pGameFrameWork->GetIItemSystem()->GetItemCategory(pEntity->GetClass()->GetName()), category))
				ok=false;

			if (ok)
				return i;
		}
	}

	return -1;
}
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:36,代码来源:Inventory.cpp

示例4: ResetState

void CDialogActorContext::BeginSession()
{
	DiaLOG::Log(DiaLOG::eAlways, "[DIALOG] CDialogActorContext::BeginSession: %s Now=%f 0x%p actorID=%d ",
		m_pSession->GetDebugName(), m_pSession->GetCurTime(), this, m_actorID);	

	ResetState();

	IEntitySystem* pES = gEnv->pEntitySystem;
	pES->AddEntityEventListener( m_entityID, ENTITY_EVENT_AI_DONE, this );
	pES->AddEntityEventListener( m_entityID, ENTITY_EVENT_DONE, this );
	pES->AddEntityEventListener( m_entityID, ENTITY_EVENT_RESET, this );

	switch (GetAIBehaviourMode())
	{
	case CDialogSession::eDIB_InterruptAlways:
		ExecuteAI( m_goalPipeID, "ACT_ANIM" );
		break;
	case CDialogSession::eDIB_InterruptMedium:
		ExecuteAI( m_goalPipeID, "ACT_DIALOG" );
		break;
	case CDialogSession::eDIB_InterruptNever:
		break;
	}
	m_bNeedsCancel = true;
}
开发者ID:aronarts,项目名称:FireNET,代码行数:25,代码来源:DialogActorContext.cpp

示例5: OnIterStart

	virtual void OnIterStart(SActivationInfo *pActInfo)
	{
		const int type = GetPortInt(pActInfo, EIP_Type);

		IEntitySystem *pEntitySystem = gEnv->pEntitySystem;
		if (pEntitySystem)
		{
			IEntityItPtr iter = pEntitySystem->GetEntityIterator();
			if (iter)
			{
				iter->MoveFirst();
				IEntity *pEntity = NULL;
				while (!iter->IsEnd())
				{
					pEntity = iter->Next();
					if (pEntity)
					{
						const EntityId id = pEntity->GetId();
						const EEntityType entityType = GetEntityType(id);
						if (IsValidType(type, entityType))
						{
							AddEntity(id);
						}
					}
				}
			}
		}
	}
开发者ID:aronarts,项目名称:FireNET,代码行数:28,代码来源:FlowEntityIterator.cpp

示例6: Destroy

//------------------------------------------------------------------------
void CInventory::Destroy()
{
  //
  //CryLog("%s::CInventory::Destroy()",GetEntity()->GetName());
  //
	if(!GetISystem()->IsSerializingFile())
	{
		IEntitySystem *pEntitySystem = gEnv->pEntitySystem;
		IItemSystem *pItemSystem = gEnv->pGame->GetIGameFramework()->GetIItemSystem();

		TInventoryVector deleteList = m_stats.slots;
		for (TInventoryIt it = deleteList.begin(); it != deleteList.end(); ++it)
		{
			EntityId entityId = *it;

			IItem *pItem = pItemSystem->GetItem(entityId);
			if (pItem)
			{
				RemoveItemFromCategorySlot(pItem->GetEntityId());
				pItem->RemoveOwnerAttachedAccessories();
				pItem->AttachToHand(false);
				pItem->AttachToBack(false);
				pItem->SetOwnerId(0);
			}

			pEntitySystem->RemoveEntity(entityId);
		}
	}

	Clear();
}
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:32,代码来源:Inventory.cpp

示例7: Validate

//------------------------------------------------------------------------
int CInventory::Validate()
{
	TInventoryVector copyOfSlots;
	copyOfSlots.reserve(m_stats.slots.size());
	std::swap(copyOfSlots, m_stats.slots);

	int count = 0;
	const int slotCount = copyOfSlots.size();

	IEntitySystem *pEntitySystem = gEnv->pEntitySystem;
	for (int i = 0; i < slotCount; ++i)
	{
		EntityId itemId = copyOfSlots[i];
		IEntity *pEntity = pEntitySystem->GetEntity(itemId);
		if (!pEntity)
		{
			++count;
		}
		else
		{
			m_stats.slots.push_back(itemId);
		}
	}

	return count;
}
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:27,代码来源:Inventory.cpp

示例8: GetCountOfClass

//------------------------------------------------------------------------
int CInventory::GetCountOfClass(const char *className) const
{
	int count = 0;

	IEntitySystem *pEntitySystem = gEnv->pEntitySystem;
	
	IEntityClass* pClass = (className != NULL) ? pEntitySystem->GetClassRegistry()->FindClass( className ) : NULL;
	if (pClass)
	{
		for (TInventoryCIt it = m_stats.slots.begin(); it != m_stats.slots.end(); ++it)
		{
			IEntity *pEntity = pEntitySystem->GetEntity(*it);
			if ((pEntity != NULL) && (pEntity->GetClass() == pClass))
			{
					++count;
			}
		}
		TInventoryVectorEx::const_iterator endEx = m_stats.accessorySlots.end();
		for (TInventoryVectorEx::const_iterator cit = m_stats.accessorySlots.begin(); cit!=endEx; ++cit)
		{
			if (*cit == pClass)
			{
				count++;
			}
		}
	}

	return count;
}
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:30,代码来源:Inventory.cpp

示例9: DetachEntity

//------------------------------------------------------------------------
bool CVehicleActionEntityAttachment::DetachEntity()
{
	IEntitySystem *pEntitySystem = gEnv->pEntitySystem;
	assert(pEntitySystem);

	if(IEntity *pEntity = pEntitySystem->GetEntity(m_entityId))
	{
		IVehicleSystem *pVehicleSystem = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem();
		assert(pVehicleSystem);

		// FIXME: remove this workaround, replace by e.g. buddy constraint
		if(IVehicle *pVehicle = pVehicleSystem->GetVehicle(m_entityId))
		{
			int hitType = g_pGame->GetGameRules()->GetHitTypeId("disableCollisions");
			pVehicle->OnHit(m_pVehicle->GetEntityId(), m_pVehicle->GetEntityId(), 10.0f, Vec3(0.0f, 0.0f, 0.0f), 0.0f, hitType, false);
		}

		pEntity->DetachThis();
		m_isAttached = false;

		m_timer = g_parachuteTimeMax;
		m_pVehicle->SetObjectUpdate(this, IVehicle::eVOU_AlwaysUpdate);
		return true;
	}

	return false;
}
开发者ID:super-nova,项目名称:NovaRepo,代码行数:28,代码来源:VehicleActionEntityAttachment.cpp

示例10: DeleteDynamicEntities

void CCheckpointSystem::DeleteDynamicEntities()
{
	IEntitySystem *pEntitySystem = gEnv->pEntitySystem;
	IEntityItPtr pIt = pEntitySystem->GetEntityIterator();
	//////////////////////////////////////////////////////////////////////////
	pIt->MoveFirst();
	while (!pIt->IsEnd())
	{
		IEntity * pEntity = pIt->Next();
		uint32 nEntityFlags = pEntity->GetFlags();

		// Local player must not be deleted.
		if (nEntityFlags & ENTITY_FLAG_LOCAL_PLAYER)
			continue;

		if (nEntityFlags & ENTITY_FLAG_SPAWNED)
			pEntitySystem->RemoveEntity( pEntity->GetId() );
	}
	// Force deletion of removed entities.
	pEntitySystem->DeletePendingEntities();
	//////////////////////////////////////////////////////////////////////////

	// Reset entity pools
	pEntitySystem->GetIEntityPoolManager()->ResetPools(false);
}
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:25,代码来源:CheckPointSystem.cpp

示例11: Reset

//------------------------------------------------------------------------
void CVehicleDamageBehaviorDetachPart::Reset()
{
	if (m_detachedEntityId)
	{
		for(TDetachedStatObjs::iterator ite = m_detachedStatObjs.begin(), end = m_detachedStatObjs.end(); ite != end; ++ite)
		{
			CVehiclePartBase	*pPartBase = ite->first;

			if(IStatObj *pStatObj = ite->second)
			{
				if(pPartBase)
				{
					pPartBase->SetStatObj(pStatObj);
				}

				pStatObj->Release();
			}
		}

		m_detachedStatObjs.clear();

		if(GetISystem()->IsSerializingFile() != 1)
		{		
			IEntitySystem* pEntitySystem = gEnv->pEntitySystem;
			pEntitySystem->RemoveEntity(m_detachedEntityId, true);
		}
		
		m_detachedEntityId = 0;
	}	
}
开发者ID:aronarts,项目名称:FireNET,代码行数:31,代码来源:VehicleDamageBehaviorDetachPart.cpp

示例12: SpawnEntity

//------------------------------------------------------------------------
void CVehicleActionEntityAttachment::SpawnEntity()
{
	IEntitySystem* pEntitySystem = gEnv->pEntitySystem;
	assert(pEntitySystem);

	IEntityClassRegistry* pClassRegistry = pEntitySystem->GetClassRegistry();
	assert(pClassRegistry);

	IEntityClass* pEntityClass = pClassRegistry->FindClass(m_entityClassName.c_str());
	if (!pEntityClass)
		return;

	char pEntityName[256];
	_snprintf(pEntityName, 256, "%s_%s", m_pVehicle->GetEntity()->GetName(), m_entityClassName.c_str());
	pEntityName[sizeof(pEntityName)-1] = '\0';

	SEntitySpawnParams params;
	params.sName = pEntityName;
	params.nFlags = ENTITY_FLAG_CLIENT_ONLY;
	params.pClass = pEntityClass;

	IEntity* pEntity = pEntitySystem->SpawnEntity(params, true);
	if (!pEntity)
	{
		m_entityId = 0;
		return;
	}

	m_entityId = pEntity->GetId();

	m_pVehicle->GetEntity()->AttachChild(pEntity);
	pEntity->SetLocalTM(m_pHelper->GetVehicleTM());

	m_isAttached = true;
}
开发者ID:mrwonko,项目名称:CrysisVR,代码行数:36,代码来源:VehicleActionEntityAttachment.cpp

示例13: GetEntityType

EEntityType GetEntityType(EntityId id)
{
	int type = eET_Unknown;

	IEntitySystem *pEntitySystem = gEnv->pEntitySystem;
	if (pEntitySystem)
	{
		IEntity *pEntity = pEntitySystem->GetEntity(id);
		if (pEntity)
		{
			type = eET_Valid;

			IEntityClass *pClass = pEntity->GetClass();
			if (pClass)
			{
				const char* className = pClass->GetName();

				// Check AI
				if (pEntity->GetAI())
				{
					type |= eET_AI;
				}
				
				// Check actor
				IActorSystem *pActorSystem = gEnv->pGame->GetIGameFramework()->GetIActorSystem();
				if (pActorSystem)
				{
					IActor *pActor = pActorSystem->GetActor(id);
					if (pActor)
					{
						type |= eET_Actor;
					}
				}

				// Check vehicle
				IVehicleSystem *pVehicleSystem = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem();
				if (pVehicleSystem)
				{
					if (pVehicleSystem->IsVehicleClass(className))
					{
						type |= eET_Vehicle;
					}
				}

				// Check item
				IItemSystem *pItemSystem = gEnv->pGame->GetIGameFramework()->GetIItemSystem();
				if (pItemSystem)
				{
					if (pItemSystem->IsItemClass(className))
					{
						type |= eET_Item;
					}
				}
			}
		}
	}

	return (EEntityType)type;
}
开发者ID:aronarts,项目名称:FireNET,代码行数:59,代码来源:FlowEntityIterator.cpp

示例14: GetISystem

//////////////////////////////////////////////////////////////////////////
//
// Allows the game code to write game-specific data into the minimap xml
// file on level export. Currently used to export data to StatsTool
//
//////////////////////////////////////////////////////////////////////////
bool CEditorGame::GetAdditionalMinimapData(XmlNodeRef output)
{
	string classes = g_pGameCVars->g_telemetryEntityClassesToExport;
	if(!classes.empty())
	{
		// additional data relating to StatsTool
		XmlNodeRef statsNode = output->findChild("StatsTool");
		if(!statsNode)
		{
			statsNode = GetISystem()->CreateXmlNode("StatsTool");
			output->addChild(statsNode);
		}
		else
		{
			statsNode->removeAllChilds();
		}

		// first build a list of entity classes from the cvar
		std::vector<IEntityClass*> interestingClasses;
		int curPos = 0;
		string currentClass = classes.Tokenize(",",curPos);
		IEntitySystem* pES = GetISystem()->GetIEntitySystem();
		if(IEntityClassRegistry* pClassReg = pES->GetClassRegistry())
		{
			while (!currentClass.empty())
			{
				if(IEntityClass* pClass = pClassReg->FindClass(currentClass.c_str()))
				{
					interestingClasses.push_back(pClass);
				}

				currentClass = classes.Tokenize(",",curPos);
			}
		}

		// now iterate through all entities and save the ones which match the classes
		if(interestingClasses.size() > 0)
		{
			IEntityItPtr it = pES->GetEntityIterator();
			while(IEntity* pEntity = it->Next())
			{
				if(stl::find(interestingClasses, pEntity->GetClass()))
				{
					XmlNodeRef entityNode = GetISystem()->CreateXmlNode("Entity");
					statsNode->addChild(entityNode);

					entityNode->setAttr("class", pEntity->GetClass()->GetName());
					Vec3 pos = pEntity->GetWorldPos();
					entityNode->setAttr("x", pos.x);
					entityNode->setAttr("y", pos.y);
					entityNode->setAttr("z", pos.z);
				}
			}
		}
	}

	return true;
}
开发者ID:aronarts,项目名称:FireNET,代码行数:64,代码来源:EditorGame.cpp

示例15: DestroyGameObject

	virtual void DestroyGameObject( const char* name )
	{
		IEntitySystem* pEntitySystem = PerModuleInterface::g_pSystemTable->pEntitySystem;
		IAUEntity* pEnt = pEntitySystem->Get(name);
		if (pEnt)
		{
			DestroyGameObject( pEnt->GetObject()->GetObjectId() );
		}
	}
开发者ID:ABuus,项目名称:RuntimeCompiledCPlusPlus,代码行数:9,代码来源:GameManager.cpp


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