public BallsData(XContainer ballsXMLData) { if (ballsXMLData == null) { return; } BallsGUID = ballsXMLData.Element("guid")?.Value; DisplayName = ballsXMLData.Element("displayName")?.Value; File = ballsXMLData.Element("file")?.Value; Asset = ballsXMLData.Element("asset")?.Value; if (ballsXMLData.Element("allowRandom")?.Value.ToLower() == "false" || ballsXMLData.Element("allowRandom")?.Value.ToLower() == "0") { AllowRandom = false; } foreach (XElement colorMatch in ballsXMLData.Elements("colorMatch")) { ColorMatchPart part = new ColorMatchPart(colorMatch.Element("object")?.Value, colorMatch.Element("material")?.Value, colorMatch.Element("materialCreate")?.Value, colorMatch.Element("mainTex")?.Value, colorMatch.Element("colorMask")?.Value); if (part.Verify()) { ColorMatchList.Add(part); } } //These things can be null if the XML doesn't exist or empty strings if it does exist but is left blank //Set everything to null for easier checks BallsGUID = BallsGUID.IsNullOrWhiteSpace() ? null : BallsGUID; DisplayName = DisplayName.IsNullOrWhiteSpace() ? null : DisplayName; File = File.IsNullOrWhiteSpace() ? null : File; Asset = Asset.IsNullOrWhiteSpace() ? null : Asset; }
public BodyData(XContainer bodyXMLData) { if (bodyXMLData == null) { return; } BodyGUID = bodyXMLData.Element("guid")?.Value; DisplayName = bodyXMLData.Element("displayName")?.Value; if (bodyXMLData.Element("sex")?.Value.ToLower() == "female") { Sex = 1; } if (bodyXMLData.Element("allowRandom")?.Value.ToLower() == "false" || bodyXMLData.Element("allowRandom")?.Value.ToLower() == "0") { AllowRandom = false; } XElement oo_base = bodyXMLData.Element("oo_base"); if (oo_base != null) { OOBase = oo_base.Element("file")?.Value; if (Asset.IsNullOrWhiteSpace()) { Asset = oo_base.Element("asset")?.Value; } BodyMainTex = oo_base.Element("mainTex")?.Value; BodyColorMask = oo_base.Element("colorMask")?.Value; Normals = oo_base.Element("normals")?.Value; UncensorOverlay = oo_base.Element("uncensorOverlay")?.Value; UncensorUnderlay = oo_base.Element("uncensorUnderlay")?.Value; foreach (XElement parts in oo_base.Elements("additionalPart")) { string part = parts?.Value; if (!part.IsNullOrWhiteSpace()) { AdditionalParts.Add(part); } } foreach (XElement colorMatch in oo_base.Elements("colorMatch")) { ColorMatchPart part = new ColorMatchPart(colorMatch.Element("object")?.Value, colorMatch.Element("material")?.Value, colorMatch.Element("materialCreate")?.Value, colorMatch.Element("mainTex")?.Value, colorMatch.Element("colorMask")?.Value); if (part.Verify()) { ColorMatchList.Add(part); } } } XElement mm_base = bodyXMLData.Element("oo_base"); if (mm_base != null) { MMBase = mm_base.Element("mm_base")?.Value; BodyMaterial = mm_base.Element("material")?.Value; BodyMaterialCreate = mm_base.Element("materialCreate")?.Value; } //These things can be null if the XML doesn't exist or empty strings if it does exist but is left blank //Set everything to null/defaults for easier checks MMBase = MMBase.IsNullOrWhiteSpace() ? Defaults.MMBase : MMBase; OOBase = OOBase.IsNullOrWhiteSpace() ? Defaults.OOBase : OOBase; BodyGUID = BodyGUID.IsNullOrWhiteSpace() ? null : BodyGUID; DisplayName = DisplayName.IsNullOrWhiteSpace() ? BodyGUID : DisplayName; Normals = Normals.IsNullOrWhiteSpace() ? Defaults.Normals : Normals; BodyMainTex = BodyMainTex.IsNullOrWhiteSpace() ? Defaults.BodyMainTex : BodyMainTex; BodyColorMask = BodyColorMask.IsNullOrWhiteSpace() ? Sex == 0 ? Defaults.BodyColorMaskMale : Defaults.BodyColorMaskFemale : BodyColorMask; Asset = Asset.IsNullOrWhiteSpace() ? Sex == 0 ? Defaults.AssetMale : Defaults.AssetFemale : Asset; BodyMaterial = BodyMaterial.IsNullOrWhiteSpace() ? Sex == 0 ? Defaults.BodyMaterialMale : Defaults.BodyMaterialFemale : BodyMaterial; BodyMaterialCreate = BodyMaterialCreate.IsNullOrWhiteSpace() ? Defaults.BodyMaterialCreate : BodyMaterialCreate; }