Example #1
0
    void ResourceManager::endLoadPhase(const uint16 persistence)
    {
        if (m_instance && m_instance->m_loadPhase.load())
        {
            auto& inst = *m_instance;

            std::size_t count = 0;
            {
                std::lock_guard<std::recursive_mutex> lock(inst.m_mutex);

                for (auto itr = inst.m_resources.begin(); itr != inst.m_resources.end();)
                {
                    if (inst.m_loadPhaseResources.find(itr->first) == inst.m_loadPhaseResources.end() && itr->second->getPersistence() >= persistence)
                    {
                        JOP_DEBUG_DIAG("\"" << itr->first.first << "\" (" << itr->first.second.name() << ") unloaded");

                        itr = inst.m_resources.erase(itr);
                        ++count;
                        continue;
                    }

                    ++itr;
                }

                inst.m_loadPhaseResources.clear();
            }

            inst.m_loadPhase.store(false);

            JOP_DEBUG_INFO("Resource load phase ended, " << count << " resources removed");
        }
    }
Example #2
0
    void Collider::registerListener(ContactListener& listener)
    {
        if (listener.m_collider != this)
        {
            if (listener.m_collider)
                listener.m_collider->m_listeners.erase(&listener);

            // Replace old collider with this
            listener.m_collider = this;

            // Check if this listener is already registered
            std::pair<std::set<ContactListener*>::iterator, bool> ret;
            ret = m_listeners.insert(&listener);

            if (ret.second == false)
            {
                // Erase the old and replace it with new
                m_listeners.erase(ret.first);
                m_listeners.insert(&listener);
            }
        }
        else
        {
            JOP_DEBUG_INFO("Could not register listener for Collider2D: Listener is already registered for collider");
            return;
        }
    }
    void updateScreenPosition(const std::string& root, const glm::vec3& newPos)
    {
        int index = findScreen(root);

        if (index == -1)
        {
            JOP_DEBUG_INFO("updateScreen not found: " << root);
            return;
        }

        m_screens[index].obj->setPosition(newPos);
    }
    void setNewMask(const std::string& root, const unsigned int mask)
    {
        int index = findScreen(root);

        if (index == -1)
        {
            JOP_DEBUG_INFO("updateScreen not found: " << root);
            return;
        }

        auto s = m_screens[index];

        for (unsigned int i = 0u; i < s.obj->getChildren().size() - 1u; ++i)
        {
            s.obj->findChild(s.names[i])->getComponent<jop::Text>()->setRenderGroup(mask);
        }
    }
    void updateScreenValues(const std::string& root, const std::vector<int>& newValues)
    {
        int index = findScreen(root);

        if (index == -1)
        {
            JOP_DEBUG_INFO("updateScreen not found: " << root);
            return;
        }

        auto& s = m_screens[index];

        JOP_ASSERT(s.names.size() == newValues.size(), "updateScreen newValues size not matching with old.");

        for (unsigned int i = 0u; i < s.obj->getChildren().size() - 1u; ++i)
        {
            s.obj->findChild(s.names[i])->getComponent<jop::Text>()->setString(std::to_string(newValues[i]));
        }

    }