#include "timer.h" #include #include #include using Atlas::Message::Element; using Atlas::Message::ListType; using Atlas::Message::MapType; class NPC { public: NPC() : id("123") {x=y=z = vx=vy=vz = 0.0;} Element move(const Element &op); std::string getId() {return id;} private: std::string id; double x,y,z; double vx,vy,vz; }; Element NPC::move(const Element &op) { ListType::iterator new_vel_i = ((Element&)op).asMap()["args"].asList(). front().asMap()["velocity"].asList().begin(); vx = (*new_vel_i).asFloat(); new_vel_i++; vy = (*new_vel_i).asFloat(); new_vel_i++; vz = (*new_vel_i).asFloat(); x += vx; y += vy; z += vz; //human: MapType human; human["id"] = getId(); ListType pos; pos.push_back(x); pos.push_back(y); pos.push_back(z); human["pos"] = pos; ListType vel; vel.push_back(vx); vel.push_back(vy); vel.push_back(vz); human["velocity"] = vel; //move: MapType move; move["objtype"] = Element("op"); ListType move_parents(1, Element("move")); move["parents"] = move_parents; ListType move_args(1, human); move["args"] = move_args; //sight: MapType sight; sight["objtype"] = Element("op"); ListType sight_parents(1, Element("sight")); sight["parents"] = sight_parents; sight["from"] = getId(); ListType sight_args(1, move); sight["args"] = sight_args; return sight; } int main(int argc, char** argv) { double i; Element bar(42); std::cout<