本文整理汇总了C++中EntityManager::acknowledgeDelete方法的典型用法代码示例。如果您正苦于以下问题:C++ EntityManager::acknowledgeDelete方法的具体用法?C++ EntityManager::acknowledgeDelete怎么用?C++ EntityManager::acknowledgeDelete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityManager
的用法示例。
在下文中一共展示了EntityManager::acknowledgeDelete方法的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));
}
}