void ActorSet::load(const PropertyBag &objects, World *_world) { ASSERT(_world!=0, "world was null"); world = _world; for(size_t i=0, n=objects.getNumInstances("object"); i<n; ++i) { const tuple<OBJECT_ID, ActorPtr> t = create(); const ActorPtr object = t.get<1>(); const PropertyBag decl = objects.getBag("object", i); const FileName templateFile = decl.getFileName("template"); const vec3 initialPosition = decl.getVec3("position"); const PropertyBag templateData = PropertyBag::fromFile(templateFile); const PropertyBag base = templateData.getBag("components"); ComponentDataSet s = ComponentDataSet::load(base, decl); // get actor name object->actorName = "(no name)"; templateData.get("name", object->actorName); object->load(s, initialPosition, vec3(0,0,0), world); object->setParentBlackBoard(this); } }
void ActorSet::_spawn(const SpawnRequest &spawnData) { const ComponentDataSet &data = spawnData.get<0>(); const vec3 &position = spawnData.get<1>(); const vec3 &velocity = spawnData.get<2>(); const tuple<OBJECT_ID, ActorPtr> t = create(); const ActorPtr object = t.get<1>(); object->load(data, position, velocity, world); object->enableDebugRendering(displayDebugRendering); }