git-svn-id: https://scorched3d.svn.sourceforge.net/svnroot/scorched3d/trunk/scorched...
[scorched3d/parasti.git] / src / common / placement / PlacementObjectTarget.cpp
blobfc781e6f376b73fea5c81ebc701e807bf09a2c65
1 ////////////////////////////////////////////////////////////////////////////////
2 // Scorched3D (c) 2000-2009
3 //
4 // This file is part of Scorched3D.
5 //
6 // Scorched3D is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // Scorched3D is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with Scorched3D; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ////////////////////////////////////////////////////////////////////////////////
21 #include <placement/PlacementObjectTarget.h>
22 #include <landscapemap/LandscapeMaps.h>
23 #include <engine/ScorchedContext.h>
24 #include <weapons/AccessoryStore.h>
25 #include <common/Defines.h>
26 #include <target/TargetContainer.h>
27 #include <target/TargetLife.h>
28 #include <target/Target.h>
29 #include <XML/XMLParser.h>
31 PlacementObjectTarget::PlacementObjectTarget()
35 PlacementObjectTarget::~PlacementObjectTarget()
39 bool PlacementObjectTarget::readXML(XMLNode *node)
41 if (!targetDef_.readXML(node, ".")) return false;
42 if (!groups_.readXML(node)) return false;
43 return PlacementObject::readXML(node);
46 void PlacementObjectTarget::createObject(ScorchedContext &context,
47 RandomGenerator &generator,
48 unsigned int &playerId,
49 PlacementType::Position &position)
51 ++playerId;
52 Target *target = targetDef_.createTarget(
53 playerId, position.position, position.velocity, context, generator);
54 context.getTargetContainer().addTarget(target);
56 context.getLandscapeMaps().getGroundMaps().getGroups().getShadows().push_back(
57 PlacementShadowDefinition::Entry(
58 &targetDef_.getShadow(),
59 position.position,
60 target->getLife().getSize()));