示例#1
0
void NodeSystem::assessNodeRemovals(entityx::Entity entity)
{
    if(entity.valid())
    {
        auto node = entity.component<CNode>();
        if(node)
        {
            if(node->mCull)
                node->removeChildren();

            for(entityx::Entity dc : node->mRemoveChildren)
            {
                if(node->hasChild(dc))
                {
                    node->mChildren.erase(dc);
                    if(dc)
                    {
                        dc.component<CNode>()->cull();
                        for(entityx::Entity gc : dc.component<CNode>()->getChildren())
                        {
                            if(gc)
                            {
                                gc.component<CNode>()->cull();
                                assessNodeRemovals(gc);
                            }
                        }
                    }
                }
            }
            node->mRemoveChildren.clear();
        }
    }
}
示例#2
0
void NodeSystem::assessNodeAdditions(entityx::Entity entity)
{
    if(entity.valid())
    {
        auto node = entity.component<CNode>();
        if(node)
        {
            for(entityx::Entity ac : node->mAddChildren)
            {
                if(ac.valid())
                {
                    if(!node->hasChild(ac) && ac.component<CNode>() && entity != ac)
                    {
                        auto wp = ac.component<CNode>()->getWorldPosition();

                        //Replaces owner.
                        if(ac.component<CNode>()->mParent)
                            ac.component<CNode>()->mParent.component<CNode>()->mChildren.erase(ac);

                        ac.component<CNode>()->mParent = entity;
                        node->mChildren.insert(ac);
                    }
                }
            }
            node->mAddChildren.clear();
        }
    }
}
 void save( Archive &ar, entityx::Entity const & entity )
 {
     //        uint64_t id = entity.id().id();
     //        ar( make_nvp("entityID", id) );
     assert(entity.has_component<Tag>());
     auto e = const_cast<entityx::Entity &>(entity);
     auto tag = e.component<Tag>();
     assert(entity.valid());
     ar( cereal::make_nvp("uuid", (uint)(tag.get()->tag)) );
     
     //serialize over all components of each entity
     SERIALIZE("playerControl", PlayerControl);
     SERIALIZE("camera", Camera);
     SERIALIZE("orbitPath", OrbitPath);
 }
示例#4
0
	/**
	 * Gets the width of the player.
	 * @return the player's width, according to its sprite
	 */
    inline float getWidth(void) const
    { return game::entities.component<Solid>(player.id())->width; }