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


C++ IEntitySystem::FindEntityByName方法代码示例

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


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

示例1: OnIterStart

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

		// Find the entity
		IEntitySystem *pEntitySystem = gEnv->pEntitySystem;
		if (pEntitySystem)
		{
			IEntity *pArea = pEntitySystem->FindEntityByName(area);
			if (pArea)
			{
				IEntityAreaProxy *pAreaProxy = (IEntityAreaProxy*)pArea->GetProxy(ENTITY_PROXY_AREA);
				if (pAreaProxy)
				{
					Vec3 min, max, worldPos(pArea->GetWorldPos());
					min.Set(0.f,0.f,0.f);
					max.Set(0.f,0.f,0.f);
					EEntityAreaType areaType = pAreaProxy->GetAreaType();

					// Construct bounding space around area
					switch (areaType)
					{
						case ENTITY_AREA_TYPE_BOX:
						{
							pAreaProxy->GetBox(min, max);
							min += worldPos;
							max += worldPos;
						}
						break;
						case ENTITY_AREA_TYPE_SPHERE:
						{
							Vec3 center;
							float radius = 0.f;
							pAreaProxy->GetSphere(center, radius);
							
							min.Set(center.x-radius, center.y-radius, center.z-radius);
							max.Set(center.x+radius, center.y+radius, center.z+radius);
						}
						break;
						case ENTITY_AREA_TYPE_SHAPE:
						{
							const Vec3 *points = pAreaProxy->GetPoints();
							const int count = pAreaProxy->GetPointsCount();
							if (count > 0)
							{
								Vec3 p = worldPos + points[0];
								min = p;
								max = p;
								for (int i = 1; i < count; ++i)
								{
									p = worldPos + points[i];
									if (p.x < min.x) min.x = p.x;
									if (p.y < min.y) min.y = p.y;
									if (p.z < min.z) min.z = p.z;
									if (p.x > max.x) max.x = p.x;
									if (p.y > max.y) max.y = p.y;
									if (p.z > max.z) max.z = p.z;
								}
							}
						}
						break;
					}

					IPhysicalWorld *pWorld = gEnv->pPhysicalWorld;
					IPhysicalEntity **ppList = NULL;
					int	numEnts = pWorld->GetEntitiesInBox(min,max,ppList,ent_all);
					for (int i = 0; i < numEnts; ++i)
					{
						const EntityId id = pWorld->GetPhysicalEntityId(ppList[i]);
						const EEntityType entityType = GetEntityType(id);
						if (IsValidType(type, entityType))
						{
							// Sanity check - Test entity's position
							IEntity *pEntity = pEntitySystem->GetEntity(id);
							if (pEntity && pAreaProxy->CalcPointWithin(id, pEntity->GetWorldPos(), pAreaProxy->GetHeight()==0))
							{
								AddEntity(id);
							}
						}
					}
				}
			}
		}
	}
开发者ID:aronarts,项目名称:FireNET,代码行数:85,代码来源:FlowEntityIterator.cpp


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