当前位置: 首页>>代码示例>>C++>>正文


C++ RootEntity::setAttr方法代码示例

本文整理汇总了C++中RootEntity::setAttr方法的典型用法代码示例。如果您正苦于以下问题:C++ RootEntity::setAttr方法的具体用法?C++ RootEntity::setAttr怎么用?C++ RootEntity::setAttr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RootEntity的用法示例。


在下文中一共展示了RootEntity::setAttr方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: processAnonymousGet

void ClientConnection::processAnonymousGet(const Get& get)
{
    const std::vector<Root>& args = get->getArgs();
    if (args.empty())
    {
        Info serverInfo;
        RootEntity svObj;
        
        Atlas::Message::ListType prs;
        prs.push_back("server");
        svObj->setParentsAsList(prs);
        
        svObj->setName("Bob's StubServer");
        svObj->setAttr("server", "stubserver");
        svObj->setAttr("ruleset", "stub-world");
        svObj->setAttr("uptime", 666.0);
        svObj->setAttr("clients", 42);
        
        serverInfo->setArgs1(svObj);
        send(serverInfo);
    } else {
        std::string typeName = args.front()->getId();

        if (m_server->m_types.count(typeName))
        {
            Info typeInfo;
            typeInfo->setArgs1(m_server->m_types[typeName]);
            typeInfo->setRefno(get->getSerialno());
            send(typeInfo);
        } else
            sendError("unknown type " + typeName, get);
    }
}
开发者ID:danniellecandys,项目名称:eris,代码行数:33,代码来源:clientConnection.cpp

示例2: idListasObject

void Property<IdList>::add(const std::string & s, const RootEntity & ent) const
{
    if (!m_data.empty()) {
        ListType list;
        idListasObject(m_data, list);
        ent->setAttr(s, list);
    }
}
开发者ID:alriddoch,项目名称:cyphesis,代码行数:8,代码来源:EntityProperties.cpp

示例3: addToEntity

void ServerRouting::addToEntity(const RootEntity & ent) const
{
    ent->setObjtype("obj");
    ent->setAttr("server", "cyphesis");
    ent->setAttr("ruleset", m_svrRuleset);
    ent->setName(m_svrName);
    ent->setParents(std::list<std::string>(1, "server"));
    ent->setAttr("clients", m_numClients);
    ent->setAttr("uptime", m_world.upTime());
    ent->setAttr("builddate", std::string(consts::buildTime)+", "+std::string(consts::buildDate));
    ent->setAttr("buildid", consts::buildId);
    ent->setAttr("version", std::string(consts::version));
    if (restricted_flag) {
        ent->setAttr("restricted", "true");
    }
    ent->setAttr("entities", (long)m_world.getEntities().size());
    
    // We could add all sorts of stats here, but I don't know exactly what yet.
}
开发者ID:anthonypesce,项目名称:cyphesis,代码行数:19,代码来源:ServerRouting.cpp

示例4: addToEntity

void ServerRouting::addToEntity(const RootEntity & ent) const
{
    ent->setObjtype("obj");
    ent->setAttr("server", "cyphesis");
    ent->setAttr("ruleset", m_svrRuleset);
    ent->setName(m_svrName);
    ent->setParent("server");
    ent->setAttr("clients", m_numClients);
    ent->setAttr("uptime", m_world.upTime());
    ent->setAttr("buildid", consts::buildId);
    ent->setAttr("version", std::string(consts::version));
    if (restricted_flag) {
        ent->setAttr("restricted", "true");
    }
    ent->setAttr("entities", (long)m_world.getEntities().size());

    ent->setAttr("assets", Atlas::Message::ListType{"file://" + assets_directory});

    // We could add all sorts of stats here, but I don't know exactly what yet.
}
开发者ID:worldforge,项目名称:cyphesis,代码行数:20,代码来源:ServerRouting.cpp

示例5: sendResolvedEntityReferences

