Esempio n. 1
0
void
AbstractAnimation::targetAddedHandler(AbstractComponent::Ptr cmp, 
									  Node::Ptr node)
{
	_addedSlot = node->added()->connect(std::bind(
		&AbstractAnimation::addedHandler,
		shared_from_this(),
		std::placeholders::_1,
		std::placeholders::_2,
		std::placeholders::_3
	));

	_removedSlot = node->removed()->connect(std::bind(
		&AbstractAnimation::removedHandler,
		shared_from_this(),
		std::placeholders::_1,
		std::placeholders::_2,
		std::placeholders::_3
	));
}
Esempio n. 2
0
void
bullet::ColliderDebug::targetAddedHandler(AbstractComponent::Ptr, Node::Ptr target)
{
	if (targets().size() > 1)
		throw std::logic_error("Collider debugging component cannot be added twice.");

	_addedSlot = target->added()->connect(std::bind(
		&ColliderDebug::addedHandler,
		std::static_pointer_cast<ColliderDebug>(shared_from_this()),
		std::placeholders::_1,
		std::placeholders::_2,
		std::placeholders::_3
	));

	_removedSlot = target->removed()->connect(std::bind(
		&ColliderDebug::removedHandler,
		std::static_pointer_cast<ColliderDebug>(shared_from_this()),
		std::placeholders::_1,
		std::placeholders::_2,
		std::placeholders::_3
	));
}
Esempio n. 3
0
void
MasterLodScheduler::targetAdded(Node::Ptr target)
{
    AbstractComponent::targetAdded(target);

    _nodeAddedSlot = target->added().connect(
        [this](Node::Ptr target,
               Node::Ptr node,
               Node::Ptr parent)
        {
            auto lodSchedulerNodes = NodeSet::create(node)
                ->descendants(true)
                ->where([](Node::Ptr descendant) -> bool { return descendant->hasComponent<AbstractLodScheduler>(); });

            for (auto lodSchedulerNode : lodSchedulerNodes->nodes())
                for (auto lodScheduler : lodSchedulerNode->components<AbstractLodScheduler>())
                    _lodSchedulers.push_back(lodScheduler);
        }
    );

    _nodeRemovedSlot = target->removed().connect(
        [this](Node::Ptr target,
               Node::Ptr node,
               Node::Ptr parent)
        {
            auto lodSchedulerNodes = NodeSet::create(node)
                ->descendants(true)
                ->where([](Node::Ptr descendant) -> bool { return descendant->hasComponent<AbstractLodScheduler>(); });

            for (auto lodSchedulerNode : lodSchedulerNodes->nodes())
                for (auto lodScheduler : lodSchedulerNode->components<AbstractLodScheduler>())
                    _lodSchedulers.erase(
                        std::remove(_lodSchedulers.begin(), _lodSchedulers.end(), lodScheduler),
                        _lodSchedulers.end()
                    );
        }
    );

    _componentAddedSlot = target->componentAdded().connect(
        [this](Node::Ptr                node,
               Node::Ptr                target,
               AbstractComponent::Ptr   component)
        {
            auto lodScheduler = std::dynamic_pointer_cast<AbstractLodScheduler>(component);

            if (lodScheduler)
                _lodSchedulers.push_back(lodScheduler);
        }
    );

    _componentRemovedSlot = target->componentRemoved().connect(
        [this](Node::Ptr                node,
               Node::Ptr                target,
               AbstractComponent::Ptr   component)
        {
            auto lodScheduler = std::dynamic_pointer_cast<AbstractLodScheduler>(component);

            if (lodScheduler)
                _lodSchedulers.erase(
                    std::remove(_lodSchedulers.begin(), _lodSchedulers.end(), lodScheduler),
                    _lodSchedulers.end()
                );
        }
    );
}