Exemplo n.º 1
0
		//-------------------------------------------------------
		//-------------------------------------------------------
		void Scene::Add(const EntitySPtr& in_entity)
		{
            CS_ASSERT(in_entity != nullptr, "Cannot add a null entity");
            CS_ASSERT(in_entity->GetScene() == nullptr, "Cannot add an entity with pre-exisitng scene");
            CS_ASSERT((in_entity->GetParent() == nullptr || in_entity->GetParent()->GetScene() == this), "Cannot add an entity to a different scene than it's parent.");
            
			m_entities.push_back(in_entity);

			in_entity->SetScene(this);
            in_entity->OnAddedToScene();
            
            if (m_entitiesActive == true)
            {
                in_entity->OnResume();
                if (m_entitiesForegrounded == true)
                {
                    in_entity->OnForeground();
                }
            }
		}
    //-------------------------------------------------------
    //-------------------------------------------------------
    void Scene::Add(const EntitySPtr& in_entity)
    {
        CS_ASSERT(in_entity != nullptr, "Cannot add a null entity");
        CS_ASSERT(in_entity->GetScene() == nullptr, "Cannot add an entity with pre-exisitng scene");
        CS_ASSERT((in_entity->GetParent() == nullptr || in_entity->GetParent()->GetScene() == this), "Cannot add an entity to a different scene than its parent.");
        CS_ASSERT(m_entities.size() < static_cast<std::vector<EntitySPtr>::size_type>(std::numeric_limits<u32>::max()), "There are too many entities in the scene. It cannot exceed "
                  + ToString(std::numeric_limits<u32>::max()) + ".");
        
        m_entities.push_back(in_entity);

        in_entity->SetScene(this);
        in_entity->OnAddedToScene();
        
        if (m_entitiesActive == true)
        {
            in_entity->OnResume();
            if (m_entitiesForegrounded == true)
            {
                in_entity->OnForeground();
            }
        }
    }