public void VMMCollapse(string output)
{
Console.WriteLine("collapsing VMM");
// find the topLevel vmf
List <Dictionary <string, string> > topLevels = vmfs.FindAll(dic => dic.Keys.Contains("TopLevel"));
if (topLevels.Count == 0)
{
TopLevelVmf = vmfs.First();
}
else
{
TopLevelVmf = topLevels.Aggregate((curMin, x) => (curMin == null || int.Parse(x["TopLevel"]) < int.Parse(curMin["topLevel"]) ? x : curMin));
}
vmfs.Remove(TopLevelVmf);
//start file
VMFFile topmap = new VMFFile(vmfdir + "/" + TopLevelVmf["File"]);
VMFVector3Value originVal = new VMFVector3Value {
X = 0, Y = 0, Z = 0
};
VMFVector3Value anglesVal = new VMFVector3Value {
Pitch = 0, Roll = 0, Yaw = 0
};
VMFNumberValue fixup_styleVal = new VMFNumberValue {
Value = 0
};
foreach (Dictionary <string, string> vmf in vmfs)
{
Console.WriteLine("Inserting submap of {0}", vmfdir + "/" + vmf["File"]);
VMFFile submap = new VMFFile(vmfdir + "/" + vmf["File"]);
foreach (VMFStructure worldStruct in submap.World)
{
if (worldStruct.Type == VMFStructureType.Group || worldStruct.Type == VMFStructureType.Solid)
{
VMFStructure clone = worldStruct.Clone(topmap.LastID, topmap.LastNodeID);
clone.Transform(originVal, anglesVal);
topmap.World.Structures.Add(clone);
}
}
foreach (VMFStructure rootStruct in submap.Root)
{
if (rootStruct.Type == VMFStructureType.Entity)
{
VMFStructure clone = rootStruct.Clone(topmap.LastID, topmap.LastNodeID);
clone.Transform(originVal, anglesVal);
topmap.Root.Structures.Add(clone);
}
}
topmap.updateIds();
}
topmap.ResolveInstances();
topmap.Save(vmfdir + ".vmf");
}