public PrefabObject GetPrefabObjByName(string name) { PrefabObject probj = new PrefabObject(); foreach (PrefabObject pr in prefabObjects) { if (pr.Name.ToLower() == name.ToLower()) { probj = pr; } } return(probj); }
void MakePrefabObjects() { foreach (VisArea sc in visAreas) { if (sc.GetVisAreaType() == 0x00000090 || sc.GetVisAreaType() == 0x00000091 || sc.GetVisAreaType() == 0x000000B0) { PrefabObject prefabObj = new PrefabObject(); prefabObj.Name = sc.GetName(); prefabObj.SetPos(sc.GetPosition()); prefabObj.SetRotate(sc.GetRotation()); prefabObj.Height = sc.GetHeight().ToString(); prefabObj.Type = "VisArea"; prefabObj.DisplayFilled = "1"; XElement elPoints = new XElement("Points"); foreach (Point3D pt in sc.GetPoints()) { XElement elPoint = new XElement("Point"); elPoint.Add(new XAttribute("Pos", pt.Pos)); elPoints.Add(elPoint); } prefabObj.Points = elPoints; prefabObjects.Add(prefabObj); } } foreach (Portal sc in portals) { if (sc.GetPortalType() == 0x00000038) { PrefabObject prefabObj = new PrefabObject(); prefabObj.Name = sc.GetName(); prefabObj.SetPos(sc.GetPosition()); prefabObj.SetRotate(sc.GetRotation()); prefabObj.Height = sc.GetHeight().ToString(); prefabObj.Type = "Portal"; prefabObj.DisplayFilled = "1"; prefabObj.LightBlending = "0"; prefabObj.LightBlendValue = "0"; XElement elPoints = new XElement("Points"); foreach (Point3D pt in sc.GetPoints()) { XElement elPoint = new XElement("Point"); elPoint.Add(new XAttribute("Pos", pt.Pos)); elPoints.Add(elPoint); } prefabObj.Points = elPoints; prefabObjects.Add(prefabObj); } } }
public PrefabObject GetGeomAsPrefabObject(List <Item> itemsList) { PrefabObject prefabObj = null; if (propertiesDataCore != null) { prefabObj = new PrefabObject(); prefabObj.Id = GuidUtility.GenID(); prefabObj.Name = Name; prefabObj.Layer = Layer; prefabObj.LayerGUID = LayerGUID; if (Pos != null) { prefabObj.Pos = Pos; } if (Rotate != null) { prefabObj.Rotate = Rotate; } if (Scale != null) { prefabObj.Scale = Scale; } if (Material != null) { prefabObj.Material = Material; } if (Entity.Attribute("Geometry") != null) { prefabObj.Geometry = Entity.Attribute("Geometry").Value; prefabObj.Type = "GeomEntity"; prefabObj.EntityClass = "GeomEntity"; } else if (propertiesDataCore.Geometry != "") { prefabObj.Geometry = propertiesDataCore.Geometry; prefabObj.Type = "GeomEntity"; prefabObj.EntityClass = "GeomEntity"; if (propertiesDataCore.Material != "") { prefabObj.Material = propertiesDataCore.Material; } if (Material != null) { prefabObj.Material = Material; } } else if (propertiesDataCore.Loadout != null) { Item entityItem = null; foreach (Item it in itemsList) { if (it.name == EntityClass) { entityItem = it; } } if (entityItem != null) { if (entityItem.geometry != "") { prefabObj.Geometry = entityItem.geometry; prefabObj.Type = "GeomEntity"; prefabObj.EntityClass = "GeomEntity"; foreach (ItemPort loadoutItemPort in propertiesDataCore.Loadout.itemPorts) { //Item childItem = exporter.GetItem(loadoutItemPort.itemName); Item childItem = null; foreach (Item it in itemsList) { if (it.name == loadoutItemPort.itemName) { childItem = it; } } if (childItem != null) { if (childItem.geometry != "") { PrefabObject childObj = new PrefabObject(); ItemPort targetItemPort = entityItem.GetItemPort(loadoutItemPort.portName); if (targetItemPort != null) { string targetJointName = targetItemPort.helperName; childObj.Geometry = childItem.geometry; childObj.Id = GuidUtility.GenID(); childObj.Name = loadoutItemPort.itemName; childObj.Layer = Layer; childObj.LayerGUID = LayerGUID; childObj.Pos = "0,0,0"; childObj.Rotate = "1,0,0,0"; childObj.Type = "GeomEntity"; childObj.EntityClass = "GeomEntity"; childObj.ParentId = prefabObj.Id; childObj.AttachmentType = "CharacterBone"; if (targetJointName != null) { childObj.AttachmentTarget = targetJointName; } else { childObj.AttachmentTarget = targetItemPort.portName; } prefabObj.attachments.Add(childObj); } } } } } } } else { Item entityItem = null; foreach (Item it in itemsList) { if (it.name == EntityClass) { entityItem = it; } } if (entityItem != null) { if (entityItem.geometry != "") { prefabObj.Geometry = entityItem.geometry; prefabObj.Type = "GeomEntity"; prefabObj.EntityClass = "GeomEntity"; prefabObj.Name = Name; prefabObj.Layer = Layer; prefabObj.LayerGUID = LayerGUID; if (Pos != null) { prefabObj.Pos = Pos; } if (Rotate != null) { prefabObj.Rotate = Rotate; } if (Scale != null) { prefabObj.Scale = Scale; } if (Material != null) { prefabObj.Material = Material; } } } } } else { if (EntityClass == "AnimObject") { prefabObj = new PrefabObject(); prefabObj.Id = GuidUtility.GenID(); prefabObj.Type = "AnimObject"; prefabObj.EntityClass = "AnimObject"; prefabObj.Name = Name; prefabObj.Layer = Layer; prefabObj.LayerGUID = LayerGUID; if (Pos != null) { prefabObj.Pos = Pos; } if (Rotate != null) { prefabObj.Rotate = Rotate; } if (Scale != null) { prefabObj.Scale = Scale; } if (Material != null) { prefabObj.Material = Material; } prefabObj.Properties = Properties; } if (EntityClass == "GeomEntity") { } } //delete %level% geoms if (prefabObj != null) { if (prefabObj.Geometry != null) { if (prefabObj.Geometry.StartsWith("%level%", StringComparison.OrdinalIgnoreCase)) { prefabObj.Geometry = null; } } } return(prefabObj); }