PlacementTypeTankStart.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 <placement/PlacementTypeTankStart.h>
00022 #include <placement/PlacementTankPosition.h>
00023 #include <engine/ScorchedContext.h>
00024 #include <common/ProgressCounter.h>
00025 #include <common/RandomGenerator.h>
00026 #include <common/Defines.h>
00027 #include <XML/XMLParser.h>
00028 
00029 PlacementTypeTankStart::PlacementTypeTankStart() : mincloseness(0)
00030 {
00031 }
00032 
00033 PlacementTypeTankStart::~PlacementTypeTankStart()
00034 {
00035 }
00036 
00037 bool PlacementTypeTankStart::readXML(XMLNode *node)
00038 {
00039         if (!node->getNamedChild("numobjects", numobjects)) return false;
00040         if (!node->getNamedChild("team", team)) return false;
00041         node->getNamedChild("mincloseness", mincloseness, false);
00042         return PlacementType::readXML(node);
00043 }
00044 
00045 void PlacementTypeTankStart::getPositions(ScorchedContext &context,
00046         RandomGenerator &generator,
00047         std::list<Position> &returnPositions,
00048         ProgressCounter *counter)
00049 {
00050         for (int i=0; i<numobjects;)
00051         {
00052                 Position position;
00053                 position.position = 
00054                         PlacementTankPosition::placeTank(0, team, context, generator);
00055 
00056                 if (checkCloseness(position.position, context, 
00057                         returnPositions, mincloseness))
00058                 {
00059                         returnPositions.push_back(position);
00060                         i++;
00061                 }
00062         }
00063 }

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