コード例 #1
0
void ComponentExitMapOnUse::load(const PropertyBag &data)
{
	resetMembers();
	nextMap = data.getFileName("nextMap");
	sfxOnFail = data.getFileName("sfxOnFailed");
	requiresCoins = data.getBool("requiresCoins");
}
コード例 #2
0
    void decomposeProperty(const Sample<T>& sample, PropertyBag& targetbag)
    {
        std::string tname = detail::DataSourceTypeInfo<T>::getType();
        targetbag.setType("Sample");
        //std::string str;

        assert( targetbag.empty() );

        bool result =true;
        //std::stringstream out;
        //out << i+1;
        //str = out.str();

        Property<PropertyBag>* el_bag = new Property<PropertyBag>("SampleValue", "Sample Value"); 
        Property<T> el("SampleValue" , "Sample value ",sample.ValueGet())  ;
        if(    el.getTypeInfo()->decomposeType(el.getDataSource(),el_bag->value()) )
        {
            //log(Debug)<<"Element type "<<el.getType()<<" is a bag"<<endlog();
            targetbag.add( el_bag ); // Put variables in the bag
        }
        else
        {
            //log(Debug)<<"Element type "<<el.getType()<<" is not a bag"<<endlog();
            //For Property
            targetbag.add( new Property<T>("SampleValue" ,"Sample Value",sample.ValueGet() )); // Put variables in the bag
        }
    };
コード例 #3
0
void ComponentPhysicsGeom::load(const PropertyBag &data)
{
	resetMembers();

	desiredHeight = data.getFloat("height");
	collisionRadius = data.getFloat("radius");

	// Create as physics geometry
	if(geom){dGeomDestroy(geom);} geom=0;
	createGeom(data.getString("physicsGeometryType"));

	// Set initial position
	{
		vec3 position;
		if(data.get("position", position)) // optional tag
		{
			setPosition(position);
		}
	}

	// Declare the initial state
	getParentBlackBoard().relayMessage(MessagePositionHasBeenSet(getPosition()));
	getParentBlackBoard().relayMessage(MessageOrientationHasBeenSet(getOrientation()));
	getParentBlackBoard().relayMessage(MessageRequestSetHeight(desiredHeight));
}
コード例 #4
0
ファイル: Monster.cpp プロジェクト: foxostro/arbarlith2
void Monster::load(const PropertyBag &xml)
{
	Creature::load(xml);

	if(xml.exists("preferredSpell")) {
		xml.get_optional("preferredSpell", preferredSpell);
	} else {
		preferredSpell = 0;
	}

	switch(preferredSpell)
	{
	case 0: spell = new SpellFireBall	(&getZone(), m_ID, "data/spells/fireball.xml");		break; // Fireball
	case 1: spell = new SpellFireBall	(&getZone(), m_ID, "data/spells/arctic-wind.xml");	break; // Arctic Wind
	case 2: spell = new SpellIncinerate	(&getZone(), m_ID, "data/spells/incinerate.xml");		break; // Incinerate
	case 3: spell = new SpellFireBall	(&getZone(), m_ID, "data/spells/chill.xml");		break; // Chill
	case 4: spell = new SpellHeal		(&getZone(), m_ID, "data/spells/heal.xml");			break; // Heal
	case 5: spell = new SpellFireBall	(&getZone(), m_ID, "data/spells/ice-blast.xml");		break; // Ice Blast
	case 6: spell = 0; break; // Reserved for "Resurrect" Spell
	default: spell = 0; break;
	};

	if(spell!=0)
	{
		spell->available = true;
	}
}
コード例 #5
0
ファイル: PowerupHeal.cpp プロジェクト: foxostro/arbarlith2
void PowerupHeal::load(const PropertyBag &xml)
{
	Powerup::load(xml);

	xml.get("healValue", healValue);
	xml.get("healTime", healTime);
}
コード例 #6
0
void ComponentRenderAsModel::load(const PropertyBag &data)
{
	resetMembers();
	const FileName modelFileName = data.getFileName("model");
	loadModel(modelFileName);
	data.get("independentModelOrientation", independentModelOrientation);
}
コード例 #7
0
void ComponentSpinAround::load(const PropertyBag &data)
{
	resetMembers();
	rotationSpeed = data.getFloat("rotationSpeed");
	bounceHeight = data.getFloat("bounceHeight");
	bounceSpeed = data.getFloat("bounceSpeed");
}
コード例 #8
0
    PropertyTest()
        : pf("pf","pfd", -1.0),pd("pd","pdd", +1.0),
          ps("ps","psd", "std::string"),
          pc("pc","pcd", 'c'),
          pc1("pc1","pcd1", 'a'),
          pc2("pc2","pcd1", 'b'),
          subbag1("s1", "s1d"),subbag2("s2", "s2d")
    {
        intref = 99;
        pi1 = new Property<int>("pi1","pi1d", 0 );
        pi2 = new Property<int>("pi2","pi2d", 0 );
        pi1ref =  dynamic_cast< Property<int>* >( pi1->clone() );
        pi2ref =  dynamic_cast< Property<int>* >( pi2->clone() );

        pc1ref = pc1;
        pc2ref = pc2;

        bag.add( pi1 );
        bag.add( pi2 );
        bag.add( &subbag1 );
        subbag1.set().add( &subbag2 );
        subbag1.set().add( &pf );
        subbag1.set().add( &pd );

        subbag2.set().add( &ps );
        subbag2.set().add( &pc );

    }
