Пример #1
0
        public MPConditionalEffect(List <string> gameModes, XmlNode node)
        {
            List <MPPerkCondition>  mpPerkConditionList  = new List <MPPerkCondition>();
            List <MPPerkEffectBase> mpPerkEffectBaseList = new List <MPPerkEffectBase>();

            foreach (XmlNode childNode1 in node.ChildNodes)
            {
                if (childNode1.Name == nameof(Conditions))
                {
                    foreach (XmlNode childNode2 in childNode1.ChildNodes)
                    {
                        if (childNode2.NodeType != XmlNodeType.Comment && childNode2.NodeType != XmlNodeType.SignificantWhitespace)
                        {
                            mpPerkConditionList.Add(MPPerkCondition.CreateFrom(gameModes, childNode2));
                        }
                    }
                }
                else if (childNode1.Name == nameof(Effects))
                {
                    foreach (XmlNode childNode2 in childNode1.ChildNodes)
                    {
                        if (childNode2.NodeType != XmlNodeType.Comment && childNode2.NodeType != XmlNodeType.SignificantWhitespace)
                        {
                            MPPerkEffect from = MPPerkEffect.CreateFrom(childNode2);
                            mpPerkEffectBaseList.Add((MPPerkEffectBase)from);
                        }
                    }
                }
            }
            this.Conditions = (IReadOnlyList <MPPerkCondition>)mpPerkConditionList;
            this.Effects    = (IReadOnlyList <MPPerkEffectBase>)mpPerkEffectBaseList;
        }
        public static MPPerkCondition CreateFrom(List <string> gameModes, XmlNode node)
        {
            string          key      = node?.Attributes?["type"]?.Value;
            MPPerkCondition instance = (MPPerkCondition)Activator.CreateInstance(MPPerkCondition.Registered[key], BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, (Binder)null, (object[])null, CultureInfo.InvariantCulture);

            instance.Deserialize(node);
            return(instance);
        }