Пример #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));
 }
        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);
        }
Пример #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);
        }