コード例 #9
0
ファイル: GateOpener.cpp プロジェクト: foxostro/arbarlith2
void GateOpener::load(const PropertyBag &xml)
{
	Listener::load(xml);

	xml.get("gateName", gateName);
	xml.get("open", open);
}
コード例 #10
0
void ComponentExplodeAfterTimeout::load(const PropertyBag &data) {
	resetMembers();
	
	timeleft = data.getFloat("timeout");
	baseDamage = data.getInt("baseDamage");
	soundFileName = data.getFileName("soundFileName");
	particlesFileName = data.getFileName("particlesFileName");
}
コード例 #11
0
    bool composeProperty(const PropertyBag& bag, WeightedSample<T>& weightedSample)
    {
        //log(Debug) << "composeProperty of WeightedSample " << endlog();
        std::string tname = detail::DataSourceTypeInfo<T>::getType();
        if ( bag.getType() == std::string("WeightedSample") ) {
            // Get values of sample
            Property<PropertyBag>* el_bag =  bag.getProperty<PropertyBag>("WeightedSampleValue");

            if(el_bag==NULL){
                // Works for properties in WeightedSample
                PropertyBase* element = bag.getItem( 0 );
                //log(Debug)<<element->getName()<<", "<< element->getDescription()<<endlog();
                Property<T> my_property_t (element->getName(),element->getDescription());
                if(my_property_t.getType()!=element->getType())
                {
                    log(Error)<< "Type of "<< element->getName() << " does not match type of WeightedSample"<< "OR "<<"Could not read WeightedSample Value "<<endlog();
                    return false;
                }
                else{
                    my_property_t.getTypeInfo()->composeType(element->getDataSource(),my_property_t.getDataSource());
                    weightedSample.ValueSet( my_property_t.get());
                }
            }
            else{
                // Works for propertybags in WeightedSample
                const std::string el_bagType = el_bag->getType();
                Property<T > el_p(el_bag->getName(),el_bag->getDescription());
                if(!(el_p.getDataSource()->composeType(el_bag->getDataSource()))){
                    log(Error)<<"Could not compose WeightedSampleValue "<<endlog();
                    return false;
                }
                if(el_p.ready()){
                    weightedSample.ValueSet( el_p.get());
                }else{
                    log(Error)<<"Property of WeightedSampleValue was not ready for use"<<endlog();
                    return false;
                }
            }
            // Get weight of sample
            Property<double>* weightProp =  bag.getProperty<double>("WeightedSampleWeight");

            if(!weightProp)
            {
                log(Error)<< "Error reading weight of WeightedSample"<<endlog();
                return false;
            }
            else{
                weightedSample.WeightSet( weightProp->get());
            }
        }
        else {
            Logger::log() << Logger::Error << "Composing Property< WeightedSample<T> > :"
                          << " type mismatch, got type '"<< bag.getType()
                          << "', expected type "<<tname<<"."<<Logger::endl;
            return false;
        }
        return true;
    };
