Exemple #1
0
    public override void ReadXml(XmlReader reader)
    {
        IGameService service = Services.GetService <IGameService>();

        Diagnostics.Assert(service != null);
        Diagnostics.Assert(service.Game != null);
        global::Game game = service.Game as global::Game;

        Diagnostics.Assert(game != null);
        this.HasBeenPacified = reader.GetAttribute <bool>("HasBeenPacified");
        int num = reader.ReadVersionAttribute();

        if (num >= 2)
        {
            this.HasBeenConvertedByIndex = reader.GetAttribute <int>("HasBeenConvertedByIndex");
            this.ConvertedUnitSpawnTurn  = reader.GetAttribute <int>("ConvertedUnitSpawnTurn");
            this.HasBeenConvertedBy      = null;
        }
        base.ReadXml(reader);
        int num2 = reader.ReadElementString <int>("IndexOfPointOfInterest");

        if (num >= 3)
        {
            int num3 = reader.ReadElementString <int>("IndexOfRegion");
            this.PointOfInterest = game.World.Regions[num3].PointOfInterests[num2];
        }
        else
        {
            MinorEmpire minorEmpire = this.Empire as MinorEmpire;
            Diagnostics.Assert(minorEmpire != null);
            this.PointOfInterest = minorEmpire.Region.PointOfInterests[num2];
        }
    }
Exemple #2
0
    private void ComputeVillageScoring()
    {
        this.villagePOI.Clear();
        DepartmentOfTheInterior agency = this.OtherEmpire.GetAgency <DepartmentOfTheInterior>();

        for (int i = 0; i < agency.Cities.Count; i++)
        {
            MinorEmpire minorEmpire = agency.Cities[i].Region.MinorEmpire;
            if (minorEmpire != null)
            {
                BarbarianCouncil council = minorEmpire.GetAgency <BarbarianCouncil>();
                if (council != null)
                {
                    bool flag = agency.IsAssimilated(minorEmpire.MinorFaction);
                    int  villageIndex2;
                    int  villageIndex;
                    Predicate <DissentTask_Empire.VillageScoring> < > 9__1;
                    for (villageIndex = 0; villageIndex < council.Villages.Count; villageIndex = villageIndex2 + 1)
                    {
                        if (council.Villages[villageIndex].HasBeenPacified && !council.Villages[villageIndex].HasBeenConverted && !council.Villages[villageIndex].HasBeenInfected)
                        {
                            List <DissentTask_Empire.VillageScoring>      list = this.villagePOI;
                            Predicate <DissentTask_Empire.VillageScoring> match2;
                            if ((match2 = < > 9__1) == null)
                            {
                                match2 = (< > 9__1 = ((DissentTask_Empire.VillageScoring match) => match.Village.GUID == council.Villages[villageIndex].GUID));
                            }
                            DissentTask_Empire.VillageScoring villageScoring = list.Find(match2);
                            if (villageScoring == null)
                            {
                                villageScoring = new DissentTask_Empire.VillageScoring(council.Villages[villageIndex]);
                                this.villagePOI.Add(villageScoring);
                            }
                            villageScoring.Reset();
                            if (flag)
                            {
                                villageScoring.Score.Boost(0.2f, "Assimilated", new object[0]);
                            }
                            if (this.visibilityService.IsWorldPositionVisibleFor(villageScoring.Village.WorldPosition, base.Owner))
                            {
                                villageScoring.Score.Boost(0.2f, "Visible", new object[0]);
                            }
                        }
                        villageIndex2 = villageIndex;
                    }
                }
            }
        }
        this.villagePOI.Sort((DissentTask_Empire.VillageScoring left, DissentTask_Empire.VillageScoring right) => - 1 * left.Score.CompareTo(right.Score));
    }
Exemple #3
0
 public bool TryGetMinorEmpireAIEntity(Region region, out AIEntity_MinorEmpire minorEmpire)
 {
     minorEmpire = null;
     if (this.aiPlayerMinorEmpire != null && this.aiPlayerMinorEmpire.AIEntities != null)
     {
         for (int i = 0; i < this.aiPlayerMinorEmpire.AIEntities.Count; i++)
         {
             AIEntity_MinorEmpire aientity_MinorEmpire = this.aiPlayerMinorEmpire.AIEntities[i] as AIEntity_MinorEmpire;
             MinorEmpire          minorEmpire2         = aientity_MinorEmpire.Empire as MinorEmpire;
             if (minorEmpire2.Region == region)
             {
                 minorEmpire = aientity_MinorEmpire;
                 return(true);
             }
         }
     }
     return(minorEmpire != null);
 }
