Example #1
0
void KillFeedSystem::Update(double dt)
{
    auto killFeeds = m_World->GetComponents("KillFeed");
    if (killFeeds == nullptr) {
        return;
    }

    for (auto it = m_DeathQueue.begin(); it != m_DeathQueue.end(); it++) {
        (*it).TimeToLive -= dt;
    }

    for (auto& killFeedComponent : *killFeeds) {
        EntityWrapper entity = EntityWrapper(m_World, killFeedComponent.EntityID);

        for (int i = 1; i <= 3; i++) {
            EntityWrapper child = entity.FirstChildByName("KillFeed" + std::to_string(i));
            if (child.HasComponent("Text")) {
                (Field<std::string>)child["Text"]["Content"] = "";
            }
        }
      
        int feedIndex = 1;
        for (auto it = m_DeathQueue.begin(); it != m_DeathQueue.end(); ) {
            bool remove = false;
            
            EntityWrapper child = entity.FirstChildByName("KillFeed" + std::to_string(feedIndex));

            if (child.HasComponent("Text")) {

                std::string str = "";
                //Add killer to the start of string.
                str = (*it).KillerColor + "\\" + std::to_string((*it).KillerClass) + "\\CFFFFFF" +  " " + (*it).KillerName + "  ";
                //Add Weapon to middle of string.
                str += "\\" + std::to_string((*it).KillerClass+3) + "  ";
                //Add victim to the end of string
                str += (*it).VictimColor + "\\" + std::to_string((*it).VictimClass) + "\\CFFFFFF" + " " + (*it).VictimName;

                (Field<std::string>)child["Text"]["Content"] = str;

                if ((*it).TimeToLive <= 0.f) {
                    (Field<std::string>)child["Text"]["Content"] = "";
                    remove = true;
                }
            }
            feedIndex++;
            if(feedIndex > 3) {
                break;
            }

            if(remove) {
                it = m_DeathQueue.erase(it);
            } else {
                it++;
            }
        }
    }
}
EntityWrapper EntityManagerWrapper::getEntityByName(const std::string& name)
{
    CustomPropertyComponent::Handle cph;

    for (auto entity : m_manager->entities.entities_with_components(cph))
    {
        if (cph->property["name"] == name)
            return EntityWrapper(entity);
    }

    return createEntity();
}
Example #3
0
glm::quat TransformSystem::AbsoluteOrientation(World* world, EntityID entity)
{
    return TransformSystem::AbsoluteOrientation(EntityWrapper(world, entity));
}
Example #4
0
glm::vec3 TransformSystem::AbsolutePosition(World* world, EntityID entity)
{
    return TransformSystem::AbsolutePosition(EntityWrapper(world, entity));
}
Example #5
0
glm::mat4 TransformSystem::ModelMatrix(EntityID entityID, World* world)
{
    return ModelMatrix(EntityWrapper(world, entityID));
}
EntityWrapper EntityManagerWrapper::createEntity()
{
    entityx::Entity ent = m_manager->entities.create();
    ent.assign <CustomPropertyComponent> ();
    return EntityWrapper(ent);
}