public static Agent GetSuitableAgentForStandingPoint(
            StonePile usableMachine,
            StandingPoint standingPoint,
            IEnumerable <Agent> agents,
            List <Agent> usedAgents)
        {
            float num    = float.MinValue;
            Agent agent1 = (Agent)null;

            foreach (Agent agent2 in agents)
            {
                if (StonePileAI.IsAgentAssignable(agent2) && !standingPoint.IsDisabledForAgent(agent2) && (double)standingPoint.GetUsageScoreForAgent(agent2) > (double)num)
                {
                    num    = standingPoint.GetUsageScoreForAgent(agent2);
                    agent1 = agent2;
                }
            }
            return(agent1);
        }
        public static Agent GetSuitableAgentForStandingPoint(
            StonePile stonePile,
            StandingPoint standingPoint,
            IEnumerable <AgentValuePair <float> > agents,
            List <Agent> usedAgents,
            float weight)
        {
            float num    = float.MinValue;
            Agent agent1 = (Agent)null;

            foreach (AgentValuePair <float> agent2 in agents)
            {
                Agent agent3 = agent2.Agent;
                if (StonePileAI.IsAgentAssignable(agent3) && !standingPoint.IsDisabledForAgent(agent3) && (double)standingPoint.GetUsageScoreForAgent(agent3) > (double)num)
                {
                    num    = standingPoint.GetUsageScoreForAgent(agent3);
                    agent1 = agent3;
                }
            }
            return(agent1);
        }
        public static Agent GetSuitableAgentForStandingPoint(
            UsableMachine usableMachine,
            StandingPoint standingPoint,
            IEnumerable <Agent> agents,
            List <Agent> usedAgents)
        {
            if (usableMachine.AmmoPickUpPoints.Contains(standingPoint) && usableMachine.StandingPoints.Any <StandingPoint>((Func <StandingPoint, bool>)(standingPoint2 => (standingPoint2.IsDeactivated || standingPoint2.HasUser || standingPoint2.HasAIMovingTo) && !standingPoint2.GameEntity.HasTag(usableMachine.AmmoPickUpTag) && standingPoint2 is StandingPointWithWeaponRequirement)))
            {
                return((Agent)null);
            }
            IEnumerable <Agent> source = agents.Where <Agent>((Func <Agent, bool>)(a =>
            {
                if (usedAgents.Contains(a) || !a.IsAIControlled || (!a.IsActive() || a.IsRunningAway) || (a.AIUseGameObjectIsEnabled() || a.AIMoveToGameObjectIsEnabled() || standingPoint.IsDisabledForAgent(a)))
                {
                    return(false);
                }
                return(a.Formation == null || !a.Formation.IsUnitDetached(a));
            }));

            return(!source.Any <Agent>() ? (Agent)null : source.MaxBy <Agent, float>((Func <Agent, float>)(a => standingPoint.GetUsageScoreForAgent(a))));
        }
        public static Agent GetSuitableAgentForStandingPoint(
            UsableMachine usableMachine,
            StandingPoint standingPoint,
            IEnumerable <AgentValuePair <float> > agents,
            List <Agent> usedAgents,
            float weight)
        {
            if (usableMachine.IsStandingPointNotUsedOnAccountOfBeingAmmoLoad(standingPoint))
            {
                return((Agent)null);
            }
            IEnumerable <AgentValuePair <float> > source = agents.Where <AgentValuePair <float> >((Func <AgentValuePair <float>, bool>)(ap =>
            {
                Agent agent = ap.Agent;
                if (usedAgents.Contains(agent) || !agent.IsAIControlled || (!agent.IsActive() || agent.IsRunningAway) || (agent.AIUseGameObjectIsEnabled() || agent.AIMoveToGameObjectIsEnabled() || standingPoint.IsDisabledForAgent(agent)))
                {
                    return(false);
                }
                return(agent.Formation == null || !agent.Formation.IsUnitDetached(agent) || (double)agent.DetachmentWeight * 0.400000005960464 > (double)weight);
            }));

            return(!source.Any <AgentValuePair <float> >() ? (Agent)null : source.MaxBy <AgentValuePair <float>, float>((Func <AgentValuePair <float>, float>)(a => standingPoint.GetUsageScoreForAgent(a))).Agent);
        }
Beispiel #5
0
        protected override StandingPoint GetSuitableStandingPointFor(
            BattleSideEnum side,
            Agent agent = null,
            IEnumerable <Agent> agents = null,
            IEnumerable <AgentValuePair <float> > agentValuePairs = null)
        {
            List <Agent> agentList = new List <Agent>();

            if (agents == null)
            {
                if (agent != null)
                {
                    agentList.Add(agent);
                }
                else if (agentValuePairs != null)
                {
                    foreach (AgentValuePair <float> agentValuePair in agentValuePairs)
                    {
                        agentList.Add(agentValuePair.Agent);
                    }
                }
            }
            else
            {
                agentList = new List <Agent>(agents);
            }
            bool          flag1          = false;
            StandingPoint standingPoint1 = (StandingPoint)null;

            for (int index1 = 0; index1 < this._throwingPoints.Count && standingPoint1 == null; ++index1)
            {
                StonePile.ThrowingPoint throwingPoint = this._throwingPoints[index1];
                if (this.IsThrowingPointAssignable(throwingPoint))
                {
                    bool flag2 = agentList == null;
                    for (int index2 = 0; !flag2 && index2 < agentList.Count; ++index2)
                    {
                        flag2 = !throwingPoint.StandingPoint.IsDisabledForAgent(agentList[index2]);
                    }
                    if (flag2)
                    {
                        if (standingPoint1 == null)
                        {
                            standingPoint1 = (StandingPoint)throwingPoint.StandingPoint;
                        }
                    }
                    else
                    {
                        flag1 = true;
                    }
                }
            }
            for (int index1 = 0; index1 < this.StandingPoints.Count && standingPoint1 == null; ++index1)
            {
                StandingPoint standingPoint2 = this.StandingPoints[index1];
                if (!standingPoint2.IsDeactivated && (standingPoint2.IsInstantUse || !standingPoint2.HasUser && !standingPoint2.HasAIMovingTo) && (!standingPoint2.GameEntity.HasTag(this.ThrowingPointTag) && (flag1 || !standingPoint2.GameEntity.HasTag(this.AmmoPickUpTag))))
                {
                    for (int index2 = 0; index2 < agentList.Count && standingPoint1 == null; ++index2)
                    {
                        if (!standingPoint2.IsDisabledForAgent(agentList[index2]))
                        {
                            standingPoint1 = standingPoint2;
                        }
                    }
                    if (agentList.Count == 0)
                    {
                        standingPoint1 = standingPoint2;
                    }
                }
            }
            return(standingPoint1);
        }