コード例 #12
0
    bool ImageDisplayComponent::configureHook(){
        Logger::In in("ImageDisplayComponent");

        // Load config file
        if ( this->marshalling()->readProperties( this->getName() + ".cpf" ) == false)
            return false;

        log(Info) << "Loading Ports to display from file." <<endlog();
        PropertyDemarshaller dem( config.get() );
        PropertyBag bag;
        if (dem.deserialize( bag ) == false ) {
            log(Error) << "Reading file "<< config.get() << " failed."<<endlog();
            return false;
        }

        bool ok = true;
        PropertyBag::const_iterator it = bag.getProperties().begin();
        while ( it != bag.getProperties().end() ){
            Property<std::string>* compName = dynamic_cast<Property<std::string>* >( *it );
            if ( !compName )
                log(Error) << "Expected Property \""
                           << (*it)->getName() <<"\" to be of type string."<< endlog();
            else if ( compName->getName() == "ImagePort" ) {
                string cname = compName->value().substr(0, compName->value().find("."));
                string pname = compName->value().substr( compName->value().find(".")+1, string::npos);
                ok &= this->addDisplayPort(cname, pname);
            }
            else {
                log(Error) << "Expected \"Component\", \"Port\" or \"Data\", got "
                           << compName->getName() << endlog();
                ok = false;
            }
            ++it;
        }
        deleteProperties( bag );

        // Create window for every dataport
        for(Reports::iterator it = root.begin(); it != root.end(); ++it ) {
            // Update the dataport
            (it->get<2>())->execute();
            // Get the base dataport
            DataSourceBase::shared_ptr source = it->get<3>();
            // Convert to Dataport<IplImage>
            DataSource<IplImage>::shared_ptr clone = AdaptDataSource<IplImage>()( source.get() );
            IplImage localImage = clone->get();
            string dataportName = it->get<0>();
            cvNamedWindow(dataportName.data(),CV_WINDOW_AUTOSIZE);
            cvShowImage(dataportName.data(),&localImage);
        }

        // Enter main loop of the window, and update the window if needed
        int key;
        key = cvWaitKey(3);
        // Magic number 3


        return ok;
    }
コード例 #13
0
ファイル: Spawn.cpp プロジェクト: foxostro/arbarlith2
void Spawn::load(const PropertyBag &xml)
{
	Listener::load(xml);

	xml.get("monsterDataFile", monsterDataFile);
	xml.get("minMonsters", minMonsters);
	xml.get("maxMonsters", maxMonsters);
	xml.get("separationDistance", separationDistance);
}
コード例 #14
0
            virtual void serialize(const PropertyBag &v)
			{
                for (
                    PropertyBag::const_iterator i = v.getProperties().begin();
                    i != v.getProperties().end();
                    i++ )
                {
                    this->serialize( *i );
                }
			}
コード例 #15
0
void ComponentBrainShooter::load(const PropertyBag &data)
{
	resetMembers();

	data.get("fov", fov); // optional tag
	data.get("maxSightDistance", maxSightDistance); // optional tag
	data.get("shootDistance", shootDistance); // optional tag

	wanderAngle = FRAND_RANGE(0.0f, 2.0f * (float)M_PI);
}
コード例 #16
0
    // todo
