コード例 #1
0
 private bool IsThrowingPointAssignable(StonePile.ThrowingPoint throwingPoint, Agent agent = null)
 {
     if (throwingPoint == null || throwingPoint.StandingPoint.IsDeactivated || (throwingPoint.AmmoPickUpPoint != null || throwingPoint.StandingPoint.HasUser) || throwingPoint.StandingPoint.HasAIMovingTo)
     {
         return(false);
     }
     if (agent == null)
     {
         return(true);
     }
     return(StonePileAI.IsAgentAssignable(agent) && !throwingPoint.StandingPoint.IsDisabledForAgent(agent));
 }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        private bool AssignAgentToStandingPoint(StandingPoint standingPoint, Agent agent)
        {
            if (standingPoint == null || agent == null || !StonePileAI.IsAgentAssignable(agent))
            {
                return(false);
            }
            int slotIndex = this.StandingPoints.IndexOf(standingPoint);

            if (slotIndex >= 0)
            {
                ((IDetachment)this).AddAgent(agent, slotIndex);
                if (agent.Formation != null)
                {
                    agent.Formation.DetachUnit(agent, this.IsLoose);
                    agent.Detachment       = (IDetachment)this;
                    agent.DetachmentWeight = this.GetWeightOfStandingPoint(standingPoint);
                    return(true);
                }
            }
            return(false);
        }
コード例 #5
0
        float?IDetachment.GetWeightOfAgentAtNextSlot(
            IEnumerable <Agent> candidates,
            out Agent match)
        {
            BattleSideEnum side             = candidates.First <Agent>().Team.Side;
            StandingPoint  standingPointFor = this.GetSuitableStandingPointFor(side, (Agent)null, candidates, (IEnumerable <AgentValuePair <float> >)null);

            if (standingPointFor != null)
            {
                match = StonePileAI.GetSuitableAgentForStandingPoint(this, standingPointFor, candidates, new List <Agent>());
                if (match == null)
                {
                    return(new float?());
                }
                float?weightOfNextSlot = ((IDetachment)this).GetWeightOfNextSlot(side);
                float num = 1f;
                return(!weightOfNextSlot.HasValue ? new float?() : new float?(weightOfNextSlot.GetValueOrDefault() * num));
            }
            match = (Agent)null;
            return(new float?());
        }