public static MPOnSpawnPerkEffect CreateFrom(XmlNode node) { string key = node?.Attributes?["type"]?.Value; MPOnSpawnPerkEffect instance = (MPOnSpawnPerkEffect)Activator.CreateInstance(MPOnSpawnPerkEffect.Registered[key], BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, (Binder)null, (object[])null, CultureInfo.InvariantCulture); instance.Deserialize(node); return(instance); }
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; } } } }