//---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- void ManagerImplemented::ExecuteEvents() { std::map<Handle,DrawSet>::iterator it = m_DrawSets.begin(); std::map<Handle,DrawSet>::iterator it_end = m_DrawSets.end(); while( it != it_end ) { if( (*it).second.GoingToStop ) { InstanceContainer* pContainer = (*it).second.InstanceContainerPointer; pContainer->KillAllInstances( true ); (*it).second.IsRemoving = true; if (GetSoundPlayer() != NULL) { GetSoundPlayer()->StopTag((*it).second.GlobalPointer); } } if( (*it).second.GoingToStopRoot ) { InstanceContainer* pContainer = (*it).second.InstanceContainerPointer; pContainer->KillAllInstances( false ); } ++it; } }
//---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- void ManagerImplemented::GCDrawSet( bool isRemovingManager ) { // インスタンスグループ自体の削除処理 { std::map<Handle,DrawSet>::iterator it = m_RemovingDrawSets[1].begin(); while( it != m_RemovingDrawSets[1].end() ) { DrawSet& drawset = (*it).second; // 全破棄処理 drawset.InstanceContainerPointer->RemoveForcibly( true ); drawset.InstanceContainerPointer->~InstanceContainer(); InstanceContainer::operator delete( drawset.InstanceContainerPointer, this ); ES_SAFE_RELEASE( drawset.ParameterPointer ); ES_SAFE_DELETE( drawset.GlobalPointer ); if(m_cullingWorld != NULL) { m_cullingWorld->RemoveObject(drawset.CullingObjectPointer); Culling3D::SafeRelease(drawset.CullingObjectPointer); } m_RemovingDrawSets[1].erase( it++ ); } m_RemovingDrawSets[1].clear(); } { std::map<Handle,DrawSet>::iterator it = m_RemovingDrawSets[0].begin(); while( it != m_RemovingDrawSets[0].end() ) { DrawSet& drawset = (*it).second; m_RemovingDrawSets[1][ (*it).first ] = (*it).second; m_RemovingDrawSets[0].erase( it++ ); } m_RemovingDrawSets[0].clear(); } { std::map<Handle,DrawSet>::iterator it = m_DrawSets.begin(); while( it != m_DrawSets.end() ) { DrawSet& draw_set = (*it).second; // 削除フラグが立っている時 bool isRemoving = draw_set.IsRemoving; // 何も存在しない時 if( !isRemoving && draw_set.GlobalPointer->GetInstanceCount() == 0 ) { isRemoving = true; } // ルートのみ存在し、既に新しく生成する見込みがないとき if( !isRemoving && draw_set.GlobalPointer->GetInstanceCount() == 1 ) { InstanceContainer* pRootContainer = draw_set.InstanceContainerPointer; InstanceGroup* group = pRootContainer->GetFirstGroup(); if( group ) { Instance* pRootInstance = group->GetFirst(); if( pRootInstance && pRootInstance->GetState() == INSTANCE_STATE_ACTIVE ) { int maxcreate_count = 0; for( int i = 0; i < Min(pRootInstance->m_pEffectNode->GetChildrenCount(), Instance::ChildrenMax); i++ ) { auto child = (EffectNodeImplemented*) pRootInstance->m_pEffectNode->GetChild(i); float last_generation_time = child->CommonValues.GenerationTime.max * (child->CommonValues.MaxGeneration - 1) + child->CommonValues.GenerationTimeOffset.max + 1.0f; if( pRootInstance->m_LivingTime >= last_generation_time ) { maxcreate_count++; } else { break; } } if( maxcreate_count == pRootInstance->m_pEffectNode->GetChildrenCount() ) { // 音が再生中でないとき if (!GetSoundPlayer() || !GetSoundPlayer()->CheckPlayingTag(draw_set.GlobalPointer)) { isRemoving = true; } } } } } if( isRemoving ) { // 消去処理 StopEffect( (*it).first ); if( (*it).second.RemovingCallback != NULL ) { (*it).second.RemovingCallback( this, (*it).first, isRemovingManager ); } m_RemovingDrawSets[0][ (*it).first ] = (*it).second; m_DrawSets.erase( it++ ); } else { ++it; } } } }
sf::Sound* PlaySound(const std::string& name, int x, int y) { sf::Sound* s = GetSoundPlayer().PlaySound(name); //s->setPosition(mob_position::x, y, 0); return s; }