EContextEstablishTaskResult OnStep( SContextEstablishState& state ) { CScopedRemoveObjectUnlock unlockRemovals(CCryAction::GetCryAction()->GetGameContext()); if (m_skipGameRules || m_skipPlayers) { IEntityItPtr i = gEnv->pEntitySystem->GetEntityIterator(); while(!i->IsEnd()) { IEntity* pEnt = i->Next(); // skip gamerules if (m_skipGameRules) if (pEnt->GetId() == CCryAction::GetCryAction()->GetIGameRulesSystem()->GetCurrentGameRulesEntity()->GetId()) continue; // skip players if (m_skipPlayers) { IActor* pActor = CCryAction::GetCryAction()->GetIActorSystem()->GetActor(pEnt->GetId()); if (pActor && pActor->IsPlayer()) continue; } pEnt->ClearFlags(ENTITY_FLAG_UNREMOVABLE); // force remove all other entities gEnv->pEntitySystem->RemoveEntity(pEnt->GetId(), true); } if (!m_skipGameRules) gEnv->pEntitySystem->ReserveEntityId(1); } else { if(!gEnv->pSystem->IsSerializingFile()) gEnv->pEntitySystem->Reset(); gEnv->pEntitySystem->ReserveEntityId(1); } gEnv->pEntitySystem->ReserveEntityId( LOCAL_PLAYER_ENTITY_ID ); CActionGame::Get()->OnEntitySystemReset(); return eCETR_Ok; }