/**\brief Initializes a new Engine with the given parameters. * \param _name Name of the Engine * \param _thrustsound Pointer to a Sound object that will be played for thrust * \param _forceOutput The amount of force the Engine generates * \param _msrp Price of the Engine * \param foldDrive Fold capable * \param _flareAnimation Thrust animation */ Engine::Engine( string _name, Sound* _thrustsound, float _forceOutput, short int _msrp, bool _foldDrive, string _flareAnimation, Image* _pic) : thrustsound(_thrustsound), foldDrive(_foldDrive), flareAnimation(_flareAnimation) { SetName(_name); SetMSRP(_msrp); SetPicture(_pic); SetForceOutput(_forceOutput); }
/**\brief Parser to parse the XML file */ bool Engine::FromXMLNode( xmlDocPtr doc, xmlNodePtr node ) { xmlNodePtr attr; string value; if( (attr = FirstChildNamed(node,"forceOutput")) ){ value = NodeToString(doc,attr); SetForceOutput( static_cast<float> (atof( value.c_str() ))); } else return false; if( (attr = FirstChildNamed(node,"msrp")) ){ value = NodeToString(doc,attr); SetMSRP( (short int)atoi( value.c_str() )); } else return false; if( (attr = FirstChildNamed(node,"foldDrive")) ){ value = NodeToString(doc,attr); foldDrive = (atoi( value.c_str() ) != 0); } else return false; if( (attr = FirstChildNamed(node,"flareAnimation")) ){ flareAnimation = NodeToString(doc,attr); } else return false; if( (attr = FirstChildNamed(node,"thrustSound")) ){ thrustsound = Sound::Get( NodeToString(doc,attr) ); } else return false; if( (attr = FirstChildNamed(node,"picName")) ){ Image* pic = Image::Get( NodeToString(doc,attr) ); // This image can be accessed by either the path or the Engine Name Image::Store(name, pic); SetPicture(pic); } else return false; return true; }
/**\brief Parses weapon information */ bool Outfit::FromXMLNode( xmlDocPtr doc, xmlNodePtr node ) { xmlNodePtr attr; string value; if( (attr = FirstChildNamed(node,"msrp")) ){ value = NodeToString(doc,attr); SetMSRP( atoi( value.c_str() )); } else return false; if( (attr = FirstChildNamed(node,"picName")) ){ Image* pic = Image::Get( NodeToString(doc,attr) ); // This image can be accessed by either the path or the Engine Name Image::Store(name, pic); SetPicture(pic); } else return false; if( (attr = FirstChildNamed(node,"rotationsPerSecond")) ){ value = NodeToString(doc,attr); SetRotationsPerSecond( static_cast<float>(atof( value.c_str() ))); } if( (attr = FirstChildNamed(node,"maxSpeed")) ){ value = NodeToString(doc,attr); SetMaxSpeed( static_cast<float>(atof( value.c_str() ))); } if( (attr = FirstChildNamed(node,"forceOutput")) ){ value = NodeToString(doc,attr); SetForceOutput( static_cast<float> (atof( value.c_str() ))); } if( (attr = FirstChildNamed(node,"mass")) ){ value = NodeToString(doc,attr); SetMass( static_cast<float> (atof( value.c_str() ))); } if( (attr = FirstChildNamed(node,"cargoSpace")) ){ value = NodeToString(doc,attr); SetCargoSpace( atoi( value.c_str() )); } if( (attr = FirstChildNamed(node,"surfaceArea")) ){ value = NodeToString(doc,attr); SetSurfaceArea( atoi( value.c_str() )); } if( (attr = FirstChildNamed(node,"cargoSpace")) ){ value = NodeToString(doc,attr); SetCargoSpace( atoi( value.c_str() )); } if( (attr = FirstChildNamed(node,"hullStrength")) ){ value = NodeToString(doc,attr); SetHullStrength( atoi( value.c_str() )); } if( (attr = FirstChildNamed(node,"shildStrength")) ){ value = NodeToString(doc,attr); SetShieldStrength( (short)atoi( value.c_str() )); } return true; }