private void RefreshArmySupportMission(ColossusMission currentColossusMission, Unit colossus) { if (currentColossusMission.Objective != ColossusMission.MissionObjective.ArmySupport) { return; } WorldPosition colossusArmyPosition = WorldPosition.Invalid; if (colossus.Garrison is IWorldPositionable) { colossusArmyPosition = (colossus.Garrison as IWorldPositionable).WorldPosition; } float fitnessForMission = this.GetFitnessForMission(colossus, ColossusMission.MissionObjective.ArmySupport); float num = this.ComputeArmyFitness(currentColossusMission.TargetGuid, colossusArmyPosition); float num2 = num * fitnessForMission; ColossusMission colossusMissionPerTarget = this.GetColossusMissionPerTarget(currentColossusMission.TargetGuid); if (colossusMissionPerTarget != null && colossusMissionPerTarget.Objective == currentColossusMission.Objective && colossusMissionPerTarget.ColossusGuid != colossus.GUID && num2 < colossusMissionPerTarget.Fitness) { num *= 0.5f; } num = AILayer.Boost(num, 0.1f); currentColossusMission.EntityFitness = num; currentColossusMission.ColossusMissionFitness = fitnessForMission; }
public ColossusMission UpdateCityDefenseMission(ColossusMission currentColossusMission, Unit colossus) { float fitnessForMission = this.GetFitnessForMission(colossus, ColossusMission.MissionObjective.CityDefense); WorldPosition worldPosition = WorldPosition.Invalid; if (colossus.Garrison is IWorldPositionable) { worldPosition = (colossus.Garrison as IWorldPositionable).WorldPosition; } Region region = this.worldPositioningService.GetRegion(worldPosition); float num = 0f; float entityFitness = 0f; GameEntityGUID targetGuid = GameEntityGUID.Zero; for (int i = 0; i < this.departmentOfTheInterior.Cities.Count; i++) { if (currentColossusMission == null || !(this.departmentOfTheInterior.Cities[i].GUID == currentColossusMission.TargetGuid)) { if (!this.hasShips) { Region region2 = this.worldPositioningService.GetRegion(this.departmentOfTheInterior.Cities[i].WorldPosition); if (region.ContinentID != region2.ContinentID) { goto IL_193; } } float num2 = this.ComputeCityFitness(this.departmentOfTheInterior.Cities[i].GUID, worldPosition); float num3 = num2 * fitnessForMission; ColossusMission colossusMissionPerTarget = this.GetColossusMissionPerTarget(this.departmentOfTheInterior.Cities[i].GUID); if (colossusMissionPerTarget != null && currentColossusMission != null && colossusMissionPerTarget.Objective == currentColossusMission.Objective && num3 < colossusMissionPerTarget.Fitness) { num2 *= 0.5f; num3 *= 0.5f; } if (currentColossusMission == null || num3 >= currentColossusMission.Fitness) { if (num < num3) { num = num3; targetGuid = this.departmentOfTheInterior.Cities[i].GUID; } } } IL_193 :; } if (targetGuid.IsValid) { return(new ColossusMission { EntityFitness = entityFitness, ColossusMissionFitness = fitnessForMission, TargetGuid = targetGuid, ColossusGuid = colossus.GUID, Objective = ColossusMission.MissionObjective.CityDefense }); } return(null); }
private void UpdateColossusMissions() { for (int i = 0; i < this.colossusData.Count; i++) { Unit unit = this.colossusData[i].Army.StandardUnits[0]; ColossusMission colossusMissionPerColossus = this.GetColossusMissionPerColossus(unit.GUID); if (colossusMissionPerColossus != null) { for (int j = 0; j < this.refreshColossusMissions.Count; j++) { this.refreshColossusMissions[j](colossusMissionPerColossus, unit); } } } for (int k = 0; k < this.colossusData.Count; k++) { Unit unit2 = this.colossusData[k].Army.StandardUnits[0]; ColossusMission colossusMission = this.GetColossusMissionPerColossus(unit2.GUID); bool flag = false; for (int l = 0; l < this.refreshColossusMissions.Count; l++) { ColossusMission colossusMission2 = this.updateColossusMissions[l](colossusMission, unit2); if (colossusMission2 != null) { flag = true; colossusMission = colossusMission2; } } if (flag) { for (int m = 0; m < base.AICommanders.Count; m++) { if (base.AICommanders[m].ForceArmyGUID == this.colossusData[k].Army.GUID) { AICommander_Colossus aicommander_Colossus = this.aiCommanders[k] as AICommander_Colossus; aicommander_Colossus.ChangeColossusMission(colossusMission); } } } } }
public ColossusMission UpdateHarassingMission(ColossusMission currentColossusMission, Unit colossus) { float fitnessForMission = this.GetFitnessForMission(colossus, ColossusMission.MissionObjective.Harassing); WorldPosition worldPosition = WorldPosition.Invalid; if (colossus.Garrison is IWorldPositionable) { worldPosition = (colossus.Garrison as IWorldPositionable).WorldPosition; } Region region = this.worldPositioningService.GetRegion(worldPosition); float num = 0f; GameEntityGUID targetGuid = GameEntityGUID.Zero; global::Game game = this.gameService.Game as global::Game; for (int i = 0; i < game.Empires.Length; i++) { if (game.Empires[i] is MajorEmpire) { if (base.AIEntity.Empire.Index != i) { DepartmentOfTheInterior agency = game.Empires[i].GetAgency <DepartmentOfTheInterior>(); int j = 0; while (j < agency.Cities.Count) { if (this.hasShips) { goto IL_EF; } Region region2 = this.worldPositioningService.GetRegion(agency.Cities[j].WorldPosition); if (region.ContinentID == region2.ContinentID) { goto IL_EF; } IL_12B: j++; continue; IL_EF: float num2 = this.ComputeHarassingFitness(agency.Cities[j].GUID, worldPosition); if (num < num2) { num = num2; targetGuid = agency.Cities[j].GUID; goto IL_12B; } goto IL_12B; } } } } if (!targetGuid.IsValid) { return(null); } float num3 = num * fitnessForMission; ColossusMission colossusMissionPerTarget = this.GetColossusMissionPerTarget(targetGuid); if (colossusMissionPerTarget != null && currentColossusMission != null && colossusMissionPerTarget.Objective == currentColossusMission.Objective && num3 < colossusMissionPerTarget.Fitness) { num *= 0.5f; num3 *= 0.5f; } if (currentColossusMission != null && num3 < currentColossusMission.Fitness) { return(null); } return(new ColossusMission { EntityFitness = num, ColossusMissionFitness = fitnessForMission, ColossusGuid = colossus.GUID, TargetGuid = targetGuid, Objective = ColossusMission.MissionObjective.Harassing }); }