Exemple #1
0
void ConnectedAdapter::actuate(Eris::Entity* entity, const std::string& action)
{
	try {

		Atlas::Objects::Entity::Anonymous what;
		what->setId(entity->getId());
		// 	what->setObjtype("obj");

		Atlas::Objects::Operation::RootOperation actionOp;
		actionOp->setObjtype("op");
		actionOp->setArgs1(what);
		std::list<std::string> actionParents;
		actionParents.push_back(action);
		actionOp->setParents(actionParents);

		Atlas::Objects::Operation::RootOperation actuateOp;
		actuateOp->setObjtype("op");
		actuateOp->setArgs1(actionOp);
		std::list<std::string> actuateParents;
		actuateParents.push_back("actuate");
		actuateOp->setParents(actuateParents);
		actuateOp->setFrom(mAvatar.getEntity()->getId());

		S_LOG_INFO("Actuating entity with id " << entity->getId() << ", named " << entity->getName() << " with action '" << action << "'.");
		mConnection.send(actuateOp);
	} catch (const std::exception& ex) {
		S_LOG_WARNING("Got error on actuating." << ex);
	}
}
Exemple #2
0
void ConnectedAdapter::setAttributes(Eris::Entity* entity, Atlas::Message::MapType& elements)
{
	try {
		Atlas::Objects::Entity::Anonymous what;
		what->setId(entity->getId());
		//We'll use this flag to make sure that nothing gets sent in the case that the only thing changed was immutable attributes (like "pos").
		bool areAttributesToSend = false;
		for (Atlas::Message::MapType::iterator I = elements.begin(); I != elements.end(); ++I) {
			//The "pos" attribute is immutable and cannot be altered by a "set" op. Instead we must use a "move" op.
			if (I->first == "pos") {
				place(entity, entity->getLocation(), WFMath::Point<3>(I->second));
			} else {
				what->setAttr(I->first, I->second);
				areAttributesToSend = true;
			}
		}

		if (areAttributesToSend) {
			Atlas::Objects::Operation::Set setOp;
			setOp->setFrom(mAvatar.getEntity()->getId());
			//setOp->setTo(entity->getId());
			setOp->setArgs1(what);

			S_LOG_INFO("Setting attributes of entity with id " << entity->getId() << ", named " << entity->getName());
			mConnection.send(setOp);
		}
	} catch (const std::exception& ex) {
		S_LOG_WARNING("Got error on setting attributes on entity." << ex);
	}
}
Exemple #3
0
void ConnectedAdapter::wield(Eris::Entity* entity, const std::string& outfitSlot)
{

	try {

		if (entity->getLocation() != mAvatar.getEntity()) {
			S_LOG_WARNING("Can't wield an Entity which is not located in the avatar.");

			return;
		}

		Atlas::Objects::Entity::Anonymous arguments;
		arguments->setId(entity->getId());
		if (outfitSlot != "") {
			arguments->setAttr("outfit", outfitSlot);
		}
		Atlas::Objects::Operation::Wield wield;
		wield->setFrom(mAvatar.getEntity()->getId());
		wield->setArgs1(arguments);

		mConnection.send(wield);

	} catch (const std::exception& ex) {
		S_LOG_WARNING("Got error on wielding." << ex);
	}
}
Root atlasClass(const std::string & name, const std::string & parent)
{
    Atlas::Objects::Entity::Anonymous r;
    r->setParents(std::list<std::string>(1, parent));
    r->setObjtype("class");
    r->setId(name);
    return r;
}
Exemple #5
0
Root atlasOpDefinition(const std::string & name, const std::string & parent)
{
    Atlas::Objects::Entity::Anonymous r;

    r->setParents(std::list<std::string>(1, parent));
    r->setObjtype("op_definition");
    r->setId(name);

    return r;
}
Exemple #6
0
Root atlasType(const std::string & name,
               const std::string & parent,
               bool abstract)
{
    Atlas::Objects::Entity::Anonymous r;

    r->setParents(std::list<std::string>(1, parent));
    r->setObjtype(abstract ? "data_type" : "type");
    r->setId(name);

    return r;
}
Exemple #7
0
void BaseMindtest::test_unseenOperation()
{
    OpVector res;
    Atlas::Objects::Operation::Unseen op;
    bm->operation(op, res);

    Atlas::Objects::Entity::Anonymous arg;
    op->setArgs1(arg);
    bm->operation(op, res);

    arg->setId("2");
    bm->operation(op, res);
}
Exemple #8
0
void BaseMindtest::test_disappearanceOperation()
{
    OpVector res;
    Atlas::Objects::Operation::Disappearance op;
    bm->operation(op, res);

    Atlas::Objects::Entity::Anonymous arg;
    op->setArgs1(arg);
    bm->operation(op, res);

    arg->setId("2");
    bm->operation(op, res);
}
Exemple #9
0
void ConnectedAdapter::eat(Eris::Entity* entity)
{
	try {
		Atlas::Objects::Entity::Anonymous what;
		what->setId(entity->getId());

		Atlas::Objects::Operation::Generic op;
		op->setType("eat", -1);
		op->setFrom(mAvatar.getEntity()->getId());
		op->setArgs1(what);

		S_LOG_INFO("Eating entity with id " << entity->getId() << ", named " << entity->getName());
		mConnection.send(op);
	} catch (const std::exception& ex) {
		S_LOG_WARNING("Got error on eating entity." << ex);
	}
}
Exemple #10
0
void ConnectedAdapter::deleteEntity(Eris::Entity* entity)
{
	try {
		Atlas::Objects::Entity::Anonymous what;
		what->setId(entity->getId());

		Atlas::Objects::Operation::Delete deleteOp;
		deleteOp->setFrom(mAvatar.getEntity()->getId());
		deleteOp->setTo(entity->getId());
		deleteOp->setArgs1(what);

		S_LOG_INFO("Deleting entity with id " << entity->getId() << ", named " << entity->getName());
		mConnection.send(deleteOp);
	} catch (const std::exception& ex) {
		S_LOG_WARNING("Got error on deleting entity." << ex);
	}
}
Exemple #11
0
void BaseMindtest::test_sightSetOperation()
{
    Atlas::Objects::Operation::Set sub_op;
    Atlas::Objects::Operation::Sight op;
    op->setArgs1(sub_op);
    OpVector res;
    bm->operation(op, res);

    sub_op->setArgs1(Atlas::Objects::Entity::Anonymous());
    bm->operation(op, res);

    sub_op->setArgs1(Atlas::Objects::Entity::Anonymous(0));
    bm->operation(op, res);

    Atlas::Objects::Entity::Anonymous arg;
    arg->setId("2");
    sub_op->setArgs1(arg);
    bm->operation(op, res);
}