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


C++ EntityManager::getNewEntities方法代码示例

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


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

示例1: update

void SCollision::update(Map * world, float frameTime)
{
	EntityManager * entM = world->getEntityManager();

	// if entity manager has changed, ( happens when switching worlds ), cache new entity manager's entities who have hitboxes
	if( this->entM != entM )
		startUp( entM );

	auto deletedlist = entM->getDeletedEntities();
	auto newlist = entM->getNewEntities();

	PPosition * pos1, * pos2;
	PBoundingBox * hitbox1, * hitbox2;
	PImage * img1, * img2;

	// query entity manager for newly created entities and
	// update system's vectors with new entities if new entities exist
	acknowledgeInserts( newlist, entM );

	for(size_t cache_index = 0; cache_index < pboxes.size(); cache_index++)
	{	
		pos1 = pposes[cache_index]; 
		hitbox1 = pboxes[cache_index];
		img1 = images[cache_index];
		
		// clear this entity of the previous pass's colliding entities.
		if ( cache_index == 0 )
			hitbox1->collidingEntities.clear();

		// if this entity was marked for deletion...
		if( removeDelEnt( deletedlist, hitbox1->entity_id, cache_index ) )
		{
			// continue on to next entity
			cache_index--;
			continue;
		}

		for( size_t cache_index_inner = cache_index+1; cache_index_inner < pboxes.size(); cache_index_inner++ )
		{
			pos2 = pposes[cache_index_inner];
			hitbox2 = pboxes[cache_index_inner];			
			img2 = images[cache_index_inner];

			if ( cache_index == 0 )
				hitbox2->collidingEntities.clear();

			// if this entity was marked for deletion...
			if( removeDelEnt( deletedlist, hitbox2->entity_id, cache_index_inner ) )
			{
				// continue on to next entity
				cache_index_inner--;
				continue;
			}			
			
			if(hitbox1->active && hitbox2->active)
			{	
				if(collisionOccurring(entM, pos1, hitbox1, pos2, hitbox2))
				{
					hitbox1->collidingEntities.push_back(hitbox2->entity_id);
					hitbox2->collidingEntities.push_back(hitbox1->entity_id);

					// notify scripts of collision event
					LuaDoa::fireEventMulti(ON_COLLIDE, hitbox1->entity_id, hitbox2->entity_id);
					LuaDoa::fireEventMulti(ON_COLLIDE, hitbox2->entity_id, hitbox1->entity_id);
				}		
			}
		}
	}
	// acknowledge the deletions so that the entity manager may remove marked entities from store
	for(auto it = deletedlist.begin(); it != deletedlist.end(); it++)
	{
		if(!entM->acknowledgedDelete[this->sys_id][(*it)])
			entM->acknowledgeDelete(this->sys_id, (*it));
	}
}
开发者ID:brep,项目名称:Vertigo2D,代码行数:75,代码来源:SCollision.cpp


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