internal void Reset()
        {
            foreach (CharacterAttrib objAttribute in AttributeList.Concat(SpecialAttributeList))
            {
                objAttribute.UnbindAttribute();
            }
            AttributeList.Clear();
            SpecialAttributeList.Clear();
            foreach (string strAttribute in AttributeStrings)
            {
                CharacterAttrib objAttribute;
                switch (CharacterAttrib.ConvertToAttributeCategory(strAttribute))
                {
                case CharacterAttrib.AttributeCategory.Special:
                    objAttribute = new CharacterAttrib(_objCharacter, strAttribute, CharacterAttrib.AttributeCategory.Special);
                    SpecialAttributeList.Add(objAttribute);
                    break;

                case CharacterAttrib.AttributeCategory.Standard:
                    objAttribute = new CharacterAttrib(_objCharacter, strAttribute);
                    AttributeList.Add(objAttribute);
                    break;
                }
            }
            BuildBindingList();
        }
 public void UnbindAttributeSection()
 {
     _dicBindings.Clear();
     foreach (CharacterAttrib objAttribute in AttributeList.Concat(SpecialAttributeList))
     {
         objAttribute.UnbindAttribute();
     }
     AttributeList.Clear();
     SpecialAttributeList.Clear();
 }
		public CharacterAttrib GetAttributeByName(string abbrev)
		{
            bool blnGetShifterAttribute = _character.MetatypeCategory == "Shapeshifter" && _character.Created && _character.AttributeSection.AttributeCategory == CharacterAttrib.AttributeCategory.Shapeshifter;
            CharacterAttrib objReturn = AttributeList.FirstOrDefault(att => att.Abbrev == abbrev && (att.MetatypeCategory == CharacterAttrib.AttributeCategory.Shapeshifter) == blnGetShifterAttribute);
            if (objReturn == null)
			{
                objReturn = SpecialAttributeList.FirstOrDefault(att => att.Abbrev == abbrev);
            }
			return objReturn;
		}
		internal void Reset()
		{
			AttributeList.Clear();
			SpecialAttributeList.Clear();
			foreach (string strAttribute in AttributeStrings)
			{
				CharacterAttrib att = new CharacterAttrib(_character, strAttribute);
				switch (att.ConvertToAttributeCategory(att.Abbrev))
				{
					case CharacterAttrib.AttributeCategory.Special:
						SpecialAttributeList.Add(att);
						break;
					case CharacterAttrib.AttributeCategory.Standard:
						AttributeList.Add(att);
						break;
				}
			}
			BuildBindingList();
		}
        public void LoadFromHeroLab(XmlNode xmlStatBlockBaseNode)
        {
            Timekeeper.Start("load_char_attrib");
            foreach (CharacterAttrib objAttribute in AttributeList.Concat(SpecialAttributeList))
            {
                objAttribute.UnbindAttribute();
            }
            AttributeList.Clear();
            SpecialAttributeList.Clear();
            XmlDocument objXmlDocument  = XmlManager.Load(_objCharacter.IsCritter ? "critters.xml" : "metatypes.xml");
            XmlNode     xmlMetatypeNode = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _objCharacter.Metatype + "\"]");
            XmlNode     xmlCharNode     = xmlMetatypeNode?.SelectSingleNode("metavariants/metavariant[name = \"" + _objCharacter.Metavariant + "\"]") ?? xmlMetatypeNode;
            // We only want to remake attributes for shifters in career mode, because they only get their second set of attributes when exporting from create mode into career mode
            XmlNode xmlCharNodeAnimalForm = _objCharacter.MetatypeCategory == "Shapeshifter" && _objCharacter.Created ? xmlMetatypeNode : null;

            foreach (string strAttribute in AttributeStrings)
            {
                // First, remake the attribute
                CharacterAttrib objAttribute = new CharacterAttrib(_objCharacter, strAttribute);
                objAttribute = RemakeAttribute(objAttribute, xmlCharNode);
                switch (CharacterAttrib.ConvertToAttributeCategory(objAttribute.Abbrev))
                {
                case CharacterAttrib.AttributeCategory.Special:
                    SpecialAttributeList.Add(objAttribute);
                    break;

                case CharacterAttrib.AttributeCategory.Standard:
                    AttributeList.Add(objAttribute);
                    break;
                }
                if (xmlCharNodeAnimalForm != null)
                {
                    objAttribute = new CharacterAttrib(_objCharacter, strAttribute, CharacterAttrib.AttributeCategory.Shapeshifter);
                    objAttribute = RemakeAttribute(objAttribute, xmlCharNodeAnimalForm);
                    switch (CharacterAttrib.ConvertToAttributeCategory(objAttribute.Abbrev))
                    {
                    case CharacterAttrib.AttributeCategory.Special:
                        SpecialAttributeList.Add(objAttribute);
                        break;

                    case CharacterAttrib.AttributeCategory.Standard:
                        AttributeList.Add(objAttribute);
                        break;
                    }
                }

                // Then load in attribute karma levels (we'll adjust these later if the character is in Create mode)
                if (strAttribute == "ESS") // Not Essence though, this will get modified automatically instead of having its value set to the one HeroLab displays
                {
                    continue;
                }
                XmlNode xmlHeroLabAttributeNode = xmlStatBlockBaseNode.SelectSingleNode("attributes/attribute[@name = \"" + GetAttributeEnglishName(strAttribute) + "\"]");
                XmlNode xmlAttributeBaseNode    = xmlHeroLabAttributeNode?.SelectSingleNode("@base");
                if (xmlAttributeBaseNode != null &&
                    int.TryParse(xmlAttributeBaseNode.InnerText, out int intHeroLabAttributeBaseValue))
                {
                    int intAttributeMinimumValue = GetAttributeByName(strAttribute).MetatypeMinimum;
                    if (intHeroLabAttributeBaseValue != intAttributeMinimumValue)
                    {
                        objAttribute.Karma = intHeroLabAttributeBaseValue - intAttributeMinimumValue;
                    }
                }
            }

            if (!_objCharacter.Created && _objCharacter.BuildMethodHasSkillPoints)
            {
                // Allocate Attribute Points
                int             intAttributePointCount = _objCharacter.TotalAttributes;
                CharacterAttrib objAttributeToPutPointsInto;
                // First loop through attributes where costs can be 100% covered with points
                do
                {
                    objAttributeToPutPointsInto = null;
                    int intAttributeToPutPointsIntoTotalKarmaCost = 0;
                    foreach (CharacterAttrib objLoopAttribute in AttributeList)
                    {
                        if (objLoopAttribute.Karma == 0)
                        {
                            continue;
                        }
                        // Put points into the attribute with the highest total karma cost.
                        // In case of ties, pick the one that would need more points to cover it (the other one will hopefully get picked up at a later cycle)
                        int intLoopTotalKarmaCost = objLoopAttribute.TotalKarmaCost;
                        if (objAttributeToPutPointsInto == null || (objLoopAttribute.Karma <= intAttributePointCount &&
                                                                    (intLoopTotalKarmaCost > intAttributeToPutPointsIntoTotalKarmaCost ||
                                                                     (intLoopTotalKarmaCost == intAttributeToPutPointsIntoTotalKarmaCost && objLoopAttribute.Karma > objAttributeToPutPointsInto.Karma))))
                        {
                            objAttributeToPutPointsInto = objLoopAttribute;
                            intAttributeToPutPointsIntoTotalKarmaCost = intLoopTotalKarmaCost;
                        }
                    }

                    if (objAttributeToPutPointsInto != null)
                    {
                        objAttributeToPutPointsInto.Base  = objAttributeToPutPointsInto.Karma;
                        intAttributePointCount           -= objAttributeToPutPointsInto.Karma;
                        objAttributeToPutPointsInto.Karma = 0;
                    }
                } while (objAttributeToPutPointsInto != null && intAttributePointCount > 0);

                // If any points left over, then put them all into the attribute with the highest karma cost
                if (intAttributePointCount > 0 && AttributeList.Any(x => x.Karma != 0))
                {
                    int intHighestTotalKarmaCost = 0;
                    foreach (CharacterAttrib objLoopAttribute in AttributeList)
                    {
                        if (objLoopAttribute.Karma == 0)
                        {
                            continue;
                        }
                        // Put points into the attribute with the highest total karma cost.
                        // In case of ties, pick the one that would need more points to cover it (the other one will hopefully get picked up at a later cycle)
                        int intLoopTotalKarmaCost = objLoopAttribute.TotalKarmaCost;
                        if (objAttributeToPutPointsInto == null ||
                            intLoopTotalKarmaCost > intHighestTotalKarmaCost ||
                            (intLoopTotalKarmaCost == intHighestTotalKarmaCost && objLoopAttribute.Karma > objAttributeToPutPointsInto.Karma))
                        {
                            objAttributeToPutPointsInto = objLoopAttribute;
                            intHighestTotalKarmaCost    = intLoopTotalKarmaCost;
                        }
                    }

                    if (objAttributeToPutPointsInto != null)
                    {
                        objAttributeToPutPointsInto.Base   = intAttributePointCount;
                        objAttributeToPutPointsInto.Karma -= intAttributePointCount;
                    }
                }

                // Allocate Special Attribute Points
                intAttributePointCount = _objCharacter.TotalSpecial;
                // First loop through attributes where costs can be 100% covered with points
                do
                {
                    objAttributeToPutPointsInto = null;
                    int intAttributeToPutPointsIntoTotalKarmaCost = 0;
                    foreach (CharacterAttrib objLoopAttribute in SpecialAttributeList)
                    {
                        if (objLoopAttribute.Karma == 0)
                        {
                            continue;
                        }
                        // Put points into the attribute with the highest total karma cost.
                        // In case of ties, pick the one that would need more points to cover it (the other one will hopefully get picked up at a later cycle)
                        int intLoopTotalKarmaCost = objLoopAttribute.TotalKarmaCost;
                        if (objAttributeToPutPointsInto == null || (objLoopAttribute.Karma <= intAttributePointCount &&
                                                                    (intLoopTotalKarmaCost > intAttributeToPutPointsIntoTotalKarmaCost ||
                                                                     (intLoopTotalKarmaCost == intAttributeToPutPointsIntoTotalKarmaCost && objLoopAttribute.Karma > objAttributeToPutPointsInto.Karma))))
                        {
                            objAttributeToPutPointsInto = objLoopAttribute;
                            intAttributeToPutPointsIntoTotalKarmaCost = intLoopTotalKarmaCost;
                        }
                    }

                    if (objAttributeToPutPointsInto != null)
                    {
                        objAttributeToPutPointsInto.Base  = objAttributeToPutPointsInto.Karma;
                        intAttributePointCount           -= objAttributeToPutPointsInto.Karma;
                        objAttributeToPutPointsInto.Karma = 0;
                    }
                } while (objAttributeToPutPointsInto != null);

                // If any points left over, then put them all into the attribute with the highest karma cost
                if (intAttributePointCount > 0 && SpecialAttributeList.Any(x => x.Karma != 0))
                {
                    int intHighestTotalKarmaCost = 0;
                    foreach (CharacterAttrib objLoopAttribute in SpecialAttributeList)
                    {
                        if (objLoopAttribute.Karma == 0)
                        {
                            continue;
                        }
                        // Put points into the attribute with the highest total karma cost.
                        // In case of ties, pick the one that would need more points to cover it (the other one will hopefully get picked up at a later cycle)
                        int intLoopTotalKarmaCost = objLoopAttribute.TotalKarmaCost;
                        if (objAttributeToPutPointsInto == null ||
                            intLoopTotalKarmaCost > intHighestTotalKarmaCost ||
                            (intLoopTotalKarmaCost == intHighestTotalKarmaCost && objLoopAttribute.Karma > objAttributeToPutPointsInto.Karma))
                        {
                            objAttributeToPutPointsInto = objLoopAttribute;
                            intHighestTotalKarmaCost    = intLoopTotalKarmaCost;
                        }
                    }

                    if (objAttributeToPutPointsInto != null)
                    {
                        objAttributeToPutPointsInto.Base   = intAttributePointCount;
                        objAttributeToPutPointsInto.Karma -= intAttributePointCount;
                    }
                }
            }
            ResetBindings();
            _objCharacter.RefreshAttributeBindings();
            Timekeeper.Finish("load_char_attrib");
        }
        public void Load(XmlNode xmlSavedCharacterNode)
        {
            Timekeeper.Start("load_char_attrib");
            foreach (CharacterAttrib objAttribute in AttributeList.Concat(SpecialAttributeList))
            {
                objAttribute.UnbindAttribute();
            }
            AttributeList.Clear();
            SpecialAttributeList.Clear();
            XmlDocument objXmlDocument  = XmlManager.Load(_objCharacter.IsCritter ? "critters.xml" : "metatypes.xml");
            XmlNode     xmlMetatypeNode = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _objCharacter.Metatype + "\"]");
            XmlNode     xmlCharNode     = xmlMetatypeNode?.SelectSingleNode("metavariants/metavariant[name = \"" + _objCharacter.Metavariant + "\"]") ?? xmlMetatypeNode;
            // We only want to remake attributes for shifters in career mode, because they only get their second set of attributes when exporting from create mode into career mode
            XmlNode xmlCharNodeAnimalForm = _objCharacter.MetatypeCategory == "Shapeshifter" && _objCharacter.Created ? xmlMetatypeNode : null;

            foreach (string strAttribute in AttributeStrings)
            {
                XmlNodeList lstAttributeNodes = xmlSavedCharacterNode.SelectNodes("attributes/attribute[name = \"" + strAttribute + "\"]");
                // Couldn't find the appopriate attribute in the loaded file, so regenerate it from scratch.
                if (lstAttributeNodes == null || lstAttributeNodes.Count == 0 || xmlCharNodeAnimalForm != null && _objCharacter.LastSavedVersion < new Version("5.200.25"))
                {
                    CharacterAttrib objAttribute;
                    switch (CharacterAttrib.ConvertToAttributeCategory(strAttribute))
                    {
                    case CharacterAttrib.AttributeCategory.Special:
                        objAttribute = new CharacterAttrib(_objCharacter, strAttribute, CharacterAttrib.AttributeCategory.Special);
                        objAttribute = RemakeAttribute(objAttribute, xmlCharNode);
                        SpecialAttributeList.Add(objAttribute);
                        break;

                    case CharacterAttrib.AttributeCategory.Standard:
                        objAttribute = new CharacterAttrib(_objCharacter, strAttribute);
                        objAttribute = RemakeAttribute(objAttribute, xmlCharNode);
                        AttributeList.Add(objAttribute);
                        break;
                    }

                    if (xmlCharNodeAnimalForm == null)
                    {
                        continue;
                    }
                    objAttribute = new CharacterAttrib(_objCharacter, strAttribute, CharacterAttrib.AttributeCategory.Shapeshifter);
                    objAttribute = RemakeAttribute(objAttribute, xmlCharNodeAnimalForm);
                    switch (CharacterAttrib.ConvertToAttributeCategory(objAttribute.Abbrev))
                    {
                    case CharacterAttrib.AttributeCategory.Special:
                        SpecialAttributeList.Add(objAttribute);
                        break;

                    case CharacterAttrib.AttributeCategory.Standard:
                        AttributeList.Add(objAttribute);
                        break;
                    }
                }
                else
                {
                    foreach (XmlNode xmlAttributeNode in lstAttributeNodes)
                    {
                        CharacterAttrib att = new CharacterAttrib(_objCharacter, strAttribute);
                        att.Load(xmlAttributeNode);
                        switch (CharacterAttrib.ConvertToAttributeCategory(att.Abbrev))
                        {
                        case CharacterAttrib.AttributeCategory.Special:
                            SpecialAttributeList.Add(att);
                            break;

                        case CharacterAttrib.AttributeCategory.Standard:
                            AttributeList.Add(att);
                            break;
                        }
                    }
                }
            }

            Attributes = new ObservableCollection <CharacterAttrib>
            {
                _objCharacter.BOD,
                _objCharacter.AGI,
                _objCharacter.REA,
                _objCharacter.STR,
                _objCharacter.CHA,
                _objCharacter.INT,
                _objCharacter.LOG,
                _objCharacter.WIL,
                _objCharacter.EDG
            };
            if (_objCharacter.MAGEnabled)
            {
                Attributes.Add(_objCharacter.MAG);
                if (_objCharacter.Options.MysAdeptSecondMAGAttribute && _objCharacter.IsMysticAdept)
                {
                    Attributes.Add(_objCharacter.MAGAdept);
                }
            }
            if (_objCharacter.RESEnabled)
            {
                Attributes.Add(_objCharacter.RES);
            }
            if (_objCharacter.DEPEnabled)
            {
                Attributes.Add(_objCharacter.DEP);
            }
            ResetBindings();
            _objCharacter.RefreshAttributeBindings();
            Timekeeper.Finish("load_char_attrib");
        }
        public void Create(XmlNode charNode, int intValue, int intMinModifier = 0, int intMaxModifier = 0)
        {
            Timekeeper.Start("create_char_attrib");
            foreach (CharacterAttrib objAttribute in AttributeList.Concat(SpecialAttributeList))
            {
                objAttribute.UnbindAttribute();
            }
            AttributeList.Clear();
            SpecialAttributeList.Clear();

            foreach (string strAttribute in AttributeStrings)
            {
                CharacterAttrib objAttribute;
                switch (CharacterAttrib.ConvertToAttributeCategory(strAttribute))
                {
                case CharacterAttrib.AttributeCategory.Special:
                    objAttribute = new CharacterAttrib(_objCharacter, strAttribute, CharacterAttrib.AttributeCategory.Special);
                    SpecialAttributeList.Add(objAttribute);
                    break;

                case CharacterAttrib.AttributeCategory.Standard:
                    objAttribute = new CharacterAttrib(_objCharacter, strAttribute);
                    AttributeList.Add(objAttribute);
                    break;
                }
            }

            _objCharacter.BOD.AssignLimits(CommonFunctions.ExpressionToString(charNode["bodmin"]?.InnerText, intValue, intMinModifier), CommonFunctions.ExpressionToString(charNode["bodmax"]?.InnerText, intValue, intMaxModifier), CommonFunctions.ExpressionToString(charNode["bodaug"]?.InnerText, intValue, intMaxModifier));
            _objCharacter.AGI.AssignLimits(CommonFunctions.ExpressionToString(charNode["agimin"]?.InnerText, intValue, intMinModifier), CommonFunctions.ExpressionToString(charNode["agimax"]?.InnerText, intValue, intMaxModifier), CommonFunctions.ExpressionToString(charNode["agiaug"]?.InnerText, intValue, intMaxModifier));
            _objCharacter.REA.AssignLimits(CommonFunctions.ExpressionToString(charNode["reamin"]?.InnerText, intValue, intMinModifier), CommonFunctions.ExpressionToString(charNode["reamax"]?.InnerText, intValue, intMaxModifier), CommonFunctions.ExpressionToString(charNode["reaaug"]?.InnerText, intValue, intMaxModifier));
            _objCharacter.STR.AssignLimits(CommonFunctions.ExpressionToString(charNode["strmin"]?.InnerText, intValue, intMinModifier), CommonFunctions.ExpressionToString(charNode["strmax"]?.InnerText, intValue, intMaxModifier), CommonFunctions.ExpressionToString(charNode["straug"]?.InnerText, intValue, intMaxModifier));
            _objCharacter.CHA.AssignLimits(CommonFunctions.ExpressionToString(charNode["chamin"]?.InnerText, intValue, intMinModifier), CommonFunctions.ExpressionToString(charNode["chamax"]?.InnerText, intValue, intMaxModifier), CommonFunctions.ExpressionToString(charNode["chaaug"]?.InnerText, intValue, intMaxModifier));
            _objCharacter.INT.AssignLimits(CommonFunctions.ExpressionToString(charNode["intmin"]?.InnerText, intValue, intMinModifier), CommonFunctions.ExpressionToString(charNode["intmax"]?.InnerText, intValue, intMaxModifier), CommonFunctions.ExpressionToString(charNode["intaug"]?.InnerText, intValue, intMaxModifier));
            _objCharacter.LOG.AssignLimits(CommonFunctions.ExpressionToString(charNode["logmin"]?.InnerText, intValue, intMinModifier), CommonFunctions.ExpressionToString(charNode["logmax"]?.InnerText, intValue, intMaxModifier), CommonFunctions.ExpressionToString(charNode["logaug"]?.InnerText, intValue, intMaxModifier));
            _objCharacter.WIL.AssignLimits(CommonFunctions.ExpressionToString(charNode["wilmin"]?.InnerText, intValue, intMinModifier), CommonFunctions.ExpressionToString(charNode["wilmax"]?.InnerText, intValue, intMaxModifier), CommonFunctions.ExpressionToString(charNode["wilaug"]?.InnerText, intValue, intMaxModifier));
            _objCharacter.MAG.AssignLimits(CommonFunctions.ExpressionToString(charNode["magmin"]?.InnerText, intValue, intMinModifier), CommonFunctions.ExpressionToString(charNode["magmax"]?.InnerText, intValue, intMaxModifier), CommonFunctions.ExpressionToString(charNode["magaug"]?.InnerText, intValue, intMaxModifier));
            _objCharacter.RES.AssignLimits(CommonFunctions.ExpressionToString(charNode["resmin"]?.InnerText, intValue, intMinModifier), CommonFunctions.ExpressionToString(charNode["resmax"]?.InnerText, intValue, intMaxModifier), CommonFunctions.ExpressionToString(charNode["resaug"]?.InnerText, intValue, intMaxModifier));
            _objCharacter.EDG.AssignLimits(CommonFunctions.ExpressionToString(charNode["edgmin"]?.InnerText, intValue, intMinModifier), CommonFunctions.ExpressionToString(charNode["edgmax"]?.InnerText, intValue, intMaxModifier), CommonFunctions.ExpressionToString(charNode["edgaug"]?.InnerText, intValue, intMaxModifier));
            _objCharacter.DEP.AssignLimits(CommonFunctions.ExpressionToString(charNode["depmin"]?.InnerText, intValue, intMinModifier), CommonFunctions.ExpressionToString(charNode["depmax"]?.InnerText, intValue, intMaxModifier), CommonFunctions.ExpressionToString(charNode["depaug"]?.InnerText, intValue, intMaxModifier));
            _objCharacter.MAGAdept.AssignLimits(CommonFunctions.ExpressionToString(charNode["magmin"]?.InnerText, intValue, intMinModifier), CommonFunctions.ExpressionToString(charNode["magmax"]?.InnerText, intValue, intMaxModifier), CommonFunctions.ExpressionToString(charNode["magaug"]?.InnerText, intValue, intMaxModifier));
            _objCharacter.ESS.AssignLimits(CommonFunctions.ExpressionToString(charNode["essmin"]?.InnerText, intValue, 0), CommonFunctions.ExpressionToString(charNode["essmax"]?.InnerText, intValue, 0), CommonFunctions.ExpressionToString(charNode["essaug"]?.InnerText, intValue, 0));

            Attributes = new ObservableCollection <CharacterAttrib>
            {
                _objCharacter.BOD,
                _objCharacter.AGI,
                _objCharacter.REA,
                _objCharacter.STR,
                _objCharacter.CHA,
                _objCharacter.INT,
                _objCharacter.LOG,
                _objCharacter.WIL,
                _objCharacter.EDG
            };
            if (_objCharacter.MAGEnabled)
            {
                Attributes.Add(_objCharacter.MAG);
                if (_objCharacter.Options.MysAdeptSecondMAGAttribute && _objCharacter.IsMysticAdept)
                {
                    Attributes.Add(_objCharacter.MAGAdept);
                }
            }
            if (_objCharacter.RESEnabled)
            {
                Attributes.Add(_objCharacter.RES);
            }
            if (_objCharacter.DEPEnabled)
            {
                Attributes.Add(_objCharacter.DEP);
            }
            ResetBindings();
            _objCharacter.RefreshAttributeBindings();
            Timekeeper.Finish("create_char_attrib");
        }
        public void Load(XmlDocument xmlDoc)
        {
            Timekeeper.Start("load_char_attrib");
            AttributeList.Clear();
            SpecialAttributeList.Clear();
            XmlDocument    objXmlDocument = XmlManager.Load(_character.IsCritter ? "critters.xml" : "metatypes.xml");
            XPathNavigator nav            = objXmlDocument.CreateNavigator();
            XmlNode        objCharNode    = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _character.Metatype + "\"]/metavariants/metavariant[name = \"" + _character.Metavariant + "\"]")
                                            ?? objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _character.Metatype + "\"]");
            XmlNode objCharNodeAnimalForm = null;

            // We only want to remake attributes for shifters in career mode, because they only get their second set of attributes when exporting from create mode into career mode
            if (_character.MetatypeCategory == "Shapeshifter" && _character.Created)
            {
                objCharNodeAnimalForm = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _character.Metatype + "\"]");
            }
            foreach (string s in AttributeStrings)
            {
                XmlNodeList attNodeList = xmlDoc.SelectNodes("/character/attributes/attribute[name = \"" + s + "\"]");
                // Couldn't find the appopriate attribute in the loaded file, so regenerate it from scratch.
                if (attNodeList.Count == 0)
                {
                    CharacterAttrib att = new CharacterAttrib(_character, s);
                    att = RemakeAttribute(att, objCharNode, nav);
                    switch (att.ConvertToAttributeCategory(att.Abbrev))
                    {
                    case CharacterAttrib.AttributeCategory.Special:
                        SpecialAttributeList.Add(att);
                        break;

                    case CharacterAttrib.AttributeCategory.Standard:
                        AttributeList.Add(att);
                        break;
                    }
                    if (objCharNodeAnimalForm != null)
                    {
                        att = new CharacterAttrib(_character, s, CharacterAttrib.AttributeCategory.Shapeshifter);
                        att = RemakeAttribute(att, objCharNodeAnimalForm, nav);
                        switch (att.ConvertToAttributeCategory(att.Abbrev))
                        {
                        case CharacterAttrib.AttributeCategory.Special:
                            SpecialAttributeList.Add(att);
                            break;

                        case CharacterAttrib.AttributeCategory.Standard:
                            AttributeList.Add(att);
                            break;
                        }
                    }
                }
                else
                {
                    foreach (XmlNode attNode in attNodeList)
                    {
                        CharacterAttrib att = new CharacterAttrib(_character, s);
                        att.Load(attNode);
                        switch (att.ConvertToAttributeCategory(att.Abbrev))
                        {
                        case CharacterAttrib.AttributeCategory.Special:
                            SpecialAttributeList.Add(att);
                            break;

                        case CharacterAttrib.AttributeCategory.Standard:
                            AttributeList.Add(att);
                            break;
                        }
                    }
                }
            }
            ResetBindings();
            Timekeeper.Finish("load_char_attrib");
        }
        public void Load(XmlNode xmlSavedCharacterNode)
        {
            Timekeeper.Start("load_char_attrib");
            foreach (CharacterAttrib objAttribute in AttributeList.Concat(SpecialAttributeList))
            {
                objAttribute.UnbindAttribute();
            }
            AttributeList.Clear();
            SpecialAttributeList.Clear();
            XmlDocument objXmlDocument  = XmlManager.Load(_objCharacter.IsCritter ? "critters.xml" : "metatypes.xml");
            XmlNode     xmlMetatypeNode = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _objCharacter.Metatype + "\"]");
            XmlNode     xmlCharNode     = xmlMetatypeNode?.SelectSingleNode("metavariants/metavariant[name = \"" + _objCharacter.Metavariant + "\"]") ?? xmlMetatypeNode;
            // We only want to remake attributes for shifters in career mode, because they only get their second set of attributes when exporting from create mode into career mode
            XmlNode xmlCharNodeAnimalForm = _objCharacter.MetatypeCategory == "Shapeshifter" && _objCharacter.Created ? xmlMetatypeNode : null;

            foreach (string strAttribute in AttributeStrings)
            {
                XmlNodeList lstAttributeNodes = xmlSavedCharacterNode.SelectNodes("attributes/attribute[name = \"" + strAttribute + "\"]");
                // Couldn't find the appopriate attribute in the loaded file, so regenerate it from scratch.
                if (lstAttributeNodes == null || lstAttributeNodes.Count == 0)
                {
                    CharacterAttrib objAttribute = new CharacterAttrib(_objCharacter, strAttribute);
                    objAttribute = RemakeAttribute(objAttribute, xmlCharNode);
                    switch (CharacterAttrib.ConvertToAttributeCategory(objAttribute.Abbrev))
                    {
                    case CharacterAttrib.AttributeCategory.Special:
                        SpecialAttributeList.Add(objAttribute);
                        break;

                    case CharacterAttrib.AttributeCategory.Standard:
                        AttributeList.Add(objAttribute);
                        break;
                    }
                    if (xmlCharNodeAnimalForm != null)
                    {
                        objAttribute = new CharacterAttrib(_objCharacter, strAttribute, CharacterAttrib.AttributeCategory.Shapeshifter);
                        objAttribute = RemakeAttribute(objAttribute, xmlCharNodeAnimalForm);
                        switch (CharacterAttrib.ConvertToAttributeCategory(objAttribute.Abbrev))
                        {
                        case CharacterAttrib.AttributeCategory.Special:
                            SpecialAttributeList.Add(objAttribute);
                            break;

                        case CharacterAttrib.AttributeCategory.Standard:
                            AttributeList.Add(objAttribute);
                            break;
                        }
                    }
                }
                else
                {
                    foreach (XmlNode xmlAttributeNode in lstAttributeNodes)
                    {
                        CharacterAttrib att = new CharacterAttrib(_objCharacter, strAttribute);
                        att.Load(xmlAttributeNode);
                        switch (CharacterAttrib.ConvertToAttributeCategory(att.Abbrev))
                        {
                        case CharacterAttrib.AttributeCategory.Special:
                            SpecialAttributeList.Add(att);
                            break;

                        case CharacterAttrib.AttributeCategory.Standard:
                            AttributeList.Add(att);
                            break;
                        }
                    }
                }
            }
            ResetBindings();
            Timekeeper.Finish("load_char_attrib");
        }