00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <placement/PlacementGroupDefinition.h>
00022 #include <engine/ScorchedContext.h>
00023 #include <landscapemap/LandscapeMaps.h>
00024
00025 PlacementGroupDefinition::PlacementGroupDefinition()
00026 {
00027 }
00028
00029 PlacementGroupDefinition::~PlacementGroupDefinition()
00030 {
00031 }
00032
00033 bool PlacementGroupDefinition::readXML(XMLNode *node)
00034 {
00035 std::string groupname;
00036 while (node->getNamedChild("groupname", groupname, false))
00037 {
00038 groupnames_.push_back(groupname);
00039 }
00040 return true;
00041 }
00042
00043 void PlacementGroupDefinition::addToGroups(
00044 ScorchedContext &context,
00045 TargetGroup *objectEntry,
00046 bool thin)
00047 {
00048 for (unsigned int i=0; i<groupnames_.size(); i++)
00049 {
00050 std::string groupname = groupnames_[i];
00051 addToGroup(groupname.c_str(), context, objectEntry, thin);
00052 }
00053 }
00054
00055 void PlacementGroupDefinition::addToGroup(
00056 const char *groupName,
00057 ScorchedContext &context,
00058 TargetGroup *objectEntry,
00059 bool thin)
00060 {
00061 TargetGroupsGroupEntry *group =
00062 context.getLandscapeMaps().getGroundMaps().getGroups().getGroup(
00063 groupName,
00064 &context.getLandscapeMaps().getGroundMaps().getHeightMap());
00065 if (group)
00066 {
00067 group->addObject(objectEntry, thin);
00068 }
00069 }