Пример #1
0
	public void UnconvertAndPacifyAllConvertedVillages()
	{
		for (int i = this.ConvertedVillages.Count - 1; i >= 0; i--)
		{
			Village village = this.ConvertedVillages[i];
			if (village != null && village.Region != null)
			{
				BarbarianCouncil agency = village.Region.MinorEmpire.GetAgency<BarbarianCouncil>();
				if (agency != null)
				{
					agency.PacifyVillage(village, null);
				}
				DepartmentOfTheInterior agency2 = base.GetAgency<DepartmentOfTheInterior>();
				Diagnostics.Assert(agency2 != null);
				if (village.Region.City != null && agency2 != null && agency2.MainCity != village.Region.City)
				{
					DepartmentOfTheInterior agency3 = village.Region.City.Empire.GetAgency<DepartmentOfTheInterior>();
					Diagnostics.Assert(agency3 != null);
					agency3.BindMinorFactionToCity(village.Region.City, village.Region.MinorEmpire);
					agency3.VerifyOverallPopulation(village.Region.City);
				}
				else
				{
					agency2.UnbindConvertedVillage(village);
				}
			}
		}
	}
Пример #2
0
 private void BindMinorFactionToCity()
 {
     if (this.MinorEmpire.Region.City != null)
     {
         DepartmentOfTheInterior agency = this.MinorEmpire.Region.City.Empire.GetAgency <DepartmentOfTheInterior>();
         agency.BindMinorFactionToCity(this.MinorEmpire.Region.City, this.MinorEmpire);
         agency.VerifyOverallPopulation(this.MinorEmpire.Region.City);
     }
 }
Пример #3
0
 private void UpdatePillageRecovery(PointOfInterest pointOfInterest)
 {
     if (pointOfInterest.ArmyPillaging.IsValid)
     {
         return;
     }
     if (pointOfInterest.SimulationObject.Tags.Contains(DepartmentOfDefense.PillageStatusDescriptor))
     {
         float num           = pointOfInterest.GetPropertyValue(SimulationProperties.PillageCooldown);
         float propertyValue = pointOfInterest.GetPropertyValue(SimulationProperties.MaximumPillageCooldown);
         num += 1f;
         pointOfInterest.SetPropertyBaseValue(SimulationProperties.PillageCooldown, num);
         if (num >= propertyValue || pointOfInterest.Empire == null)
         {
             float propertyValue2 = pointOfInterest.GetPropertyValue(SimulationProperties.MaximumPillageDefense);
             pointOfInterest.SetPropertyBaseValue(SimulationProperties.PillageDefense, propertyValue2);
             if (!pointOfInterest.RemoveDescriptorByName(DepartmentOfDefense.PillageStatusDescriptor))
             {
                 pointOfInterest.SimulationObject.Tags.RemoveTag(DepartmentOfDefense.PillageStatusDescriptor);
             }
             if (pointOfInterest.Region.City != null)
             {
                 DepartmentOfTheInterior agency = pointOfInterest.Region.City.Empire.GetAgency <DepartmentOfTheInterior>();
                 agency.VerifyOverallPopulation(pointOfInterest.Region.City);
                 agency.BindMinorFactionToCity(pointOfInterest.Region.City, pointOfInterest.Region.MinorEmpire);
                 pointOfInterest.Region.City.Empire.Refresh(false);
             }
             pointOfInterest.LineOfSightDirty = true;
         }
     }
     else
     {
         float num2           = pointOfInterest.GetPropertyValue(SimulationProperties.PillageDefense);
         float propertyValue3 = pointOfInterest.GetPropertyValue(SimulationProperties.PillageDefenseRecovery);
         float propertyValue4 = pointOfInterest.GetPropertyValue(SimulationProperties.MaximumPillageDefense);
         num2 += propertyValue3;
         pointOfInterest.SetPropertyBaseValue(SimulationProperties.PillageDefense, Mathf.Min(propertyValue4, num2));
     }
 }
Пример #4
0
    public void CleanVillageAfterEncounter(Village village, Encounter encounter)
    {
        Diagnostics.Assert(this.villages.Contains(village));
        DepartmentOfDefense agency = base.Empire.GetAgency <DepartmentOfDefense>();

        Diagnostics.Assert(agency != null);
        agency.UpdateLifeAfterEncounter(village);
        agency.CleanGarrisonAfterEncounter(village);
        bool flag = true;

        foreach (Contender contender in encounter.GetAlliedContendersFromEmpire(village.Empire))
        {
            if (contender.IsTakingPartInBattle && contender.ContenderState != ContenderState.Defeated)
            {
                flag = false;
            }
        }
        if (village.Units.Count <Unit>() == 0 && flag)
        {
            if (village.PointOfInterest != null)
            {
                village.PointOfInterest.RemovePointOfInterestImprovement();
            }
            for (int i = 0; i < encounter.Empires.Count; i++)
            {
                if (encounter.Empires[i].Index != this.MinorEmpire.Index)
                {
                    this.EventService.Notify(new EventVillageDestroyed(encounter.Empires[i], village));
                }
            }
            List <global::Empire> list = new List <global::Empire>(encounter.Empires);
            list.Remove(this.MinorEmpire);
            MajorEmpire converter = village.Converter;
            this.PacifyVillage(village, list);
            this.BindMinorFactionToCity();
            if (converter != null)
            {
                if (village.Region.City != null)
                {
                    if (village.Region.City.Empire.Index == converter.Index)
                    {
                        DepartmentOfTheInterior agency2 = converter.GetAgency <DepartmentOfTheInterior>();
                        Diagnostics.Assert(agency2 != null);
                        if (agency2.MainCity != null)
                        {
                            agency2.BindMinorFactionToCity(agency2.MainCity, this.MinorEmpire);
                        }
                    }
                    else
                    {
                        DepartmentOfTheInterior agency3 = converter.GetAgency <DepartmentOfTheInterior>();
                        Diagnostics.Assert(agency3 != null);
                        agency3.UnbindConvertedVillage(village);
                    }
                }
                else
                {
                    DepartmentOfTheInterior agency4 = converter.GetAgency <DepartmentOfTheInterior>();
                    Diagnostics.Assert(agency4 != null);
                    agency4.UnbindConvertedVillage(village);
                }
            }
        }
        village.Refresh(false);
    }