Store turret positions in map files.

Follow up on 8bfb449375. Allows saving turret positions in the map file,
instead of relying on the order in which the entities are added.

Differential Revision: D2614
Reviewed by: @wraitii
Comments by: @Angen, @bb, @vladislavbelov.
This was SVN commit r24161.
This commit is contained in:
Freagarach
2020-11-11 19:40:44 +00:00
parent 9669b5f1a9
commit b5df81af76
9 changed files with 244 additions and 3 deletions
+17 -1
View File
@@ -44,6 +44,7 @@
#include "simulation2/components/ICmpOwnership.h"
#include "simulation2/components/ICmpPosition.h"
#include "simulation2/components/ICmpTemplateManager.h"
#include "simulation2/components/ICmpTurretHolder.h"
#include "simulation2/components/ICmpVisual.h"
#include "simulation2/components/ICmpWaterManager.h"
@@ -353,7 +354,22 @@ void CMapWriter::WriteXML(const VfsPath& filename,
{
XMLWriter_Element garrisonedEntityTag(xmlMapFile, "GarrisonedEntity");
garrisonedEntityTag.Attribute("uid", static_cast<int>(garr_ent_id));
// ToDo: We can store turret position as well.
}
}
}
CmpPtr<ICmpTurretHolder> cmpTurretHolder(sim, ent);
if (cmpTurretHolder)
{
std::vector<std::pair<std::string, entity_id_t> > turrets = cmpTurretHolder->GetTurrets();
if (!turrets.empty())
{
XMLWriter_Element turretTag(xmlMapFile, "Turrets");
for (const std::pair<std::string, entity_id_t>& turret : turrets)
{
XMLWriter_Element turretedEntityTag(xmlMapFile, "Turret");
turretedEntityTag.Attribute("turret", turret.first);
turretedEntityTag.Attribute("uid", static_cast<int>(turret.second));
}
}
}