本文整理汇总了C++中Create::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ Create::isValid方法的具体用法?C++ Create::isValid怎么用?C++ Create::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Create
的用法示例。
在下文中一共展示了Create::isValid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dispatch
void Commander::dispatch(const RootOperation& op)
{
Appearance appear = smart_dynamic_cast<Appearance>(op);
if (appear.isValid()) {
assert(op->hasAttr("for"));
Agent* ag = m_server->findAgentForEntity(op->getAttr("for").asString());
if (ag) {
ag->setEntityVisible(op->getTo(), true);
} else {
// doesn't exist yet, mark as visible if / when the agent is created
Agent::setEntityVisibleForFutureAgent(op->getTo(), op->getAttr("for").asString());
}
}
Disappearance disap = smart_dynamic_cast<Disappearance>(op);
if (disap.isValid()) {
assert(op->hasAttr("for"));
Agent* ag = m_server->findAgentForEntity(op->getAttr("for").asString());
if (ag) ag->setEntityVisible(op->getTo(), false);
}
Create cr = smart_dynamic_cast<Create>(op);
if (cr.isValid()) {
std::vector<Root> args(op->getArgs());
assert(!args.empty());
RootEntity ent = smart_dynamic_cast<RootEntity>(args.front());
assert(ent.isValid());
static int idCounter = 900;
char buf[32];
snprintf(buf, 32, "_created_%d", ++idCounter);
std::string id(buf);
ent->setId(id);
std::string loc = ent->getLoc();
assert(m_server->m_world.count(loc));
StringList children(m_server->m_world[loc]->getContains());
children.push_back(id);
m_server->m_world[loc]->setContains(children);
m_server->m_world[id] = ent;
Create bcr(cr);
bcr->setArgs1(ent);
Agent::broadcastSight(bcr);
}
Delete del = smart_dynamic_cast<Delete>(op);
if (del.isValid()) {
std::vector<Root> args(op->getArgs());
assert(!args.empty());
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")) {
//.........这里部分代码省略.........