internal void OnFormationJoinDetachment(Formation formation, IDetachment detachment)
        {
            DetachmentData detachmentData = this.data[detachment];

            detachmentData.joinedFormations.Add(formation);
            detachmentData.firstTime = MBCommon.TimeType.Mission.GetTime();
        }
        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();
        }
 internal void DestroyDetachment(IDetachment detachment)
 {
     foreach (Formation formation in this.data[detachment].joinedFormations.ToList <Formation>())
     {
         formation.LeaveDetachment(detachment);
     }
     this._detachments.Remove(detachment);
     this.data.Remove(detachment);
 }
 private void AssertDetachments()
 {
     foreach (IDetachment detachment1 in this._detachments)
     {
         IDetachment detachment = detachment1;
         foreach (Agent agent1 in detachment.Agents)
         {
             Agent agent = agent1;
             this._detachments.Count <IDetachment>((Func <IDetachment, bool>)(d => d.Agents.Contains <Agent>(agent)));
         }
         IEnumerable <Agent> source = this.data[detachment].agentScores.Select <AgentValuePair <float[]>, Agent>((Func <AgentValuePair <float[]>, Agent>)(asc => asc.Agent));
         source.Count <Agent>((Func <Agent, bool>)(a => a.Team != this.team));
         source.FirstOrDefault <Agent>((Func <Agent, bool>)(a => a.Team != this.team));
         source.FirstOrDefault <Agent>((Func <Agent, bool>)(a => a.Formation != null && !a.Formation.Detachments.Contains(detachment)));
         source.Count <Agent>((Func <Agent, bool>)(a => a.Formation != null && !a.Formation.Detachments.Contains(detachment)));
     }
 }
예제 #5
0
        public static bool LeaveDetachment_Prefix(
            Formation __instance,
            List <IDetachment> ____detachments,
            IDetachment detachment)
        {
            foreach (Agent agent in detachment.Agents.Where(a => a.Formation == __instance && a.IsAIControlled).ToList())
            {
                detachment.RemoveAgent(agent);
                AttachUnit?.Invoke(__instance, new object[] { agent });
            }

            ____detachments.Remove(detachment);
            var detachmentManager = (DetachmentManager)DetachmentManager?.GetValue(__instance.Team);

            OnFormationLeaveDetachment?.Invoke(detachmentManager, new object[2]
            {
                __instance,
                detachment
            });
            return(false);
        }
 internal void MakeDetachment(IDetachment detachment)
 {
     this._detachments.Add(detachment);
     this.data[detachment] = new DetachmentData();
 }
 internal void AssertDetachment(Team team, IDetachment detachment)
 {
     this.data[detachment].joinedFormations.Where <Formation>((Func <Formation, bool>)(f => f.CountOfUnits > 0));
     team.FormationsIncludingSpecial.Where <Formation>((Func <Formation, bool>)(f => f.Detachments.Contains(detachment)));
 }