Exemplo n.º 1
0
    void IDiplomaticTermManagement.ApplyEffects()
    {
        DiplomaticTermCityExchangeDefinition diplomaticTermCityExchangeDefinition = base.Definition as DiplomaticTermCityExchangeDefinition;

        Diagnostics.Assert(diplomaticTermCityExchangeDefinition != null);
        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 = null;

        for (int i = 0; i < agency.Cities.Count; i++)
        {
            City city2 = agency.Cities[i];
            if (city2.GUID == this.CityGUID)
            {
                city = city2;
                break;
            }
        }
        if (city == null)
        {
            Diagnostics.LogError("DiplomaticTermCityExchange.ApplyEffect failed, can't retrieve the city {0} from the empire which provides the term ({1}).", new object[]
            {
                this.CityGUID,
                base.EmpireWhichProvides
            });
            return;
        }
        IEventService service = Services.GetService <IEventService>();

        if (service == null)
        {
            Diagnostics.LogError("Failed to retrieve the event service.");
            return;
        }
        bool flag  = base.EmpireWhichReceives.SimulationObject.Tags.Contains("FactionTraitCultists9");
        bool flag2 = agency2.Cities.Count >= 1;

        if (flag && flag2)
        {
            IGameService service2 = Services.GetService <IGameService>();
            IPlayerControllerRepositoryService service3 = service2.Game.Services.GetService <IPlayerControllerRepositoryService>();
            IPlayerControllerRepositoryControl playerControllerRepositoryControl = service3 as IPlayerControllerRepositoryControl;
            if (playerControllerRepositoryControl != null)
            {
                global::PlayerController playerControllerById = playerControllerRepositoryControl.GetPlayerControllerById("server");
                if (playerControllerById != null)
                {
                    float propertyValue         = city.GetPropertyValue(SimulationProperties.Population);
                    DepartmentOfScience agency3 = base.EmpireWhichReceives.GetAgency <DepartmentOfScience>();
                    bool flag3 = agency3 != null && agency3.GetTechnologyState("TechnologyDefinitionCultists12") == DepartmentOfScience.ConstructibleElement.State.Researched;
                    int  num   = 0;
                    while ((float)num < propertyValue)
                    {
                        OrderBuyoutAndActivateBooster order = new OrderBuyoutAndActivateBooster(base.EmpireWhichReceives.Index, "BoosterIndustry", 0UL, false);
                        playerControllerById.PostOrder(order);
                        if (flag3)
                        {
                            order = new OrderBuyoutAndActivateBooster(base.EmpireWhichReceives.Index, "BoosterScience", 0UL, false);
                            playerControllerById.PostOrder(order);
                        }
                        num++;
                    }
                    OrderDestroyCity order2 = new OrderDestroyCity(city.Empire.Index, city.GUID, true, true, base.EmpireWhichReceives.Index);
                    playerControllerById.PostOrder(order2);
                    EventCityRazed eventToNotify = new EventCityRazed(city.Empire, city.Region, base.EmpireWhichReceives, false);
                    service.Notify(eventToNotify);
                }
            }
        }
        else
        {
            agency.SwapCityOwner(city, base.EmpireWhichReceives);
            service.Notify(new EventSwapCity(base.EmpireWhichProvides, city, base.EmpireWhichProvides.Index, base.EmpireWhichReceives.Index, false));
            service.Notify(new EventSwapCity(base.EmpireWhichReceives, city, base.EmpireWhichProvides.Index, base.EmpireWhichReceives.Index, false));
        }
    }
Exemplo n.º 2
0
 public DiplomaticTermCityExchange(DiplomaticTermCityExchangeDefinition definition, global::Empire empireWhichProposes, global::Empire empireWhichProvides, global::Empire empireWhichReceives, GameEntityGUID cityGUID) : base(definition, empireWhichProposes, empireWhichProvides, empireWhichReceives)
 {
     this.CityGUID = cityGUID;
 }