NapalmParams.cpp

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2009
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 ////////////////////////////////////////////////////////////////////////////////
00020 
00021 #include <actions/NapalmParams.h>
00022 #include <lua/LUAUtil.h>
00023 #include <XML/XMLNode.h>
00024 
00025 NapalmParams::NapalmParams() : 
00026         napalmTime_(8),
00027         napalmHeight_(2),
00028         stepTime_(fixed(true, 1000)),
00029         hurtStepTime_(2),
00030         hurtPerSecond_(1),
00031         groundScorchPer_(fixed(true, 2000)),
00032         effectRadius_(5),
00033         noSmoke_(false),
00034         noObjectDamage_(false),
00035         allowUnderWater_(false),
00036         luminance_(true),
00037         singleFlow_(true),
00038         napalmTexture_("flames"),
00039         deformTexture_(""),
00040         numberParticles_(100)
00041 {
00042 }
00043 
00044 NapalmParams::~NapalmParams()
00045 {
00046 }
00047 
00048 bool NapalmParams::parseXML(XMLNode *accessoryNode)
00049 {
00050         // Mandatory Attributes
00051         if (!accessoryNode->getNamedChild("effectradius", effectRadius_)) return false;
00052         if (!accessoryNode->getNamedChild("napalmtexture", napalmTexture_)) return false;
00053         if (!accessoryNode->getNamedChild("allowunderwater", allowUnderWater_)) return false;
00054 
00055         accessoryNode->getNamedChild("numberparticles", numberParticles_, false);
00056 
00057         // Get the optional luminance node
00058         XMLNode *noLuminanceNode = 0; luminance_ = true;
00059         accessoryNode->getNamedChild("noluminance", noLuminanceNode, false);
00060         if (noLuminanceNode) luminance_ = false;
00061 
00062         XMLNode *noSingleFlowNode = 0; singleFlow_ = true;
00063         accessoryNode->getNamedChild("nosingleflow", noSingleFlowNode, false);
00064         if (noSingleFlowNode) singleFlow_ = false;
00065 
00066         // Optional deform texture
00067         if (accessoryNode->getNamedChild("deformtexture", deformTexture_, false))
00068         {
00069                 if (!S3D::checkDataFile(getDeformTexture())) return false;
00070         }
00071 
00072         // Optional Attributes
00073         XMLNode *noSmokeNode = 0, *noObjectDamageNode = 0;
00074         accessoryNode->getNamedChild("groundscorchper", groundScorchPer_, false);
00075         accessoryNode->getNamedChild("nosmoke", noSmokeNode, false);
00076         accessoryNode->getNamedChild("noobjectdamage", noObjectDamageNode, false);
00077         if (noSmokeNode) noSmoke_ = true;
00078         if (noObjectDamageNode) noObjectDamage_ = true;
00079 
00080         return true;
00081 }
00082 
00083 void NapalmParams::parseLUA(lua_State *L, int position)
00084 {
00085         luaL_checktype(L, position, LUA_TTABLE);
00086 
00087         napalmTime_ = LUAUtil::getNumberFromTable(L, position, "napalmtime", napalmTime_);
00088         napalmHeight_ = LUAUtil::getNumberFromTable(L, position, "napalmheight", napalmHeight_);
00089         stepTime_ = LUAUtil::getNumberFromTable(L, position, "steptime", stepTime_);
00090         hurtStepTime_ = LUAUtil::getNumberFromTable(L, position, "hurtsteptime", hurtStepTime_);
00091         hurtPerSecond_ = LUAUtil::getNumberFromTable(L, position, "hurtpersecond", hurtPerSecond_);
00092         groundScorchPer_ = LUAUtil::getNumberFromTable(L, position, "groundscorchper", groundScorchPer_);
00093         effectRadius_ = LUAUtil::getIntFromTable(L, position, "effectradius", effectRadius_);
00094         numberParticles_ = LUAUtil::getIntFromTable(L, position, "numberparticles", numberParticles_);
00095         noSmoke_ = LUAUtil::getBoolFromTable(L, position, "nosmoke", noSmoke_);
00096         noObjectDamage_ = LUAUtil::getBoolFromTable(L, position, "noobjectdamage", noObjectDamage_);
00097         allowUnderWater_ = LUAUtil::getBoolFromTable(L, position, "allowunderwater", allowUnderWater_);
00098         luminance_ = LUAUtil::getBoolFromTable(L, position, "luminance", luminance_);
00099         singleFlow_ = LUAUtil::getBoolFromTable(L, position, "singleflow", singleFlow_);
00100         napalmTexture_ = LUAUtil::getStringFromTable(L, position, "napalmtexture", napalmTexture_);
00101         deformTexture_ = LUAUtil::getStringFromTable(L, position, "deformtexture", deformTexture_);
00102 }

Generated on Mon Feb 16 15:14:48 2009 for Scorched3D by  doxygen 1.5.3