bool operator==(const PropertyBag& a, const PropertyBag& b) {
    if( a.size() == b.size() ) {
        PropertyBag::const_iterator ita = a.begin();
        PropertyBag::const_iterator itb = b.begin();
        while ( ita != a.end() ) {
            //if ( (*ita)->equals(*itb) )
                return false;
        }
    }
    return false;
}
コード例 #17
0
ファイル: ParticleSystem.cpp プロジェクト: foxostro/heroman
void ParticleSystem::loadParticleEmitters(const PropertyBag &data)
{
	const size_t nEmitters = data.getNumInstances("emitter");
	ASSERT(nEmitters>0, "particle system does not specify any emitters");
	for(size_t i=0; i<nEmitters; ++i)
	{
		const PropertyBag emitterData = data.getBag("emitter", i);
		ParticleEmitter *emitter = new ParticleEmitter(emitterData, this);
		emitters.push_back(emitter);
	}
}
コード例 #18
0
ファイル: Trigger.cpp プロジェクト: foxostro/arbarlith2
void Trigger::load(const PropertyBag &xml)
{
	Actor::load(xml);

	loadList(xml, "sounds", sounds);

	if(xml.exists("triggerRadius")) {
		xml.get("triggerRadius", triggerRadius);
	} else {
		triggerRadius = getCylinderRadius(); // default
	}
}
コード例 #19
0
ファイル: StructTypeInfo.hpp プロジェクト: FynnGamadeyo/rtt
 /**
  * Implementation that updates result with the matching parts in source
  * Relies on the fact that getMember returns a C++ reference to each part of \a result, which is then updated
  * with a property found in source.
  */
 virtual bool composeTypeImpl(const PropertyBag& source,  typename internal::AssignableDataSource<T>::reference_t result) const {
     // The default implementation decomposes result and refreshes it with source.
     TypeInfoRepository::shared_ptr tir = Types();
     internal::ReferenceDataSource<T> rds(result);
     rds.ref(); // prevent dealloc.
     PropertyBag decomp;
     // only try refreshProperties if decomp's type is equal to source type.
     // update vs refresh: since it is intentional that the decomposition leads to references to parts of result,
     // only refreshProperties() is meaningful (ie we have a one-to-one mapping). In case of sequences, this would
     // of course not match, so this is struct specific.
     return typeDecomposition( &rds, decomp, false) && ( tir->type(decomp.getType()) == tir->type(source.getType()) ) && refreshProperties(decomp, source);
 }
コード例 #20
0
ファイル: ComponentGate.cpp プロジェクト: foxostro/heroman
void ComponentGate::load(const PropertyBag &data)
{
    resetMembers();

    state = ("a" == toLowerCase(data.getString("initialState")))
            ? STATE_A
            : STATE_B;

    positionA = data.getVec3("positionA");
    positionB = data.getVec3("positionB");
    timeToTransitionAB = data.getFloat("timeToTransitionAB");
    timeToTransitionBA = data.getFloat("timeToTransitionBA");
}
コード例 #21
0
            virtual void serialize(const PropertyBag &v)
			{
                *(this->s) << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
                *(this->s) << "<xmlrpc>\n";

                for (
                    std::vector<base::PropertyBase*>::const_iterator i = v.getProperties().begin();
                    i != v.getProperties().end();
                    i++ )
                {
                    (*i)->identify(this);
                }
                *(this->s) << "\n</xmlrpc>\n";
			}
コード例 #22
0
ファイル: ActorSet.cpp プロジェクト: foxostro/heroman
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);
	}
}
コード例 #23
0
ファイル: ParticleSystem.cpp プロジェクト: foxostro/heroman
void ParticleSystem::loadParticleTemplates(const PropertyBag &data)
{
	const size_t n = data.getNumInstances("template");
	for(size_t i=0; i<n; ++i)
	{
		const PropertyBag templateData = data.getBag("template", i);
		const string templateName = templateData.getString("name");
		const string materialName = templateData.getString("material");

		Material *material = getMaterialPtr(materialName);

		ParticleElement element(templateData, material);

		templatesByName.insert(make_pair(templateName, element));
	}
}
コード例 #24
0
ファイル: Light.cpp プロジェクト: foxostro/arbarlith2
PropertyBag Light::toXml(void)
{
	PropertyBag xml;

	xml.add("constantAttenuation", constantAttenuation);
	xml.add("linearAttenuation", linearAttenuation);
	xml.add("quadraticAttenuation", quadraticAttenuation);
	xml.add("lightPosition", lightPosition);;
	xml.add("pointLight", pointLight);
	xml.add("lightDirection", lightDirection);
	xml.add("spotAngle", spotAngle);
	xml.add("spotExponent", spotExponent);
	xml.add("enable", enable);
	
	return xml;
}
コード例 #25
0
            virtual void serialize(const Property<PropertyBag> &b)
			{
                //   cout << "double: " << v;
                *(this->s) <<"<struct><name>"<<b.getName()<<"</name>\n";
				PropertyBag v = b.get();
                for (
                    std::vector<base::PropertyBase*>::const_iterator i = v.getProperties().begin();
                    i != v.getProperties().end();
                    i++ )
                {
                	*(this->s) <<"<member>\n";
                    (*i)->identify(this);
	                *(this->s) <<"</member>";
                }
                *(this->s) <<"</struct>\n";

            }
