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; }
private MPPerkObject(XmlNode node) { this._peer = (MissionPeer)null; this._conditionalEffects = new MPConditionalEffect.ConditionalEffectContainer(); this._effects = new List <MPPerkEffectBase>(); this._name = node.Attributes["name"].Value; this._description = node.Attributes["description"].Value; this.GameModes = new List <string>((IEnumerable <string>)node.Attributes["game_mode"].Value.Split(',')); for (int index = 0; index < this.GameModes.Count; ++index) { this.GameModes[index] = this.GameModes[index].Trim(); } this.IconId = node.Attributes["icon"].Value; this.PerkListIndex = 0; XmlNode attribute = (XmlNode)node.Attributes["perk_list"]; if (attribute != null) { this.PerkListIndex = Convert.ToInt32(attribute.Value); this.PerkListIndex = this.PerkListIndex - 1; } foreach (XmlNode childNode in node.ChildNodes) { if (childNode.NodeType != XmlNodeType.Comment && childNode.NodeType != XmlNodeType.SignificantWhitespace) { if (childNode.Name == "ConditionalEffect") { this._conditionalEffects.Add(new MPConditionalEffect(this.GameModes, childNode)); } else if (childNode.Name == "Effect") { this._effects.Add((MPPerkEffectBase)MPPerkEffect.CreateFrom(childNode)); } else if (childNode.Name == "OnSpawnEffect") { this._effects.Add((MPPerkEffectBase)MPOnSpawnPerkEffect.CreateFrom(childNode)); } else if (childNode.Name == "RandomOnSpawnEffect") { this._effects.Add((MPPerkEffectBase)MPRandomOnSpawnPerkEffect.CreateFrom(childNode)); } } } this.HeroIdleAnimOverride = node.Attributes["hero_idle_anim"]?.Value; this.HeroMountIdleAnimOverride = node.Attributes["hero_mount_idle_anim"]?.Value; this.TroopIdleAnimOverride = node.Attributes["troop_idle_anim"]?.Value; this.TroopMountIdleAnimOverride = node.Attributes["troop_mount_idle_anim"]?.Value; this._perkEventFlags = MPPerkCondition.PerkEventFlags.None; foreach (MPConditionalEffect conditionalEffect in (List <MPConditionalEffect>) this._conditionalEffects) { foreach (MPPerkCondition condition in (IEnumerable <MPPerkCondition>)conditionalEffect.Conditions) { this._perkEventFlags |= condition.EventFlags; } } foreach (MPConditionalEffect conditionalEffect in (List <MPConditionalEffect>) this._conditionalEffects) { foreach (MPPerkCondition condition in (IEnumerable <MPPerkCondition>)conditionalEffect.Conditions) { if (condition is BannerBearerCondition) { this.HasBannerBearer = true; } } } }