void ComponentExitMapOnUse::load(const PropertyBag &data) { resetMembers(); nextMap = data.getFileName("nextMap"); sfxOnFail = data.getFileName("sfxOnFailed"); requiresCoins = data.getBool("requiresCoins"); }
void ComponentExplodeAfterTimeout::load(const PropertyBag &data) { resetMembers(); timeleft = data.getFloat("timeout"); baseDamage = data.getInt("baseDamage"); soundFileName = data.getFileName("soundFileName"); particlesFileName = data.getFileName("particlesFileName"); }
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 ComponentRenderAsModel::load(const PropertyBag &data) { resetMembers(); const FileName modelFileName = data.getFileName("model"); loadModel(modelFileName); data.get("independentModelOrientation", independentModelOrientation); }
void ComponentAttachParticleSystem::load(const PropertyBag &data) { ASSERT(world, "World has not yet been set"); const vec3 position = vec3(0,0,0); const float rotation = 0.0f; const FileName fileName = data.getFileName("fileName"); handle = world->particleEngine->add(fileName, position, rotation, world->getTextureFactory()); }
void Font::setup(const PropertyBag &data) { fontSize.clear(); fontSize[Font::SizeHuge] = data.getFloat("huge"); fontSize[Font::SizeLarge] = data.getFloat("large"); fontSize[Font::SizeNormal] = data.getFloat("normal"); fontSize[Font::SizeSmall] = data.getFloat("small"); spacing = data.getFloat("spacing"); lineHeight = data.getFloat("lineHeight"); loadFontImage(data.getFileName("image")); }
AnimationController* ModelLoaderSingle::loadFromFile(const FileName &fileName, TextureFactory &textureFactory) const { PropertyBag xml = PropertyBag::fromFile(fileName); const FileName directory = fileName.getPath(); // Winding of polygons, either "CCW" or "CW" string polygonWinding = "CW"; xml.get("polygonWinding", polygonWinding); // Allocate a blank animation controller AnimationController *controller = new AnimationController(); // Get key frames from the first source PropertyBag fileBag = xml.getBag("model", 0); const FileName file = directory.append(fileBag.getFileName("file")); FileName skinName; if(fileBag.get("skin", skinName)) { skinName = directory.append(skinName); } vector<KeyFrame> keyFrames = loadKeyFrames(file, skinName, textureFactory); // Get the rest of the key frames for(size_t i = 1, numMD3 = xml.getNumInstances("model"); i<numMD3; ++i) { PropertyBag fileBag = xml.getBag("model", i); const FileName file = directory.append(fileBag.getFileName("file")); FileName skinName; if(fileBag.get("skin", skinName)) { skinName = directory.append(skinName); } vector<KeyFrame> k = loadKeyFrames(file, skinName, textureFactory); for(size_t i=0; i<k.size(); ++i) { KeyFrame &keyFrame = keyFrames[i]; keyFrame.merge(k[i]); // set polygon windings according to data file setPolygonWinding(keyFrame, polygonWinding); } } // Build the animations from these keyframes for(size_t i = 0, numAnimations = xml.getNumInstances("animation"); i<numAnimations; ++i) { PropertyBag animation; string name; bool looping=false; int start=0; float priority=0; int length=0; float fps=0; xml.get("animation", animation, i); animation.get("name", name); animation.get("priority", priority); animation.get("looping", looping); animation.get("start", start); animation.get("length", length); animation.get("fps", fps); // Add it to the controller AnimationSequence animationSequence(keyFrames, name, priority, looping, start, length, fps); controller->addAnimation(animationSequence); } return controller; }