internal CharacterAttachmentBrand(CharacterAttachmentSlot slot, XElement element) { Slot = slot; // Set up strings var brandNameAttribute = element.Attribute("Name"); if (brandNameAttribute != null) Name = brandNameAttribute.Value; var brandThumbnailAttribute = element.Attribute("Thumbnail"); if (brandThumbnailAttribute != null) ThumbnailPath = brandThumbnailAttribute.Value; // Get attachments var slotAttachmentElements = element.Elements("Attachment"); int count = slotAttachmentElements.Count(); if (Slot.CanBeEmpty) count++; var slotAttachments = new CharacterAttachment[count]; for (int i = 0; i < slotAttachmentElements.Count(); i++) { var slotAttachmentElement = slotAttachmentElements.ElementAt(i); slotAttachments[i] = new CharacterAttachment(Slot, slotAttachmentElement); } if (Slot.CanBeEmpty) slotAttachments[slotAttachmentElements.Count()] = new CharacterAttachment(Slot, null); Attachments = slotAttachments; }
internal CharacterAttachmentBrand(CharacterAttachmentSlot slot, XElement element) { Slot = slot; // Set up strings var brandNameAttribute = element.Attribute("Name"); if (brandNameAttribute != null) { Name = brandNameAttribute.Value; } var brandThumbnailAttribute = element.Attribute("Thumbnail"); if (brandThumbnailAttribute != null) { ThumbnailPath = brandThumbnailAttribute.Value; } // Get attachments var slotAttachmentElements = element.Elements("Attachment"); int count = slotAttachmentElements.Count(); var slotAttachments = new CharacterAttachment[count]; for (int i = 0; i < slotAttachmentElements.Count(); i++) { var slotAttachmentElement = slotAttachmentElements.ElementAt(i); slotAttachments[i] = new CharacterAttachment(Slot, slotAttachmentElement); } Attachments = slotAttachments; }
internal CharacterAttachmentSlot(CustomizationManager manager, XElement element) { m_manager = manager; Element = element; Name = element.Attribute("name").Value; var allowNoneAttribute = element.Attribute("allowNone"); if(allowNoneAttribute != null) CanBeEmpty = allowNoneAttribute.Value == "1"; var hiddenAttribute = element.Attribute("hidden"); if(hiddenAttribute != null) Hidden = hiddenAttribute.Value == "1"; var subSlotElements = element.Elements("AttachmentSlot"); if (subSlotElements.Count() > 0) { SubAttachmentSlots = new CharacterAttachmentSlot[subSlotElements.Count()]; for(int i = 0; i < subSlotElements.Count(); i++) { var subSlotElement = subSlotElements.ElementAt(i); SubAttachmentSlots[i] = new CharacterAttachmentSlot(manager, subSlotElement); } } var mirroredSlotElements = element.Elements("MirroredSlot"); if (mirroredSlotElements.Count() > 0) { MirroredSlots = new CharacterAttachmentSlot[mirroredSlotElements.Count()]; for (int i = 0; i < mirroredSlotElements.Count(); i++) { var mirroredSlotElement = mirroredSlotElements.ElementAt(i); MirroredSlots[i] = new CharacterAttachmentSlot(manager, mirroredSlotElement); } } // Set up brands var slotBrandElements = element.Elements("Brand"); int numBrands = slotBrandElements.Count(); Brands = new CharacterAttachmentBrand[numBrands]; for(int i = 0; i < numBrands; i++) { var brandElement = slotBrandElements.ElementAt(i); Brands[i] = new CharacterAttachmentBrand(this, brandElement); } }
internal CharacterAttachmentSlot(CustomizationManager manager, XElement element) { Manager = manager; Element = element; Name = element.Attribute("name").Value; var uiNameAttribute = element.Attribute("uiName"); if (uiNameAttribute != null) { UIName = uiNameAttribute.Value; } var categoryAttribute = element.Attribute("category"); if (categoryAttribute != null) { Category = categoryAttribute.Value; } var allowNoneAttribute = element.Attribute("allowNone"); if (allowNoneAttribute != null) { CanBeEmpty = allowNoneAttribute.Value == "1"; } if (CanBeEmpty) { EmptyAttachment = new CharacterAttachment(this, null); } var hiddenAttribute = element.Attribute("hidden"); if (hiddenAttribute != null) { Hidden = hiddenAttribute.Value == "1"; } var subSlotElements = element.Elements("AttachmentSlot"); if (subSlotElements.Count() > 0) { SubAttachmentSlots = new CharacterAttachmentSlot[subSlotElements.Count()]; for (int i = 0; i < subSlotElements.Count(); i++) { var subSlotElement = subSlotElements.ElementAt(i); SubAttachmentSlots[i] = new CharacterAttachmentSlot(manager, subSlotElement); } } var mirroredSlotElements = element.Elements("MirroredSlot"); if (mirroredSlotElements.Count() > 0) { MirroredSlots = new CharacterAttachmentSlot[mirroredSlotElements.Count()]; for (int i = 0; i < mirroredSlotElements.Count(); i++) { var mirroredSlotElement = mirroredSlotElements.ElementAt(i); MirroredSlots[i] = new CharacterAttachmentSlot(manager, mirroredSlotElement); } } // Set up brands var slotBrandElements = element.Elements("Brand"); int numBrands = slotBrandElements.Count(); Brands = new CharacterAttachmentBrand[numBrands]; for (int i = 0; i < numBrands; i++) { var brandElement = slotBrandElements.ElementAt(i); Brands[i] = new CharacterAttachmentBrand(this, brandElement); } }
internal CharacterAttachment(CharacterAttachmentSlot slot, XElement element, bool child = false) { Element = element; Slot = slot; if (element == null) { Name = "None"; ThumbnailPath = slot.Manager.InitParameters.EmptyThumbnailPath; } else { var slotAttachmentNameAttribute = element.Attribute("Name"); if (slotAttachmentNameAttribute != null) Name = slotAttachmentNameAttribute.Value; var slotAttachmentThumbnailAttribute = element.Attribute("Thumbnail"); if (slotAttachmentThumbnailAttribute != null) ThumbnailPath = slotAttachmentThumbnailAttribute.Value; var slotAttachmentTypeAttribute = element.Attribute("Type"); if (slotAttachmentTypeAttribute != null) Type = slotAttachmentTypeAttribute.Value; var slotAttachmentBoneNameAttribute = element.Attribute("BoneName"); if (slotAttachmentBoneNameAttribute != null) BoneName = slotAttachmentBoneNameAttribute.Value; var slotAttachmentObjectAttribute = element.Attribute("Binding"); if (slotAttachmentObjectAttribute != null) Object = slotAttachmentObjectAttribute.Value; var slotAttachmentFlagsAttribute = element.Attribute("Flags"); if (slotAttachmentFlagsAttribute != null) Flags = slotAttachmentFlagsAttribute.Value; var slotAttachmentPositionAttribute = element.Attribute("Position"); if (slotAttachmentPositionAttribute != null) Position = slotAttachmentPositionAttribute.Value; var slotAttachmentRotationAttribute = element.Attribute("Rotation"); if (slotAttachmentRotationAttribute != null) Rotation = slotAttachmentRotationAttribute.Value; var slotAttachmentMaterials = new List<CharacterAttachmentMaterial>(); foreach (var materialElement in element.Elements("Material")) slotAttachmentMaterials.Add(new CharacterAttachmentMaterial(this, materialElement)); Materials = slotAttachmentMaterials.ToArray(); Material = Materials.FirstOrDefault(); if (!child) { var subCharacterAttachments = new List<CharacterAttachment>(); foreach (var subAttachmentElement in element.Elements("SubAttachment")) { var subAttachmentSlotName = subAttachmentElement.Attribute("Slot").Value; var subAttachmentSlot = Slot.SubAttachmentSlots.FirstOrDefault(x => x.Name == subAttachmentSlotName); if (subAttachmentSlot == null) throw new CustomizationConfigurationException(string.Format("Failed to find subattachment slot {0} for attachment {1} for primary slot {2}", subAttachmentSlotName, Name, Slot.Name)); subCharacterAttachments.Add(new CharacterAttachment(subAttachmentSlot, subAttachmentElement, true)); } SubAttachmentVariations = subCharacterAttachments.ToArray(); SubAttachment = SubAttachmentVariations.FirstOrDefault(); } if (slot.MirroredSlots != null) { MirroredChildren = new CharacterAttachment[slot.MirroredSlots.Length]; for (int i = 0; i < slot.MirroredSlots.Length; i++) { var mirroredSlot = slot.MirroredSlots.ElementAt(i); var mirroredAttachmentElement = element.Element(mirroredSlot.Name); if (mirroredAttachmentElement == null) throw new CustomizationConfigurationException(string.Format("Failed to get mirrored element from slot {0} and name {1}", slot.Name, mirroredSlot.Name)); MirroredChildren[i] = new CharacterAttachment(mirroredSlot, mirroredAttachmentElement); } } } }
internal CharacterAttachment(CharacterAttachmentSlot slot, XElement element, bool child = false) { Element = element; Slot = slot; if (element == null) { Name = "None"; ThumbnailPath = slot.Manager.InitParameters.EmptyThumbnailPath; } else { var slotAttachmentNameAttribute = element.Attribute("Name"); if (slotAttachmentNameAttribute != null) { Name = slotAttachmentNameAttribute.Value; } var slotAttachmentThumbnailAttribute = element.Attribute("Thumbnail"); if (slotAttachmentThumbnailAttribute != null) { ThumbnailPath = slotAttachmentThumbnailAttribute.Value; } var slotAttachmentTypeAttribute = element.Attribute("Type"); if (slotAttachmentTypeAttribute != null) { Type = slotAttachmentTypeAttribute.Value; } var slotAttachmentBoneNameAttribute = element.Attribute("BoneName"); if (slotAttachmentBoneNameAttribute != null) { BoneName = slotAttachmentBoneNameAttribute.Value; } var slotAttachmentObjectAttribute = element.Attribute("Binding"); if (slotAttachmentObjectAttribute != null) { Object = slotAttachmentObjectAttribute.Value; } var slotAttachmentFlagsAttribute = element.Attribute("Flags"); if (slotAttachmentFlagsAttribute != null) { Flags = slotAttachmentFlagsAttribute.Value; } var slotAttachmentPositionAttribute = element.Attribute("Position"); if (slotAttachmentPositionAttribute != null) { Position = slotAttachmentPositionAttribute.Value; } var slotAttachmentRotationAttribute = element.Attribute("Rotation"); if (slotAttachmentRotationAttribute != null) { Rotation = slotAttachmentRotationAttribute.Value; } var slotAttachmentMaterials = new List <CharacterAttachmentMaterial>(); foreach (var materialElement in element.Elements("Material")) { slotAttachmentMaterials.Add(new CharacterAttachmentMaterial(this, materialElement)); } Materials = slotAttachmentMaterials.ToArray(); Material = Materials.FirstOrDefault(); if (!child) { var subCharacterAttachments = new List <CharacterAttachment>(); foreach (var subAttachmentElement in element.Elements("SubAttachment")) { var subAttachmentSlotName = subAttachmentElement.Attribute("Slot").Value; var subAttachmentSlot = Slot.SubAttachmentSlots.FirstOrDefault(x => x.Name == subAttachmentSlotName); if (subAttachmentSlot == null) { throw new CustomizationConfigurationException(string.Format("Failed to find subattachment slot {0} for attachment {1} for primary slot {2}", subAttachmentSlotName, Name, Slot.Name)); } subCharacterAttachments.Add(new CharacterAttachment(subAttachmentSlot, subAttachmentElement, true)); } SubAttachmentVariations = subCharacterAttachments.ToArray(); SubAttachment = SubAttachmentVariations.FirstOrDefault(); } if (slot.MirroredSlots != null) { MirroredChildren = new CharacterAttachment[slot.MirroredSlots.Length]; for (int i = 0; i < slot.MirroredSlots.Length; i++) { var mirroredSlot = slot.MirroredSlots.ElementAt(i); var mirroredAttachmentElement = element.Element(mirroredSlot.Name); if (mirroredAttachmentElement == null) { throw new CustomizationConfigurationException(string.Format("Failed to get mirrored element from slot {0} and name {1}", slot.Name, mirroredSlot.Name)); } MirroredChildren[i] = new CharacterAttachment(mirroredSlot, mirroredAttachmentElement); } } } }