Exemple #4
0
	protected override IEnumerator OnLoad()
	{
		if (this.convertedVillages != null)
		{
			for (int index = 0; index < this.convertedVillages.Count; index++)
			{
				Village village = this.convertedVillages[index];
				village.Empire = null;
				Diagnostics.Assert(village.PointOfInterest != null);
				Diagnostics.Assert(village.PointOfInterest.Region != null);
				MinorEmpire minorEmpire = village.PointOfInterest.Region.MinorEmpire;
				Diagnostics.Assert(minorEmpire != null);
				BarbarianCouncil barbarianCouncil = minorEmpire.GetAgency<BarbarianCouncil>();
				Diagnostics.Assert(barbarianCouncil != null);
				barbarianCouncil.AddVillage(village);
				barbarianCouncil.AddConvertVillageOnLoad(village, this);
				DepartmentOfTheInterior.GenerateFIMSEForConvertedVillage(this, village.PointOfInterest);
			}
		}
		if (this.InfectedVillages != null)
		{
			for (int index2 = 0; index2 < this.InfectedVillages.Count; index2++)
			{
				Village village2 = this.InfectedVillages[index2];
				village2.Empire = null;
				Diagnostics.Assert(village2.PointOfInterest != null);
				Diagnostics.Assert(village2.PointOfInterest.Region != null);
				MinorEmpire minorEmpire2 = village2.PointOfInterest.Region.MinorEmpire;
				Diagnostics.Assert(minorEmpire2 != null);
				BarbarianCouncil barbarianCouncil2 = minorEmpire2.GetAgency<BarbarianCouncil>();
				Diagnostics.Assert(barbarianCouncil2 != null);
				barbarianCouncil2.AddVillage(village2);
			}
		}
		yield return base.OnLoad();
		yield break;
	}
Exemple #5
0
    private void Server_TurnBegin_CheckLiceArmySpawn()
    {
        global::Game game = this.gameService.Game as global::Game;

        Diagnostics.Assert(game != null);
        ISessionService service = Services.GetService <ISessionService>();

        Diagnostics.Assert(service != null);
        global::Session session = service.Session as global::Session;

        Diagnostics.Assert(session != null);
        KaijuCouncil.WildLiceArmyPreferences.LoadRegistryValues(session);
        if (this.LiceArmies.Length >= KaijuCouncil.WildLiceArmyPreferences.MaxArmiesAlive)
        {
            return;
        }
        int turn = game.Turn;
        int num  = (int)Math.Ceiling((double)((float)KaijuCouncil.WildLiceArmyPreferences.SpawningCooldown * base.Empire.GetPropertyValue(SimulationProperties.GameSpeedMultiplier)));

        if (turn < this.lastLiceArmySpawnTurn + num)
        {
            return;
        }
        int num2 = this.Kaiju.OnGarrisonMode() ? KaijuCouncil.WildLiceArmyPreferences.ArmiesToSpawnCount : 0;

        if (num2 <= 0)
        {
            return;
        }
        List <WorldPosition> list = new List <WorldPosition>();

        for (int i = 0; i < this.Kaiju.Region.WorldPositions.Length; i++)
        {
            WorldPosition worldPosition = this.Kaiju.Region.WorldPositions[i];
            if (DepartmentOfDefense.CheckWhetherTargetPositionIsValidForUseAsArmySpawnLocation(worldPosition, PathfindingMovementCapacity.Ground) && worldPosition != this.Kaiju.WorldPosition)
            {
                list.Add(worldPosition);
            }
        }
        if (list.Count == 0)
        {
            return;
        }
        System.Random randomizer = new System.Random(World.Seed + turn);
        list = (from position in list
                orderby this.worldPositionningService.GetDistance(this.Kaiju.WorldPosition, position), randomizer.NextDouble()
                select position).ToList <WorldPosition>();
        WorldPosition[] worldPositions;
        if (list.Count > num2)
        {
            worldPositions = list.Take(Math.Min(list.Count, num2)).ToArray <WorldPosition>();
        }
        else
        {
            worldPositions = list.ToArray();
        }
        List <StaticString> list2 = new List <StaticString>();
        StaticString        name  = this.KaijuEmpire.FindLiceDesign(true).Name;
        int unitsPerArmy          = KaijuCouncil.WildLiceArmyPreferences.UnitsPerArmy;

        for (int j = 0; j < unitsPerArmy; j++)
        {
            list2.Add(name);
        }
        List <StaticString> list3 = new List <StaticString>();

        list3.Add(KaijuCouncil.WildLiceArmyPreferences.ArmyTag);
        List <StaticString> list4 = new List <StaticString>();

        list4.Add(KaijuCouncil.WildLiceArmyPreferences.UnitTag);
        List <MajorEmpire> list5 = new List <MajorEmpire>();
        int k = 0;

        while (k < game.Empires.Length)
        {
            if (game.Empires[k] is MajorEmpire && !(game.Empires[k] as MajorEmpire).ELCPIsEliminated)
            {
                if (game.Empires[k].GetAgency <DepartmentOfTheInterior>().NonInfectedCities.Count > 0)
                {
                    list5.Add(game.Empires[k] as MajorEmpire);
                    break;
                }
                break;
            }
            else
            {
                k++;
            }
        }
        DepartmentOfTheInterior agency      = list5[game.Turn % list5.Count].GetAgency <DepartmentOfTheInterior>();
        MinorEmpire             minorEmpire = agency.Cities[game.Turn % agency.Cities.Count].Region.MinorEmpire;
        OrderSpawnArmies        order       = new OrderSpawnArmies(minorEmpire.Index, worldPositions, list2.ToArray(), KaijuCouncil.WildLiceArmyPreferences.ArmiesToSpawnCount, list3.ToArray(), list4.ToArray(), Math.Max(0, DepartmentOfScience.GetMaxEraNumber()), QuestArmyObjective.QuestBehaviourType.Undefined);
        Ticket ticket = null;

        minorEmpire.PlayerControllers.Server.PostOrder(order, out ticket, new EventHandler <TicketRaisedEventArgs>(this.OrderSpawnLiceArmies_TicketRaised));
    }