public SCOC_Entity(XElement elEntity) { Entity = elEntity; if (Entity.Element("Properties") != null) { Properties = Entity.Element("Properties"); } if (elEntity.Attribute("Name") != null) { Name = elEntity.Attribute("Name").Value; } if (elEntity.Attribute("Material") != null) { Material = elEntity.Attribute("Material").Value; } if (elEntity.Attribute("Pos") != null) { Pos = elEntity.Attribute("Pos").Value; } if (elEntity.Attribute("Rotate") != null) { Rotate = elEntity.Attribute("Rotate").Value; } if (elEntity.Attribute("Scale") != null) { Scale = elEntity.Attribute("Scale").Value; } if (elEntity.Attribute("EntityClass") != null) { EntityClass = elEntity.Attribute("EntityClass").Value; } if (elEntity.Attribute("EntityId") != null) { EntityId = elEntity.Attribute("EntityId").Value; } if (elEntity.Attribute("EntityGuid") != null) { EntityGuid = elEntity.Attribute("EntityGuid").Value; } if (elEntity.Attribute("EntityCryGUID") != null) { EntityCryGUID = elEntity.Attribute("EntityCryGUID").Value; } if (elEntity.Attribute("CastShadowMinSpec") != null) { CastShadowMinSpec = elEntity.Attribute("CastShadowMinSpec").Value; } if (elEntity.Attribute("Layer") != null) { Layer = elEntity.Attribute("Layer").Value; } LayerGUID = GuidUtility.GenLayerID(Layer); if (elEntity.Element("PropertiesDataCore") != null) { propertiesDataCore = new PropertiesDataCore(elEntity.Element("PropertiesDataCore")); } }
XElement AddObjectsFromObjectContainers(XElement el, ObjectContainer objCon, string parentid, string layerid) { XElement elObject = el; layerid = GuidUtility.GenLayerID("Main"); string layerName = "Main"; List <ObjectContainer> objContainers = new List <ObjectContainer>(); objContainers.Add(objCon); foreach (Child child in objCon.childs) { if (!child.IsExternal()) { objContainers.Add(child.Soc); } } foreach (ObjectContainer oc in objContainers) { string portName = oc.portName; foreach (PrefabObject po in oc.prefabObjects) { if (po.Geometry != null) { layerid = GuidUtility.GenLayerID("Main"); layerName = "Main"; //string layerName = oc.name; //string entid = GuidUtility.GenID("ent" + parentid +oc.name+po.Name+ po.Geometry); //string compGuid = GuidUtility.GenID("entcomp" + parentid + oc.name + po.Name + po.Geometry); string entid = GuidUtility.GenID(); string componentGuid = GuidUtility.GenID(); //string prefid = GuidUtility.GenID("entpref" + parentid + oc.name + po.Name+ po.Geometry); XElement obj1 = po.GetAsEntityWithComponent(parentid, layerid, entid, componentGuid, portName, layerName, lodRatio); elObject.Add(obj1); foreach (PrefabObject childPo in po.attachments) { string childentid = GuidUtility.GenID(); string childcomponentGuid = GuidUtility.GenID(); XElement childObj = childPo.GetAsEntityWithComponent(entid, layerid, childentid, childcomponentGuid, childPo.AttachmentTarget, layerName, lodRatio); elObject.Add(childObj); } } if (po.EntityClass == "AnimObject") { layerid = GuidUtility.GenLayerID("Main"); layerName = "Main"; string entid = GuidUtility.GenID(); string componentGuid = GuidUtility.GenID(); XElement obj1 = po.GetAsAnimObject(parentid, layerid, entid, componentGuid, portName, layerName, lodRatio); elObject.Add(obj1); } if (po.EntityClass == "LightGroup") { layerid = GuidUtility.GenLayerID("Main"); layerName = "Main"; XElement obj1 = po.GetAsFlowgraphEntity(parentid, layerid, layerName, oc.portName); elObject.Add(obj1); int i = 0; //lights and probes (enveroinmentlight) foreach (Light lt in po.lights) { if (lt.EntityClass == "Light") { obj1 = po.GetAsLight(i, layerid, layerName); elObject.Add(obj1); } if (lt.EntityClass == "EnvironmentLight") { obj1 = po.GetAsEnvironmentLight(i, layerid, layerName); elObject.Add(obj1); } i++; } } //if (po.Type == "VisArea") //{ // layerid = GuidUtility.GenLayerID("Main"); // layerName = "Main"; // string entid = GuidUtility.GenID(); // XElement obj1 = po.GetAsVisArea(entid, layerid, layerName); // Object.Add(obj1); //} //if (po.Type == "Portal") //{ // layerid = GuidUtility.GenLayerID("Main"); // layerName = "Main"; // string entid = GuidUtility.GenID(); // XElement obj1 = po.GetAsPortal(entid, layerid, layerName); // Object.Add(obj1); //} if (po.Type == "EnvironmentLight") { layerid = GuidUtility.GenLayerID("Main"); layerName = "Main"; XElement obj1 = po.GetAsFlowgraphEntity(parentid, layerid, layerName, oc.portName); elObject.Add(obj1); layerid = GuidUtility.GenLayerID("Main"); layerName = "Main"; string entid = GuidUtility.GenID(); obj1 = po.GetAsEnvironmentLight2(entid, layerid, layerName); elObject.Add(obj1); } if (po.EntityClass == "Light") { string layername = oc.name; XElement obj1 = new XElement("Object"); string entid = GuidUtility.GenID(); string prefid = GuidUtility.GenID(); obj1.Add(new XAttribute("Name", po.Name)); if (parentid != "") { obj1.Add(new XAttribute("LinkedTo", parentid)); } obj1.Add(new XAttribute("Id", entid)); obj1.Add(new XAttribute("LayerGUID", layerid)); obj1.Add(new XAttribute("Layer", "Main")); if (po.Pos != null) { obj1.Add(new XAttribute("Pos", po.Pos)); } else { obj1.Add(new XAttribute("Pos", "0,0,0")); } if (po.Rotate != null) { obj1.Add(new XAttribute("Rotate", po.Rotate)); } obj1.Add(new XAttribute("Type", "Entity")); obj1.Add(new XAttribute("EntityClass", "Light")); obj1.Add(new XAttribute("ColorRGB", "65535")); obj1.Add(po.Properties); elObject.Add(obj1); } } //foreach (Part part in ship.parts) //{ // if (part.attachmentPoints != null) // { // List<PrefabObject> prefObjects = oc.GetPrefabObjectsByAttachmentName(p); // } //} } foreach (Child child in objCon.childs) { if (child.IsExternal()) { layerid = GuidUtility.GenLayerID("Main"); layerName = "Main"; XElement obj1root = child.GetAsFlowgraphEntity(parentid, layerid, layerName, ""); elObject.Add(obj1root); elObject = AddObjectsFromObjectContainers(elObject, child.Soc, child.Guid, layerid); } } return(elObject); }