コード例 #1
0
        private void Team_OnFormationsChanged(Team arg1, Formation arg2)
        {
            float time = MBCommon.TimeType.Mission.GetTime();

            foreach (IDetachment detachment in arg2.Detachments)
            {
                if (this.data.ContainsKey(detachment))
                {
                    DetachmentData detachmentData = this.data[detachment];
                    detachmentData.agentScores.Clear();
                    detachmentData.firstTime = time;
                }
                else
                {
                    if (!this._detachments.Contains(detachment))
                    {
                        this.MakeDetachment(detachment);
                    }
                    else
                    {
                        this.data[detachment] = new DetachmentData();
                    }
                    DetachmentData detachmentData = this.data[detachment];
                    detachmentData.agentScores.Clear();
                    detachmentData.firstTime = time;
                }
            }
        }
コード例 #2
0
        internal void OnFormationJoinDetachment(Formation formation, IDetachment detachment)
        {
            DetachmentData detachmentData = this.data[detachment];

            detachmentData.joinedFormations.Add(formation);
            detachmentData.firstTime = MBCommon.TimeType.Mission.GetTime();
        }
コード例 #3
0
        internal void OnFormationLeaveDetachment(Formation formation, IDetachment detachment)
        {
            DetachmentData detachmentData = this.data[detachment];

            detachmentData.joinedFormations.Remove(formation);
            detachmentData.agentScores.RemoveAll((Predicate <AgentValuePair <float[]> >)(ags => ags.Agent.Formation == formation));
            detachmentData.firstTime = MBCommon.TimeType.Mission.GetTime();
        }
コード例 #4
0
 internal void TickAgent(Agent agent)
 {
     if (!agent.IsDetachedFromFormation)
     {
         float time = MBCommon.TimeType.Mission.GetTime();
         bool  flag = (double)time - (double)agent.LastDetachmentTickAgentTime > 1.5;
         foreach (IDetachment detachment in agent.Formation.Detachments)
         {
             if ((double)detachment.GetDetachmentWeight(agent.Formation.Team.Side) > -3.40282346638529E+38)
             {
                 DetachmentData           detachmentData = this.data[detachment];
                 AgentValuePair <float[]> agentValuePair = (AgentValuePair <float[]>)null;
                 for (int index = 0; index < detachmentData.agentScores.Count; ++index)
                 {
                     if (detachmentData.agentScores[index].Agent == agent)
                     {
                         agentValuePair = detachmentData.agentScores[index];
                         break;
                     }
                 }
                 if (agentValuePair == null)
                 {
                     if (detachmentData.agentScores.Count == 0)
                     {
                         detachmentData.firstTime = time;
                     }
                     float[] templateCostsOfAgent = detachment.GetTemplateCostsOfAgent(agent, (float[])null);
                     detachmentData.agentScores.Add(new AgentValuePair <float[]>(agent, templateCostsOfAgent));
                     agent.LastDetachmentTickAgentTime = time;
                 }
                 else if (flag)
                 {
                     agentValuePair.Value = detachment.GetTemplateCostsOfAgent(agent, agentValuePair.Value);
                     agent.LastDetachmentTickAgentTime = time;
                 }
             }
             else
             {
                 this.data[detachment].firstTime = time;
             }
         }
     }
     else
     {
         if (agent.Detachment == null || agent.Detachment.IsAgentEligible(agent))
         {
             return;
         }
         agent.Detachment.RemoveAgent(agent);
         agent.Formation?.AttachUnit(agent);
     }
 }