// XML
        private AbilityCondition ConstructCondition(CharacterTalent characterTalent, XElement conditionElement, bool errorMessages = true)
        {
            AbilityCondition newCondition = null;

            Type   conditionType;
            string type = conditionElement.Name.ToString().ToLowerInvariant();

            try
            {
                conditionType = Type.GetType("Barotrauma.Abilities." + type + "", false, true);
                if (conditionType == null)
                {
                    if (errorMessages)
                    {
                        DebugConsole.ThrowError("Could not find the component \"" + type + "\" (" + characterTalent.DebugIdentifier + ")");
                    }
                    return(null);
                }
            }
            catch (Exception e)
            {
                if (errorMessages)
                {
                    DebugConsole.ThrowError("Could not find the component \"" + type + "\" (" + characterTalent.DebugIdentifier + ")", e);
                }
                return(null);
            }

            object[] args = { characterTalent, conditionElement };

            try
            {
                newCondition = (AbilityCondition)Activator.CreateInstance(conditionType, args);
            }
            catch (TargetInvocationException e)
            {
                DebugConsole.ThrowError("Error while creating an instance of an ability condition of the type " + conditionType + ".", e.InnerException);
                return(null);
            }

            if (newCondition == null)
            {
                DebugConsole.ThrowError("Error while creating an instance of an ability condition of the type " + conditionType + ", instance was null");
                return(null);
            }

            return(newCondition);
        }
        public void LoadConditions(XElement conditionElements)
        {
            foreach (XElement conditionElement in conditionElements.Elements())
            {
                AbilityCondition newCondition = ConstructCondition(CharacterTalent, conditionElement);

                if (newCondition == null)
                {
                    DebugConsole.ThrowError($"AbilityCondition was not found in talent {CharacterTalent.DebugIdentifier}!");
                    return;
                }

                if (!newCondition.AllowClientSimulation && GameMain.NetworkMember != null && GameMain.NetworkMember.IsClient)
                {
                    IsActive = false;
                }

                abilityConditions.Add(newCondition);
            }
        }