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);
    }
}