public void UpdateSiegeBreakerArmyAssignation(Army army, City city)
 {
     if (city == null || army == null)
     {
         return;
     }
     if (!this.SiegeBreakerArmyAssignations.ContainsKey(city))
     {
         this.SiegeBreakerArmyAssignations.Add(city, new List <AILayer_SiegeBreaker.ArmySupportInfo>());
     }
     AILayer_SiegeBreaker.ArmySupportInfo armySupportInfo = this.SiegeBreakerArmyAssignations[city].FirstOrDefault((AILayer_SiegeBreaker.ArmySupportInfo asu) => asu.Army.GUID == army.GUID);
     if (armySupportInfo == null)
     {
         Predicate <AILayer_SiegeBreaker.ArmySupportInfo> < > 9__1;
         foreach (KeyValuePair <City, List <AILayer_SiegeBreaker.ArmySupportInfo> > keyValuePair in this.SiegeBreakerArmyAssignations)
         {
             List <AILayer_SiegeBreaker.ArmySupportInfo>      value = keyValuePair.Value;
             Predicate <AILayer_SiegeBreaker.ArmySupportInfo> match;
             if ((match = < > 9__1) == null)
             {
                 match = (< > 9__1 = ((AILayer_SiegeBreaker.ArmySupportInfo asu) => asu.Army.GUID == army.GUID));
             }
             int num = value.FindIndex(match);
             if (num >= 0)
             {
                 keyValuePair.Value.RemoveAt(num);
             }
         }
         armySupportInfo = new AILayer_SiegeBreaker.ArmySupportInfo(army);
         this.SiegeBreakerArmyAssignations[city].Add(armySupportInfo);
         this.State = TickableState.NeedTick;
     }
     armySupportInfo.Update();
 }
    public void Tick()
    {
        if (global::Game.Time - this.lastTickTime < 10.0)
        {
            return;
        }
        this.lastTickTime = global::Game.Time;
        this.State        = TickableState.Optional;
        List <City> list = new List <City>();

        foreach (KeyValuePair <City, List <AILayer_SiegeBreaker.ArmySupportInfo> > keyValuePair in this.SiegeBreakerArmyAssignations)
        {
            if (keyValuePair.Key == null || !keyValuePair.Key.GUID.IsValid || keyValuePair.Key.BesiegingEmpireIndex < 0 || keyValuePair.Key.Empire.Index != base.AIEntity.Empire.Index || keyValuePair.Value.Count == 0)
            {
                list.Add(keyValuePair.Key);
            }
            else
            {
                for (int i = 0; i < keyValuePair.Value.Count; i++)
                {
                    AILayer_SiegeBreaker.ArmySupportInfo armySupportInfo = keyValuePair.Value[i];
                    AIData_Army aidata_Army;
                    if (!armySupportInfo.IsValid())
                    {
                        keyValuePair.Value.RemoveAt(i);
                        i--;
                    }
                    else if (!this.aiDataRepositoryHelper.TryGetAIData <AIData_Army>(armySupportInfo.Army.GUID, out aidata_Army) || aidata_Army.CommanderMission == null || aidata_Army.CommanderMission.State == TickableState.NoTick)
                    {
                        keyValuePair.Value.RemoveAt(i);
                        i--;
                    }
                }
            }
        }
        foreach (City key in list)
        {
            this.SiegeBreakerArmyAssignations.Remove(key);
        }
        if (this.SiegeBreakerArmyAssignations.Count == 0)
        {
            this.State = TickableState.NoTick;
        }
    }
 public bool WaitForSupport(Army army, City city, WorldPosition TargetPosition)
 {
     if (!this.SiegeBreakerArmyAssignations.ContainsKey(city))
     {
         return(false);
     }
     AILayer_SiegeBreaker.ArmySupportInfo armySupportInfo = this.SiegeBreakerArmyAssignations[city].FirstOrDefault((AILayer_SiegeBreaker.ArmySupportInfo asu) => asu.Army.GUID == army.GUID);
     if (armySupportInfo == null)
     {
         return(false);
     }
     if (armySupportInfo.LastMP == -1f)
     {
         return(true);
     }
     foreach (AILayer_SiegeBreaker.ArmySupportInfo armySupportInfo2 in this.SiegeBreakerArmyAssignations[city])
     {
         if (armySupportInfo2.IsValid() && armySupportInfo2.Army.GUID != army.GUID && armySupportInfo2.LastMP != armySupportInfo2.CurrentMP && this.worldPositionningService.GetDistance(armySupportInfo2.Army.WorldPosition, TargetPosition) > 3)
         {
             return(true);
         }
     }
     return(false);
 }