void EntityImporterBase::sendResolvedEntityReferences()
{
    if (!mEntitiesWithReferenceAttributes.empty()) {
        for (auto entryI : mEntitiesWithReferenceAttributes) {
            const auto& persistedEntityId = entryI.first;
            const auto& referenceEntries = entryI.second;

            auto createdEntityI = mEntityIdMap.find(persistedEntityId);
            if (createdEntityI == mEntityIdMap.end()) {
                S_LOG_WARNING("Could not find final server side entity id for persisted entity " << persistedEntityId << " when doing entity ref resolving.");
                continue;
            }
            const auto& createdEntityId = createdEntityI->second;

            //This should not fail at this phase, so we're not doing any checks.
            auto& persistedEntity = mPersistedEntities.find(persistedEntityId)->second;

            RootEntity entity;

            for (const auto& referenceEntry : referenceEntries) {
                Element element = persistedEntity->getAttr(referenceEntry.propertyName);
                resolveEntityReferences(element);
                entity->setAttr(referenceEntry.propertyName, element);
            }

            Set set;
            set->setFrom(mAvatarId);
            set->setSerialno(newSerialNumber());
            set->setTo(createdEntityId);
            set->setArgs1(entity);

            mSetOpsInTransit++;
            sigc::slot<void, const Operation&> slot = sigc::mem_fun(*this, &EntityImporterBase::operationSetResult);
            sendAndAwaitResponse(set, slot);
        }
    } else {
        sendMinds();
    }
}
开发者ID:worldforge,项目名称:cyphesis,代码行数:39,代码来源:EntityImporterBase.cpp

示例6: dispatch


//.........这里部分代码省略.........
        
        std::string id = args.front()->getId();
        assert(m_server->m_world.count(id));
        m_server->m_world.erase(id);
        
        Agent::broadcastSight(op);
    }
    
    Move mv = smart_dynamic_cast<Move>(op);
    if (mv.isValid()) {
        RootEntity ent = m_server->getEntity(op->getTo());
        
        std::vector<Root> args(op->getArgs());
        
        if (args.front()->hasAttr("loc")) {
            std::string newLocId = args.front()->getAttr("loc").asString();
            
            RootEntity oldLoc = m_server->getEntity(ent->getLoc()),
                newLoc = m_server->getEntity(newLocId);
            
            ent->setLoc(newLocId);
            // modify stamps?
            oldLoc->modifyContains().remove(ent->getId());
            newLoc->modifyContains().push_back(ent->getId());
        }
        
        if (args.front()->hasAttr("pos"))
            ent->setPosAsList(args.front()->getAttr("pos").asList());
            
        // handle velocity changes
        Agent::broadcastSight(op);
        return;
    }
    
    Sound snd = smart_dynamic_cast<Sound>(op);
    if (snd.isValid()) {
        
        std::vector<Root> args(op->getArgs());
        assert(!args.empty());
        
        if (snd->hasAttr("broadcast")) {
            Agent::broadcastSound(smart_dynamic_cast<RootOperation>(args.front()));
        }
    }
    
    Sight st = smart_dynamic_cast<Sight>(op);
    if (st.isValid()) {
        if (st->hasAttr("broadcast")) {
            std::vector<Root> args(op->getArgs());
            assert(!args.empty());
            Agent::broadcastSight(smart_dynamic_cast<RootOperation>(args.front()));
        }
    }
    
    Set s = smart_dynamic_cast<Set>(op);
    if (s.isValid()) {
        
        std::vector<Root> args(op->getArgs());
        for (unsigned int A=0; A < args.size(); ++A) {
            std::string eid = args[A]->getId();
        
            RootEntity entity = m_server->getEntity(eid);
            Root::const_iterator I = args[A]->begin();
            
            for (; I != args[A]->end(); ++I) {
                if ((I->first == "id") || (I->first == "parents") || (I->first == "objtype")) {
                    continue;
                }
                
                assert(I->first != "loc");
                entity->setAttr(I->first, I->second);
            }
        }

        Agent::broadcastSight(s);
    }
    
    Action act = smart_dynamic_cast<Action>(op);
    if (act.isValid()) {
        std::vector<Root> args(op->getArgs());
        
        if (act->getParents().front() == "command") {
            std::string cid = args[0]->getAttr("cid").asString();
            
            if (cid == "socket-shutdown") {
                std::string acc = args[0]->getAttr("acc").asString();
                ClientConnection* cc = m_server->getConnectionForAccount(acc);
                assert(cc);
                cc->shutdown();
            } else if (cid == "add-many-objects") {
                m_server->addManyObjects(args[0]->getAttr("acc").asString());
            } else if (cid == "set-world-time") {
                /* double t = */ args[0]->getAttr("seconds").asFloat();
                
            } else {
                std::cerr << "unknown command " << cid << std::endl;
            }
        } // of command action case
    } // of action case
}
开发者ID:worldforge,项目名称:eris,代码行数:101,代码来源:commander.cpp


注:本文中的RootEntity::setAttr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。