void RemoveComponentsOnDeathSystem::Update( double DeltaTime ) { for( ActorList_t::iterator it = mScene.GetActors().begin(), e = mScene.GetActors().end(); it != e; ++it ) { Actor& actor = **it; Opt<IRemoveComponentsOnDeathComponent> removeComponentsOnDeathC = actor.Get<IRemoveComponentsOnDeathComponent>(); if ( !removeComponentsOnDeathC.IsValid() ) { continue; } Opt<IHealthComponent> healthC = actor.Get<IHealthComponent>(); if( !healthC.IsValid() ) { continue; } if( healthC->IsAlive() ) { continue; } // create copy, component might drop itself std::vector<int32_t> const comps = removeComponentsOnDeathC->GetComponents(); std::for_each( std::begin( comps ), std::end( comps ), [&]( int32_t id ) { actor.DropComponent( id ); } ); } }
void RemoveComponentsOnDeathSystem::Update( double DeltaTime ) { for (auto actor : mScene.GetActorsFromMap( GetType_static() )) { Opt<IRemoveComponentsOnDeathComponent> removeComponentsOnDeathC = actor->Get<IRemoveComponentsOnDeathComponent>(); if ( !removeComponentsOnDeathC.IsValid() ) { continue; } Opt<IHealthComponent> healthC = actor->Get<IHealthComponent>(); if( !healthC.IsValid() ) { continue; } if( healthC->IsAlive() ) { continue; } // create copy, component might drop itself std::vector<int32_t> const comps = removeComponentsOnDeathC->GetComponents(); std::for_each( std::begin( comps ), std::end( comps ), [&]( int32_t id ) { actor->DropComponent( id ); } ); } }