Example #1
0
 private void UpdateAgentState(
     MPConditionalEffect.ConditionalEffectContainer container,
     Agent agent,
     bool state)
 {
     if (container.GetState(this, agent) == state)
     {
         return;
     }
     container.SetState(this, agent, state);
     foreach (MPPerkEffectBase effect in (IEnumerable <MPPerkEffectBase>) this.Effects)
     {
         effect.OnUpdate(agent, state);
     }
 }
 public MPPerkObject(
     MissionPeer peer,
     string name,
     string description,
     List <string> gameModes,
     int perkListIndex,
     string iconId,
     IEnumerable <MPConditionalEffect> conditionalEffects,
     IEnumerable <MPPerkEffectBase> effects,
     string heroIdleAnimOverride,
     string heroMountIdleAnimOverride,
     string troopIdleAnimOverride,
     string troopMountIdleAnimOverride)
 {
     this._peer                      = peer;
     this._name                      = name;
     this._description               = description;
     this.GameModes                  = gameModes;
     this.PerkListIndex              = perkListIndex;
     this.IconId                     = iconId;
     this._conditionalEffects        = new MPConditionalEffect.ConditionalEffectContainer(conditionalEffects);
     this._effects                   = new List <MPPerkEffectBase>(effects);
     this.HeroIdleAnimOverride       = heroIdleAnimOverride;
     this.HeroMountIdleAnimOverride  = heroMountIdleAnimOverride;
     this.TroopIdleAnimOverride      = troopIdleAnimOverride;
     this.TroopMountIdleAnimOverride = troopMountIdleAnimOverride;
     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;
             }
         }
     }
 }
Example #3
0
        public void OnEvent(
            Agent agent,
            MPConditionalEffect.ConditionalEffectContainer container)
        {
            if (agent == null)
            {
                return;
            }
            bool state = true;

            foreach (MPPerkCondition condition in (IEnumerable <MPPerkCondition>) this.Conditions)
            {
                if (!condition.Check(agent))
                {
                    state = false;
                    break;
                }
            }
            this.UpdateAgentState(container, agent, state);
        }
Example #4
0
        public void OnEvent(
            MissionPeer peer,
            MPConditionalEffect.ConditionalEffectContainer container)
        {
            if (MultiplayerOptions.OptionType.NumberOfBotsPerFormation.GetIntValue() <= 0)
            {
                if (peer == null)
                {
                    return;
                }
                bool?nullable = peer.ControlledAgent?.IsActive();
                bool flag     = true;
                if (!(nullable.GetValueOrDefault() == flag & nullable.HasValue))
                {
                    return;
                }
            }
            bool flag1 = true;

            foreach (MPPerkCondition condition in (IEnumerable <MPPerkCondition>) this.Conditions)
            {
                if (condition.IsPeerCondition && !condition.Check(peer))
                {
                    flag1 = false;
                    break;
                }
            }
            if (!flag1)
            {
                if (MultiplayerOptions.OptionType.NumberOfBotsPerFormation.GetIntValue() > 0)
                {
                    List <IFormationUnit> allUnits = peer?.ControlledFormation?.arrangement.GetAllUnits();
                    if (allUnits == null)
                    {
                        return;
                    }
                    foreach (IFormationUnit formationUnit in allUnits)
                    {
                        if (formationUnit is Agent agent7 && agent7.IsActive())
                        {
                            this.UpdateAgentState(container, agent7, false);
                        }
                    }
                }
                else
                {
                    this.UpdateAgentState(container, peer.ControlledAgent, false);
                }
            }
            else if (MultiplayerOptions.OptionType.NumberOfBotsPerFormation.GetIntValue() > 0)
            {
                List <IFormationUnit> allUnits = peer?.ControlledFormation?.arrangement.GetAllUnits();
                if (allUnits == null)
                {
                    return;
                }
                foreach (IFormationUnit formationUnit in allUnits)
                {
                    if (formationUnit is Agent agent8 && agent8.IsActive())
                    {
                        bool state = true;
                        foreach (MPPerkCondition condition in (IEnumerable <MPPerkCondition>) this.Conditions)
                        {
                            if (!condition.IsPeerCondition && !condition.Check(agent8))
                            {
                                state = false;
                                break;
                            }
                        }
                        this.UpdateAgentState(container, agent8, state);
                    }
                }
            }
            else
            {
                bool state = true;
                foreach (MPPerkCondition condition in (IEnumerable <MPPerkCondition>) this.Conditions)
                {
                    if (!condition.IsPeerCondition && !condition.Check(peer.ControlledAgent))
                    {
                        state = false;
                        break;
                    }
                }
                this.UpdateAgentState(container, peer.ControlledAgent, state);
            }
        }
        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;
                    }
                }
            }
        }