Esempio n. 1
0
		//-------------------------------------------------------------
		//-------------------------------------------------------------
		void Entity::AddEntity(const EntitySPtr& in_child)
		{
            CS_ASSERT(in_child != nullptr, "Cannot add null child");
            CS_ASSERT(in_child->GetParent() == nullptr, "Cannot add child with existing parent");
            CS_ASSERT(in_child->GetScene() == nullptr, "Cannot add child with existing scene");
            
            m_children.push_back(in_child);
            m_transform.AddChildTransform(&in_child->GetTransform());
            in_child->m_parent = this;
			
			if(m_scene != nullptr)
			{
				//This will add the entity and any children it may have
				m_scene->Add(in_child);
			}
		}
Esempio n. 2
0
//-------------------------------------------------------------
//-------------------------------------------------------------
void Entity::AddEntity(const EntitySPtr& in_child)
{
    CS_ASSERT(in_child != nullptr, "Cannot add null child");
    CS_ASSERT(in_child->GetParent() == nullptr, "Cannot add child with existing parent");
    CS_ASSERT(in_child->GetScene() == nullptr, "Cannot add child with existing scene");
    CS_ASSERT(m_children.size() < static_cast<std::vector<EntitySPtr>::size_type>(std::numeric_limits<u32>::max()), "There are too many child entities. It cannot exceed "
              + CSCore::ToString(std::numeric_limits<u32>::max()) + ".");

    m_children.push_back(in_child);
    m_transform.AddChildTransform(&in_child->GetTransform());
    in_child->m_parent = this;

    if(m_scene != nullptr)
    {
        //This will add the entity and any children it may have
        m_scene->Add(in_child);
    }
}
Esempio n. 3
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();
            }
        }
    }