예제 #1
0
 public int CompareTo(GuiDiplomaticTerm other)
 {
     if (this.Type != other.Type)
     {
         return(this.Type.CompareTo(other.Type));
     }
     if ((this.Type == GuiDiplomaticTerm.TermType.Strategic || this.Type == GuiDiplomaticTerm.TermType.Luxury) && this.ResourceGuiElement != null)
     {
         return(this.ResourceGuiElement.Title.CompareTo(other.ResourceGuiElement.Title));
     }
     if (this.Type == GuiDiplomaticTerm.TermType.City)
     {
         DiplomaticTermCityExchange diplomaticTermCityExchange  = this.Term as DiplomaticTermCityExchange;
         DiplomaticTermCityExchange diplomaticTermCityExchange2 = other.Term as DiplomaticTermCityExchange;
         if (diplomaticTermCityExchange != null && diplomaticTermCityExchange2 != null)
         {
             return(diplomaticTermCityExchange.CityGUID.CompareTo(diplomaticTermCityExchange2.CityGUID));
         }
     }
     if (this.Type == GuiDiplomaticTerm.TermType.Fortress)
     {
         DiplomaticTermFortressExchange diplomaticTermFortressExchange  = this.Term as DiplomaticTermFortressExchange;
         DiplomaticTermFortressExchange diplomaticTermFortressExchange2 = other.Term as DiplomaticTermFortressExchange;
         if (diplomaticTermFortressExchange != null && diplomaticTermFortressExchange2 != null)
         {
             return(diplomaticTermFortressExchange.FortressGUID.CompareTo(diplomaticTermFortressExchange2.FortressGUID));
         }
     }
     if (this.Type == GuiDiplomaticTerm.TermType.Technology)
     {
         DiplomaticTermTechnologyExchange diplomaticTermTechnologyExchange  = this.Term as DiplomaticTermTechnologyExchange;
         DiplomaticTermTechnologyExchange diplomaticTermTechnologyExchange2 = other.Term as DiplomaticTermTechnologyExchange;
         int technologyEraNumber  = DepartmentOfScience.GetTechnologyEraNumber(diplomaticTermTechnologyExchange.TechnologyDefinition);
         int technologyEraNumber2 = DepartmentOfScience.GetTechnologyEraNumber(diplomaticTermTechnologyExchange2.TechnologyDefinition);
         if (technologyEraNumber != technologyEraNumber2)
         {
             return(technologyEraNumber.CompareTo(technologyEraNumber2));
         }
     }
     if (this.Type == GuiDiplomaticTerm.TermType.Prisoner)
     {
         DiplomaticTermPrisonerExchange diplomaticTermPrisonerExchange  = this.Term as DiplomaticTermPrisonerExchange;
         DiplomaticTermPrisonerExchange diplomaticTermPrisonerExchange2 = other.Term as DiplomaticTermPrisonerExchange;
         if (diplomaticTermPrisonerExchange != null && diplomaticTermPrisonerExchange2 != null)
         {
             return(diplomaticTermPrisonerExchange.HeroGuid.CompareTo(diplomaticTermPrisonerExchange2.HeroGuid));
         }
     }
     return(this.Term.Definition.Name.CompareTo(other.Term.Definition.Name));
 }
예제 #2
0
    public override bool Equals(DiplomaticTerm other)
    {
        DiplomaticTermCityExchange diplomaticTermCityExchange = other as DiplomaticTermCityExchange;

        return(diplomaticTermCityExchange != null && this.CityGUID == diplomaticTermCityExchange.CityGUID);
    }
예제 #3
0
    public override bool CanApply(IDiplomaticContract diplomaticContract, params string[] flags)
    {
        if (!base.CanApply(diplomaticContract, new string[0]))
        {
            return(false);
        }
        Diagnostics.Assert(base.EmpireWhichProvides != null && base.EmpireWhichReceives != null);
        DepartmentOfTheInterior agency  = base.EmpireWhichProvides.GetAgency <DepartmentOfTheInterior>();
        DepartmentOfTheInterior agency2 = base.EmpireWhichReceives.GetAgency <DepartmentOfTheInterior>();

        Diagnostics.Assert(agency != null && agency2 != null);
        City city = agency.Cities.FirstOrDefault((City match) => match.GUID == this.CityGUID);

        if (city == null)
        {
            return(false);
        }
        if (city.BesiegingEmpire != null)
        {
            return(false);
        }
        if (diplomaticContract.EmpireWhichProposes.Index != base.EmpireWhichProvides.Index)
        {
            IGameService service = Services.GetService <IGameService>();
            Diagnostics.Assert(service != null);
            IVisibilityService service2 = service.Game.Services.GetService <IVisibilityService>();
            Diagnostics.Assert(service2 != null);
            District cityCenter = city.GetCityCenter();
            if (cityCenter == null || !service2.IsWorldPositionExploredFor(cityCenter.WorldPosition, base.EmpireWhichReceives))
            {
                return(false);
            }
        }
        if (base.Definition.Name == DiplomaticTermCityExchange.MimicsCityDeal)
        {
            if (agency.MainCity == city)
            {
                return(false);
            }
            if (base.EmpireWhichProvides.Faction.Affinity.Name == base.EmpireWhichReceives.Faction.Affinity.Name)
            {
                return(false);
            }
            if (city.IsInfected)
            {
                return(false);
            }
            if (base.EmpireWhichReceives.GetAgency <DepartmentOfPlanificationAndDevelopment>().HasIntegratedFaction(base.EmpireWhichProvides.Faction))
            {
                return(false);
            }
            if (agency2.InfectedCities.Any((City c) => c.LastNonInfectedOwner != null && (c.LastNonInfectedOwner == base.EmpireWhichProvides || c.LastNonInfectedOwner.Faction == base.EmpireWhichProvides.Faction)))
            {
                return(false);
            }
        }
        int num  = agency.Cities.Count;
        int num2 = agency2.Cities.Count;

        for (int i = 0; i < diplomaticContract.Terms.Count; i++)
        {
            DiplomaticTermCityExchange diplomaticTermCityExchange = diplomaticContract.Terms[i] as DiplomaticTermCityExchange;
            if (diplomaticTermCityExchange != null && !(diplomaticTermCityExchange.CityGUID == this.CityGUID))
            {
                if (base.Definition.Name == DiplomaticTermCityExchange.MimicsCityDeal)
                {
                    return(false);
                }
                if (diplomaticTermCityExchange.EmpireWhichProvides.Index == base.EmpireWhichProvides.Index)
                {
                    num--;
                    num2++;
                }
                else if (diplomaticTermCityExchange.EmpireWhichProvides.Index == base.EmpireWhichReceives.Index)
                {
                    num2--;
                    num++;
                }
                else
                {
                    Diagnostics.LogError("Can't identify the empire which provides the term {0}.", new object[]
                    {
                        diplomaticTermCityExchange
                    });
                }
            }
        }
        num--;
        num2++;
        return(num >= 1 && num2 >= 1);
    }