コード例 #26
0
ファイル: ActorSet.cpp プロジェクト: foxostro/arbarlith2
PropertyBag ActorSet::save(void) const
{
	PropertyBag xml;

	for(const_iterator i = begin(); i != end(); ++i)
	{
		Actor &a = *(i->second);

		// Do not save Creatures.  We are saving spawns instead and the player data is separate
		if(!instanceof(a, Creature))
		{
			xml.add("object", a.save());
		}
	}

	return xml;
}
コード例 #27
0
ファイル: EditorToolBar.cpp プロジェクト: foxostro/arbarlith2
void EditorToolBar::createNewMap(void)
{
	ASSERT(world!=0, "world was null!  Call setWorld first!");

	ActorSet &objects = world->getObjects();
	Map &map = world->getMap();

	map.makeNewMap();

	// Delete all objects
	objects.destroy();

	// Add a player object
	PropertyBag newGame;
	newGame.loadFromFile("data/zone/World1.xml");
	world->reloadPlayers(newGame);
}
コード例 #28
0
void TriggerParticles::load(const PropertyBag &xml)
{
	Trigger::load(xml);

	xml.get("pfxFileName", pfxFileName);
	xml.get("pfxLocation", pfxLocation);

	showModel = false;
}
コード例 #29
0
ファイル: ActorSet.cpp プロジェクト: foxostro/arbarlith2
void ActorSet::load(const PropertyBag &xml, World *world)
{
	ASSERT(world!=0, "world was null");

	TRACE("Loading ActorSet...");

	for(size_t i=0, numObjects=xml.count("object"); i<numObjects; ++i)
	{
		PropertyBag ThisObjBag;
		xml.get("object", ThisObjBag, i);
		spawnNow(ThisObjBag, world);
	}

	// Player data is saved separately
	deleteActors<Player>();

	TRACE("...finished (Loading ActorSet)");
}
コード例 #30
0
ファイル: MatrixTypeInfo.hpp プロジェクト: FynnGamadeyo/rtt
 /**
  * Specialize to resize \a result given the size of \a source.
  */
 virtual bool composeTypeImpl(const PropertyBag& bag, typename internal::AssignableDataSource<T>::reference_t result) const
 {
     if ( bag.getType() == "Matrix" ) {
         unsigned int rows = bag.size();
         unsigned int cols = 0;
         // Get values
         for (unsigned int i = 1; i <= rows ; i++) {
             std::stringstream out;
             out << i;
             Property<PropertyBag>* row_bag =  bag.getProperty<PropertyBag>(out.str());
             if(row_bag==NULL){
                 log(Error)<<"Could not read row "<<i<<endlog();
                 return false;
             }
             Property<RowVector> row_p(row_bag->getName(),row_bag->getDescription());
             if(!(row_p.getDataSource()->composeType(row_bag->getDataSource()))){
                 log(Error)<<"Could not decompose row "<<i<<endlog();
                 return false;
             }
             if(row_p.ready()){
                 if(i==1){
                     cols = row_p.get().size();
                     result.resize(rows,cols);
                 } else
                     if(row_p.get().size()!=cols){
                         log(Error)<<"Row "<<i+1<<" size does not match matrix columns"<<endlog();
                         return false;
                     }
                 for ( unsigned int j=1; j <= row_p.get().size() ; j++){
                     result(i,j)=row_p.get()(j);
                 }
             }else{
                 log(Error)<<"Property of Row "<<i<<"was not ready for use"<<endlog();
                 return false;
             }
         }
     }else {
         log(Error) << "Composing Property< Matrix > :"
                    << " type mismatch, got type '"<< bag.getType()
                    << "', expected type "<<"Matrix."<<endlog();
         return false;
     }
     return true;
 }