public void Bind(KaijuGarrison garrison, Amplitude.Unity.Gui.IGuiService guiService) { this.Unbind(); this.KaijuGarrison = garrison; this.GuiService = (guiService as global::IGuiService); IGameService service = Services.GetService <IGameService>(); this.playerControllerRepository = service.Game.Services.GetService <IPlayerControllerRepositoryService>(); Unit unit2 = (from unit in this.KaijuGarrison.Units where unit.UnitDesign.Tags.Contains(Kaiju.MonsterUnitTag) select unit).First <Unit>(); if (unit2 != null) { this.KaijuGuiUnit = new GuiUnit(unit2, null); } IGuiPanelHelper guiPanelHelper = Services.GetService <global::IGuiService>().GuiPanelHelper; Diagnostics.Assert(guiPanelHelper != null, "Unable to access GuiPanelHelper"); Texture2D image = null; if (guiPanelHelper.TryGetTextureFromIcon(this.KaijuGuiElement, global::GuiPanel.IconSize.Small, out image)) { this.KaijuIcon.Image = image; } }
private void OnDoubleClickKaijuLine() { KaijuGarrison currentKaiju = KaijuLine.CurrentKaiju; this.OnCloseCB(null); IViewService service = Services.GetService <IViewService>(); if (service != null) { service.SelectAndCenter(currentKaiju, false); } this.Hide(false); }
public void SpawnKaiju(WorldPosition targetPosition, GameEntityGUID kaijuGUID, GameEntityGUID garrisonGUID, GameEntityGUID armyGUID, GameEntityGUID monsterGUID, GameEntityGUID[] licesGUIDs) { Kaiju kaiju = new Kaiju(base.Empire as KaijuEmpire, kaijuGUID); string[] kaijuDescriptors = this.KaijuEmpire.KaijuFaction.KaijuDescriptors; for (int i = 0; i < kaijuDescriptors.Length; i++) { SimulationDescriptor descriptor = null; if (this.descriptorsDatabase.TryGetValue(kaijuDescriptors[i], out descriptor)) { kaiju.AddDescriptor(descriptor, false); } } KaijuGarrison kaijuGarrison = new KaijuGarrison(garrisonGUID, targetPosition); SimulationDescriptor value = this.descriptorsDatabase.GetValue(Kaiju.ClassKaijuGarrison); kaijuGarrison.AddDescriptor(value, false); kaijuGarrison.SetPropertyBaseValue(SimulationProperties.MaximumUnitSlotCount, (float)(licesGUIDs.Length + 1)); kaiju.SetGarrison(kaijuGarrison); KaijuArmy kaijuArmy = this.departmentOfDefense.CreateKaijuArmy(armyGUID, targetPosition, true); SimulationDescriptor value2 = this.descriptorsDatabase.GetValue(Kaiju.ClassKaijuArmy); kaijuArmy.AddDescriptor(value2, false); kaijuArmy.SetPropertyBaseValue(SimulationProperties.MaximumUnitSlotCount, (float)(licesGUIDs.Length + 1)); kaiju.SetArmy(kaijuArmy); this.gameEntityRepositoryService.Register(kaijuArmy); this.gameEntityRepositoryService.Register(kaiju); kaiju.ChangeToWildState(); kaiju.ChangeToGarrisonMode(false); Unit unit = DepartmentOfDefense.CreateUnitByDesign(monsterGUID, this.KaijuEmpire.FindMonsterDesign(true)); kaiju.AddUnit(unit); for (int j = 0; j < licesGUIDs.Length; j++) { Unit unit2 = DepartmentOfDefense.CreateUnitByDesign(licesGUIDs[j], this.KaijuEmpire.FindLiceDesign(true)); kaiju.AddUnit(unit2); } this.lastLiceArmySpawnTurn = (this.gameService.Game as global::Game).Turn; this.Kaiju = kaiju; this.KaijuEmpire.AddKaiju(kaiju); kaiju.Refresh(false); foreach (global::Empire empire in (this.gameService.Game as global::Game).Empires) { if (empire is MajorEmpire) { this.eventService.Notify(new EventKaijuSpawned(empire, this.Kaiju)); } } }
public void SetGarrison(KaijuGarrison kaijuGarrison) { kaijuGarrison.Empire = this.Empire; kaijuGarrison.Kaiju = this; this.KaijuGarrison = kaijuGarrison; this.KaijuGarrison.StandardUnitCollectionChange += this.KaijuGarrison_StandardUnitCollectionChange; if (!this.OnArmyMode()) { IWorldPositionningService service = this.GameService.Game.Services.GetService <IWorldPositionningService>(); Region region = service.GetRegion(this.KaijuGarrison.WorldPosition); this.Region = region; this.Region.KaijuEmpire = this.KaijuEmpire; this.Region.KaijuGarrisonGUID = this.KaijuGarrison.GUID; this.Empire.AddChild(kaijuGarrison); } }
public override void ReadXml(XmlReader reader) { int num = reader.ReadVersionAttribute(); this.GUID = reader.GetAttribute <ulong>("GUID"); base.ReadXml(reader); int num2 = reader.ReadElementString <int>("OwnerIndex"); this.ownerEmpireIndex = num2; this.kaijuEmpireIndex = reader.ReadElementString <int>("KaijuEmpireIndex"); ulong attribute = reader.GetAttribute <ulong>("GUID"); KaijuGarrison kaijuGarrison = new KaijuGarrison(attribute) { Empire = this.Empire, Kaiju = this }; reader.ReadElementSerializable <KaijuGarrison>(ref kaijuGarrison); if (kaijuGarrison != null) { this.SetGarrison(kaijuGarrison); } this.kaijuArmyGUID = reader.ReadElementString <ulong>("KaijuArmyGUID"); this.NextTurnToSpawnUnit = reader.ReadElementString <int>("nextTurnToSpawnUnits"); this.NextTurnToRecoverFromStun = reader.ReadElementString <int>("nextTurnToRecoveryFromStun"); if (num > 1) { this.needResetUnitsActionPointsSpent = reader.ReadElementString <bool>("needResetUnitsActionPointsSpent"); } if (num > 2) { this.PreviousOwnerIndex = reader.ReadElementString <int>("PreviousOwnerIndex"); this.TamedTurn = reader.ReadElementString <int>("TamedTurn"); this.PreviousStunnerIndex = reader.ReadElementString <int>("PreviousStunnerIndex"); this.PreviousStunnedTurn = reader.ReadElementString <int>("PreviousStunnedTurn"); } if (num > 3) { int num3 = reader.ReadElementString <int>("WorldOrientation"); this.WorldOrientation = (WorldOrientation)num3; } }
public bool IsPositionValidForDevice(Amplitude.Unity.Game.Empire empire, WorldPosition position) { if (!position.IsValid) { return(false); } if (this.WorldPositionningService.IsWaterTile(position)) { return(false); } if (this.GetDeviceAtPosition(position) != null) { return(false); } if (this.IsAreaVolcanoformed(position)) { return(false); } if (this.WorldPositionningService != null) { if (!this.WorldPositionningService.IsConstructible(position, WorldPositionning.PreventsDistrictTypeExtensionConstruction, 0) && !this.pillarService.IsPositionOccupiedByAPillar(position)) { return(false); } Region region = this.WorldPositionningService.GetRegion(position); if (region.KaijuEmpire != null && region.Kaiju != null) { KaijuGarrison kaijuGarrison = region.Kaiju.KaijuGarrison; if (kaijuGarrison.WorldPosition == position) { return(false); } } if (region != null && region.City != null && region.City.Empire.Index != empire.Index) { for (int i = 0; i < region.City.Districts.Count; i++) { if (region.City.Districts[i].Type != DistrictType.Exploitation && region.City.Districts[i].WorldPosition == position) { return(false); } } DepartmentOfIndustry agency = region.City.Empire.GetAgency <DepartmentOfIndustry>(); ConstructionQueue constructionQueue = agency.GetConstructionQueue(region.City); if (constructionQueue != null) { for (int j = 0; j < constructionQueue.PendingConstructions.Count; j++) { if (constructionQueue.PendingConstructions[j].WorldPosition == position) { if (constructionQueue.PendingConstructions[j].ConstructibleElement is DistrictImprovementDefinition) { return(false); } if (constructionQueue.PendingConstructions[j].ConstructibleElement is UnitDesign && (constructionQueue.PendingConstructions[j].ConstructibleElement as UnitDesign).Tags.Contains(DownloadableContent9.TagSolitary)) { return(false); } } } } } } return(true); }
protected override State Execute(AIBehaviorTree aiBehaviorTree, params object[] parameters) { if (this.ticket != null) { if (!this.orderExecuted) { return(State.Running); } if (this.ticket.PostOrderResponse == PostOrderResponse.PreprocessHasFailed) { this.orderExecuted = false; this.ticket = null; aiBehaviorTree.ErrorCode = 1; return(State.Failure); } this.orderExecuted = false; this.ticket = null; return(State.Success); } else { Army army; if (base.GetArmyUnlessLocked(aiBehaviorTree, "$Army", out army) != AIArmyMission.AIArmyMissionErrorCode.None) { return(State.Failure); } float propertyValue = army.GetPropertyValue(SimulationProperties.MaximumNumberOfActionPoints); float propertyValue2 = army.GetPropertyValue(SimulationProperties.ActionPointsSpent); if (propertyValue <= propertyValue2) { aiBehaviorTree.ErrorCode = 33; return(State.Failure); } if (!aiBehaviorTree.Variables.ContainsKey(this.TargetVarName)) { aiBehaviorTree.LogError("${0} not set", new object[] { this.TargetVarName }); return(State.Failure); } IGameEntity target = aiBehaviorTree.Variables[this.TargetVarName] as IGameEntity; if (!(target is IWorldPositionable)) { return(State.Failure); } IGameService service = Services.GetService <IGameService>(); Diagnostics.Assert(service != null); if (!service.Game.Services.GetService <IGameEntityRepositoryService>().Contains(target.GUID)) { return(State.Success); } IWorldPositionningService service2 = service.Game.Services.GetService <IWorldPositionningService>(); IEnumerable <Encounter> service3 = service.Game.Services.GetService <IEncounterRepositoryService>(); if (service3 != null && service3.Any((Encounter encounter) => encounter.IsGarrisonInEncounter(army.GUID, false) || encounter.IsGarrisonInEncounter(target.GUID, false))) { return(State.Running); } IGarrison garrison; if (target is Kaiju) { Kaiju kaiju = target as Kaiju; garrison = kaiju.GetActiveTroops(); if (kaiju.IsStunned()) { return(State.Failure); } } else { if (target is KaijuArmy) { KaijuArmy kaijuArmy = target as KaijuArmy; if (kaijuArmy != null && kaijuArmy.Kaiju.IsStunned()) { return(State.Failure); } } else if (target is KaijuGarrison) { KaijuGarrison kaijuGarrison = target as KaijuGarrison; if (kaijuGarrison != null && kaijuGarrison.Kaiju.IsStunned()) { return(State.Failure); } } garrison = (target as IGarrison); if (garrison == null) { return(State.Failure); } } if ((army.Empire is MinorEmpire || army.Empire is NavalEmpire) && garrison.Hero != null && garrison.Hero.IsSkillUnlocked("HeroSkillLeaderMap07")) { return(State.Failure); } if (garrison.Empire.Index == aiBehaviorTree.AICommander.Empire.Index) { return(State.Failure); } this.orderExecuted = false; GameEntityGUID guid = target.GUID; if (target is City) { Diagnostics.Assert(AIScheduler.Services != null); IEntityInfoAIHelper service4 = AIScheduler.Services.GetService <IEntityInfoAIHelper>(); Diagnostics.Assert(service4 != null); City city = target as City; if (city.BesiegingEmpire != null && city.BesiegingEmpire != aiBehaviorTree.AICommander.Empire) { return(State.Failure); } District districtToAttackFrom = service4.GetDistrictToAttackFrom(army, city); if (districtToAttackFrom == null) { aiBehaviorTree.ErrorCode = 12; return(State.Failure); } guid = districtToAttackFrom.GUID; } else if (target is Camp) { Camp camp = target as Camp; IWorldPositionable worldPositionable = target as IWorldPositionable; if (worldPositionable == null) { return(State.Failure); } if (service2.GetDistance(army.WorldPosition, worldPositionable.WorldPosition) != 1) { aiBehaviorTree.ErrorCode = 12; return(State.Failure); } guid = camp.GUID; } else if (target is Fortress) { guid = target.GUID; } else { Village village = target as Village; if (village != null && (village.HasBeenPacified || (village.HasBeenConverted && village.Converter == aiBehaviorTree.AICommander.Empire) || village.HasBeenInfected)) { return(State.Failure); } Diagnostics.Assert(AIScheduler.Services != null); IWorldPositionable worldPositionable2 = target as IWorldPositionable; if (worldPositionable2 == null) { return(State.Failure); } District district = service2.GetDistrict(worldPositionable2.WorldPosition); if (district != null && District.IsACityTile(district) && district.City.Empire == garrison.Empire) { worldPositionable2 = district; guid = district.GUID; } if (service2.GetDistance(army.WorldPosition, worldPositionable2.WorldPosition) != 1) { aiBehaviorTree.ErrorCode = 12; return(State.Failure); } } OrderAttack order = new OrderAttack(army.Empire.Index, army.GUID, guid); aiBehaviorTree.AICommander.Empire.PlayerControllers.AI.PostOrder(order, out this.ticket, new EventHandler <TicketRaisedEventArgs>(this.Order_TicketRaised)); return(State.Running); } }
private void ValidatePath() { IGuiService service = Services.GetService <IGuiService>(); IAudioEventService service2 = Services.GetService <IAudioEventService>(); Diagnostics.Assert(service2 != null); bool flag = base.SelectedUnits.Length == 0 || base.SelectedUnits.Length == this.Army.StandardUnits.Count || (this.Garrison.UnitsCount == 1 && this.Garrison.Hero != null); if (!base.IsTransferable(WorldCursor.HighlightedWorldPosition) && flag) { global::Empire empire = this.WorldArmy.Army.Empire; if (this.battleTarget is Army) { Army army = this.battleTarget as Army; if (army.Empire.Index == this.Army.Empire.Index) { int num = Mathf.Max(army.MaximumUnitSlot - army.CurrentUnitSlot, 0); if (this.Army.HasCatspaw || army.HasCatspaw) { QuickWarningPanel.Show("%UnitsTransferImpossibleWithCatsPawArmy"); } else if (this.Army.StandardUnits.Count > num) { QuickWarningPanel.Show(string.Format(AgeLocalizer.Instance.LocalizeString("%UnitsTransferNotEnoughSlotsInTargetArmy"), num)); } else if (this.Army.GetPropertyValue(SimulationProperties.Movement) <= 0f && base.WorldPositionningService.GetDistance(this.Army.WorldPosition, army.WorldPosition) == 1) { QuickWarningPanel.Show(AgeLocalizer.Instance.LocalizeString("%" + ArmyAction_TransferUnits.NotEnoughMovementToTransfer + "Description")); } else if (this.TemporaryWorldPath != null && this.TemporaryWorldPath.Length > 1 && !this.Army.HasCatspaw && !army.HasCatspaw) { OrderGoToAndMerge order = new OrderGoToAndMerge(empire.Index, this.WorldArmy.Army.GUID, this.battleTarget.GUID, (from unit in base.SelectedUnits select unit.GUID).ToArray <GameEntityGUID>(), this.TemporaryWorldPath); this.PlayerControllerRepositoryService.ActivePlayerController.PostOrder(order); } } else { DepartmentOfForeignAffairs agency = empire.GetAgency <DepartmentOfForeignAffairs>(); Diagnostics.Assert(agency != null); bool flag2 = this.Army.IsNaval == army.IsNaval; if ((agency.CanAttack(this.battleTarget) || this.WorldArmy.Army.IsPrivateers) && flag2) { ArmyAction armyAction = null; IDatabase <ArmyAction> database = Databases.GetDatabase <ArmyAction>(false); float cost = 0f; if (database != null && database.TryGetValue(ArmyAction_Attack.ReadOnlyName, out armyAction)) { cost = armyAction.GetCostInActionPoints(); } if (!this.Army.HasEnoughActionPoint(cost)) { QuickWarningPanel.Show(AgeLocalizer.Instance.LocalizeString("%ArmyNotEnoughActionPointsDescription")); } else if (this.TemporaryWorldPath != null && this.TemporaryWorldPath.Length > 1) { OrderGoToAndAttack order2 = new OrderGoToAndAttack(empire.Index, this.WorldArmy.Army.GUID, this.battleTarget.GUID, this.TemporaryWorldPath); this.PlayerControllerRepositoryService.ActivePlayerController.PostOrder(order2); } else { OrderAttack order3 = new OrderAttack(empire.Index, this.WorldArmy.Army.GUID, this.battleTarget.GUID); this.PlayerControllerRepositoryService.ActivePlayerController.PostOrder(order3); } service2.Play2DEvent("Gui/Interface/InGame/OrderAttack"); } else if (army.Empire is MajorEmpire && flag2) { global::Empire empire2 = army.Empire; service.GetGuiPanel <WarDeclarationModalPanel>().Show(new object[] { empire2, "AttackTarget" }); } } } else { bool flag3 = false; if (this.battleTarget != null) { if (this.TemporaryWorldPath != null && this.TemporaryWorldPath.Length > 1) { flag3 = (this.TemporaryWorldPath.ControlPoints.Length == 0); flag3 |= (this.TemporaryWorldPath.ControlPoints.Length == 1 && (int)this.TemporaryWorldPath.ControlPoints[0] == this.TemporaryWorldPath.Length - 1); } else { flag3 = base.PathfindingService.IsTransitionPassable(this.Army.WorldPosition, this.battleTarget.WorldPosition, this.Army, PathfindingFlags.IgnoreArmies | PathfindingFlags.IgnoreOtherEmpireDistrict | PathfindingFlags.IgnoreDiplomacy | PathfindingFlags.IgnorePOI | PathfindingFlags.IgnoreSieges | PathfindingFlags.IgnoreKaijuGarrisons, null); } } if (flag3 || this.battleTarget is Fortress || this.battleTarget is KaijuGarrison) { flag3 = false; bool flag4 = true; if (this.battleTarget is KaijuGarrison) { KaijuGarrison kaijuGarrison = this.battleTarget as KaijuGarrison; DepartmentOfForeignAffairs agency2 = empire.GetAgency <DepartmentOfForeignAffairs>(); Diagnostics.Assert(agency2 != null); if (!agency2.CanAttack(this.battleTarget)) { flag4 = false; global::Empire empire3 = kaijuGarrison.Empire; service.GetGuiPanel <WarDeclarationModalPanel>().Show(new object[] { empire3, "AttackTarget" }); } } if (flag4) { ArmyActionModalPanel guiPanel = service.GetGuiPanel <ArmyActionModalPanel>(); if (guiPanel != null) { WorldPosition destination = (this.TemporaryWorldPath == null || this.TemporaryWorldPath.Length <= 1) ? WorldPosition.Invalid : this.TemporaryWorldPath.Destination; if (guiPanel.CheckForArmyActionsAvailability(this.Army, this.battleTarget, destination).Count > 0) { flag3 = true; } } } } if (flag3 && this.battleTarget != null && !this.Army.IsPrivateers) { MajorEmpire majorEmpire = null; if (this.battleTarget is Garrison) { majorEmpire = ((this.battleTarget as Garrison).Empire as MajorEmpire); } else if (this.battleTarget is District) { majorEmpire = ((this.battleTarget as District).Empire as MajorEmpire); } if (majorEmpire != null && majorEmpire.Index != this.Army.Empire.Index) { flag3 = this.Army.Empire.GetAgency <DepartmentOfForeignAffairs>().IsSymetricallyDiscovered(majorEmpire); } } if (flag3) { WorldPosition worldPosition = (this.TemporaryWorldPath == null || this.TemporaryWorldPath.Length <= 1) ? WorldPosition.Invalid : this.TemporaryWorldPath.Destination; service.Show(typeof(ArmyActionModalPanel), new object[] { this.Army, this.battleTarget, base.SelectedUnits, worldPosition }); } else if (this.TemporaryWorldPath != null && this.TemporaryWorldPath.Destination != WorldPosition.Invalid) { OrderGoTo order4 = new OrderGoTo(empire.Index, this.WorldArmy.Army.GUID, this.TemporaryWorldPath.Destination); this.PlayerControllerRepositoryService.ActivePlayerController.PostOrder(order4); service2.Play2DEvent("Gui/Interface/InGame/OrderGoTo"); } else if (WorldCursor.HighlightedWorldPosition != WorldPosition.Invalid) { Region region = base.WorldPositionningService.GetRegion(WorldCursor.HighlightedWorldPosition); if (region != null && region.City != null && region.City.Empire != null) { DepartmentOfForeignAffairs agency3 = this.Army.Empire.GetAgency <DepartmentOfForeignAffairs>(); Diagnostics.Assert(agency3 != null); if (!agency3.CanMoveOn(WorldCursor.HighlightedWorldPosition, this.WorldArmy.Army.IsPrivateers, this.WorldArmy.Army.IsCamouflaged)) { District district = base.WorldPositionningService.GetDistrict(WorldCursor.HighlightedWorldPosition); if ((district == null || district.Type == DistrictType.Exploitation) && region.City.Empire is MajorEmpire) { service.GetGuiPanel <WarDeclarationModalPanel>().Show(new object[] { region.City.Empire, "BreakCloseBorder" }); } } } } } } this.LastHighlightedWorldPosition = WorldPosition.Invalid; this.LastUnpathableWorldPosition = WorldPosition.Invalid; this.SelectTarget(); this.UpdateBattlegroundVisibility(); if (this.TemporaryWorldPath != null) { this.PathRendererService.RemovePath(this.TemporaryWorldPath); this.TemporaryWorldPath = null; } }
private void SelectTarget() { this.battleTarget = null; if (this.LastHighlightedWorldPosition == WorldPosition.Invalid) { return; } if (!base.VisibilityService.IsWorldPositionVisibleFor(this.LastHighlightedWorldPosition, this.Army.Empire)) { return; } Region region = base.WorldPositionningService.GetRegion(this.LastHighlightedWorldPosition); if (region == null || this.battleTarget != null) { return; } PointOfInterest pointOfInterest = region.PointOfInterests.FirstOrDefault((PointOfInterest match) => match.WorldPosition == this.LastHighlightedWorldPosition); if (pointOfInterest != null && (pointOfInterest.Type == Fortress.Citadel || pointOfInterest.Type == Fortress.Facility)) { Fortress fortressAt = region.NavalEmpire.GetAgency <PirateCouncil>().GetFortressAt(pointOfInterest.WorldPosition); this.battleTarget = fortressAt; } if (region != null) { District district = null; if (region.City != null && region.City.Empire != this.Army.Empire) { district = region.City.Districts.FirstOrDefault((District match) => match.WorldPosition == this.LastHighlightedWorldPosition); } if (district != null && district.Type != DistrictType.Exploitation) { this.battleTarget = district; } } if (this.battleTarget == null && region != null && region.City != null && region.City.Camp != null && region.City.Camp.WorldPosition == this.LastHighlightedWorldPosition && region.City.Empire != this.Army.Empire) { this.battleTarget = region.City.Camp; } if (this.battleTarget == null) { Army armyAtPosition = base.WorldPositionningService.GetArmyAtPosition(this.LastHighlightedWorldPosition); if (armyAtPosition != null && (!armyAtPosition.IsCamouflaged || base.VisibilityService.IsWorldPositionDetectedFor(this.LastHighlightedWorldPosition, this.Army.Empire))) { this.battleTarget = armyAtPosition; } } if (region != null && this.battleTarget == null) { pointOfInterest = region.PointOfInterests.FirstOrDefault((PointOfInterest match) => match.WorldPosition == this.LastHighlightedWorldPosition); if (pointOfInterest != null) { if (pointOfInterest.CreepingNodeGUID != GameEntityGUID.Zero) { CreepingNode creepingNode = null; base.GameEntityRepositoryService.TryGetValue <CreepingNode>(pointOfInterest.CreepingNodeGUID, out creepingNode); if (creepingNode != null) { if (creepingNode.Empire.Index != this.Army.Empire.Index) { if (ELCPUtilities.UseELCPPeacefulCreepingNodes) { DepartmentOfForeignAffairs agency = this.Army.Empire.GetAgency <DepartmentOfForeignAffairs>(); if (agency != null && agency.IsFriend(creepingNode.Empire)) { if (pointOfInterest.Type == "QuestLocation") { this.battleTarget = pointOfInterest; } else if (pointOfInterest.Type == "Village") { IQuestManagementService service = base.GameService.Game.Services.GetService <IQuestManagementService>(); IQuestRepositoryService service2 = base.GameService.Game.Services.GetService <IQuestRepositoryService>(); IEnumerable <QuestMarker> markersByBoundTargetGUID = service.GetMarkersByBoundTargetGUID(pointOfInterest.GUID); bool flag = false; foreach (QuestMarker questMarker in markersByBoundTargetGUID) { Quest quest; if (service2.TryGetValue(questMarker.QuestGUID, out quest) && quest.EmpireBits == this.Army.Empire.Bits) { Village villageAt = region.MinorEmpire.GetAgency <BarbarianCouncil>().GetVillageAt(pointOfInterest.WorldPosition); this.battleTarget = villageAt; flag = true; break; } } if (!flag) { this.battleTarget = creepingNode; } } else { this.battleTarget = creepingNode; } } } else { this.battleTarget = creepingNode; } } else if (pointOfInterest.Type == "QuestLocation" || pointOfInterest.Type == "NavalQuestLocation") { this.battleTarget = pointOfInterest; } } } else if (pointOfInterest.Type == "Village") { Village villageAt2 = region.MinorEmpire.GetAgency <BarbarianCouncil>().GetVillageAt(pointOfInterest.WorldPosition); this.battleTarget = villageAt2; } else if (pointOfInterest.Type == "QuestLocation" || pointOfInterest.Type == "NavalQuestLocation") { this.battleTarget = pointOfInterest; } } } if (region != null && this.battleTarget == null && region.KaijuEmpire != null && region.Kaiju != null) { KaijuGarrison kaijuGarrison = region.Kaiju.KaijuGarrison; if (kaijuGarrison.WorldPosition == this.LastHighlightedWorldPosition) { this.battleTarget = kaijuGarrison; } } if (this.battleTarget == null) { TerraformDevice deviceAtPosition = (base.GameService.Game as global::Game).GetService <ITerraformDeviceService>().GetDeviceAtPosition(this.LastHighlightedWorldPosition); if (deviceAtPosition != null) { this.battleTarget = deviceAtPosition; } } }
private void RefreshCosts() { IConstructionCost[] array = this.ArmyAction.Costs; ArmyAction_Bribe armyAction_Bribe = this.ArmyAction as ArmyAction_Bribe; ArmyAction_Convert armyAction_Convert = this.ArmyAction as ArmyAction_Convert; if (armyAction_Bribe != null || armyAction_Convert != null) { Village village = this.Target as Village; if (village != null) { IConstructionCost[] array2 = null; if (armyAction_Bribe != null) { IConstructionCost[] array3 = armyAction_Bribe.GetBribeCosts(this.Army, village); array2 = array3; } else if (armyAction_Convert != null) { IConstructionCost[] array3 = armyAction_Convert.GetConvertionCost(this.Army, village); array2 = array3; } if (array2 != null && array2.Length != 0) { if (array == null) { array = array2; } else { Array.Resize <IConstructionCost>(ref array, array.Length + array2.Length); Array.Copy(array2, 0, array, array.Length - array2.Length, array2.Length); } } } } if (this.Army != null && this.Army.Empire != null && array != null && array.Length != 0) { this.ActionCostLabel.AgeTransform.Visible = true; if (ELCPUtilities.UseELCPSymbiosisBuffs && this.ArmyAction is ArmyAction_TameUnstunnedKaiju) { KaijuGarrison kaijuGarrison = this.Target as KaijuGarrison; if (kaijuGarrison != null) { KaijuCouncil agency = kaijuGarrison.KaijuEmpire.GetAgency <KaijuCouncil>(); if (agency != null) { ConstructionCost constructionCost = new ConstructionCost(agency.ELCPResourceName, KaijuCouncil.GetKaijuTameCost().GetValue(this.Army.Empire), true, true); array = new IConstructionCost[] { constructionCost }; } } } this.ActionCostLabel.Text = GuiFormater.FormatCost(this.Army.Empire, array, false, 1, this.Army); this.ActionDescription.AgeTransform.PixelMarginBottom = this.ActionCostLabel.AgeTransform.PixelMarginBottom + this.ActionCostLabel.AgeTransform.Height; return; } this.ActionCostLabel.AgeTransform.Visible = false; this.ActionCostLabel.Text = string.Empty; this.ActionDescription.AgeTransform.PixelMarginBottom = this.ActionCostLabel.AgeTransform.PixelMarginBottom; }
public void CleanAfterEncounter(KaijuGarrison garrison, Encounter encounter) { this.CleanAfterEncounter(garrison.Kaiju, garrison.GUID, encounter); }
protected override State Execute(AIBehaviorTree aiBehaviorTree, params object[] parameters) { if (this.ticket != null) { if (!this.ticket.Raised) { return(State.Running); } if (this.ticket.PostOrderResponse == PostOrderResponse.PreprocessHasFailed) { this.ticket = null; aiBehaviorTree.ErrorCode = 1; return(State.Failure); } this.ticket = null; return(State.Success); } else { Army army; if (base.GetArmyUnlessLocked(aiBehaviorTree, "$Army", out army) != AIArmyMission.AIArmyMissionErrorCode.None) { return(State.Failure); } float propertyValue = army.GetPropertyValue(SimulationProperties.MaximumNumberOfActionPoints); float propertyValue2 = army.GetPropertyValue(SimulationProperties.ActionPointsSpent); if (propertyValue <= propertyValue2) { aiBehaviorTree.ErrorCode = 33; return(State.Failure); } if (!aiBehaviorTree.Variables.ContainsKey(this.TargetVarName)) { aiBehaviorTree.LogError("${0} not set", new object[] { this.TargetVarName }); return(State.Failure); } IGameEntity gameEntity = aiBehaviorTree.Variables[this.TargetVarName] as IGameEntity; if (!(gameEntity is IWorldPositionable)) { return(State.Failure); } IGameService service = Services.GetService <IGameService>(); Diagnostics.Assert(service != null); if (!service.Game.Services.GetService <IGameEntityRepositoryService>().Contains(gameEntity.GUID)) { return(State.Success); } IEncounterRepositoryService service2 = service.Game.Services.GetService <IEncounterRepositoryService>(); if (service2 != null) { IEnumerable <Encounter> enumerable = service2; if (enumerable != null && enumerable.Any((Encounter encounter) => encounter.IsGarrisonInEncounter(army.GUID, false))) { return(State.Running); } } IGarrison garrison; if (gameEntity is Kaiju) { Kaiju kaiju = gameEntity as Kaiju; garrison = kaiju.GetActiveTroops(); if (kaiju.IsStunned()) { return(State.Failure); } } else { if (gameEntity is KaijuArmy) { KaijuArmy kaijuArmy = gameEntity as KaijuArmy; if (kaijuArmy != null && kaijuArmy.Kaiju.IsStunned()) { return(State.Failure); } } else if (gameEntity is KaijuGarrison) { KaijuGarrison kaijuGarrison = gameEntity as KaijuGarrison; if (kaijuGarrison != null && kaijuGarrison.Kaiju.IsStunned()) { return(State.Failure); } } garrison = (gameEntity as IGarrison); } if (garrison == null) { return(State.Failure); } if ((army.Empire is MinorEmpire || army.Empire is NavalEmpire) && garrison.Hero != null && garrison.Hero.IsSkillUnlocked("HeroSkillLeaderMap07")) { return(State.Failure); } if (garrison.Empire.Index == aiBehaviorTree.AICommander.Empire.Index) { return(State.Failure); } GameEntityGUID guid = gameEntity.GUID; if (!aiBehaviorTree.Variables.ContainsKey(this.PathVarName)) { aiBehaviorTree.LogError("{0} not set", new object[] { this.PathVarName }); return(State.Failure); } WorldPath worldPath = aiBehaviorTree.Variables[this.PathVarName] as WorldPath; if (worldPath == null || worldPath.Length < 2) { aiBehaviorTree.LogError("Path is null.", new object[0]); aiBehaviorTree.ErrorCode = 3; return(State.Failure); } if (!worldPath.IsValid) { aiBehaviorTree.ErrorCode = 3; return(State.Failure); } OrderGoToAndAttack orderGoToAndAttack = new OrderGoToAndAttack(army.Empire.Index, army.GUID, guid, worldPath); orderGoToAndAttack.Flags = PathfindingFlags.IgnoreFogOfWar; aiBehaviorTree.AICommander.Empire.PlayerControllers.AI.PostOrder(orderGoToAndAttack, out this.ticket, null); return(State.Running); } }
private bool CanAttackGameEntity(Army army, IGameEntity gameEntity, ref bool displayButtonAnyway, ref List <StaticString> failureFlags) { Village village = gameEntity as Village; if (village != null) { displayButtonAnyway = true; if (!TutorialManager.IsActivated) { if (village.PointOfInterest.Interaction.IsLocked(army.Empire.Index, this.Name)) { if (!failureFlags.Contains(ArmyAction_Attack.OneVillageOrManyLocked)) { failureFlags.Add(ArmyAction_Attack.OneVillageOrManyLocked); } return(false); } } else { failureFlags.Add(ArmyAction.NoCanDoWhileTutorial); } if (village.HasBeenConverted) { if (village.Converter == army.Empire) { failureFlags.Add(ArmyAction_Attack.OwnVillage); return(false); } return(true); } else { if (village.HasBeenPacified) { failureFlags.Add(ArmyAction_BaseVillage.NoCanDoWhileVillageIsPacified); return(false); } return(true); } } else { Camp camp = gameEntity as Camp; if (camp != null) { if (camp.Empire == army.Empire) { return(false); } DepartmentOfForeignAffairs agency = army.Empire.GetAgency <DepartmentOfForeignAffairs>(); if (!agency.CanAttack(gameEntity) && !army.IsPrivateers && DepartmentOfTheInterior.CanNeverDeclareWar(army.Empire)) { failureFlags.Add(ArmyAction_Attack.CanNeverDeclareWar); return(false); } return(true); } else { District district = gameEntity as District; if (district != null) { if (district.City.Empire == army.Empire) { return(false); } displayButtonAnyway = true; if (district.City.BesiegingEmpire != null && district.City.BesiegingEmpire != army.Empire) { return(false); } if (district.Type == DistrictType.Exploitation) { return(false); } DepartmentOfForeignAffairs agency2 = army.Empire.GetAgency <DepartmentOfForeignAffairs>(); Diagnostics.Assert(agency2 != null); if (!agency2.CanAttack(gameEntity) && !army.IsPrivateers && DepartmentOfTheInterior.CanNeverDeclareWar(army.Empire)) { failureFlags.Add(ArmyAction_Attack.CanNeverDeclareWar); return(false); } return(true); } else { Army army2 = gameEntity as Army; if (army2 == null) { KaijuGarrison kaijuGarrison = gameEntity as KaijuGarrison; return(kaijuGarrison != null && (kaijuGarrison.Owner == null || kaijuGarrison.Owner.Index != army.Empire.Index) && !kaijuGarrison.Kaiju.IsStunned()); } if (army2.Empire == army.Empire) { return(false); } if (army2.Sails) { return(false); } if (army2 is KaijuArmy) { KaijuArmy kaijuArmy = army2 as KaijuArmy; if (kaijuArmy != null && kaijuArmy.Kaiju.IsStunned()) { return(false); } } DepartmentOfForeignAffairs agency3 = army.Empire.GetAgency <DepartmentOfForeignAffairs>(); Diagnostics.Assert(agency3 != null); if (!agency3.CanAttack(gameEntity) && !army.IsPrivateers && DepartmentOfTheInterior.CanNeverDeclareWar(army.Empire)) { failureFlags.Add(ArmyAction_Attack.CanNeverDeclareWar); return(false); } displayButtonAnyway = true; return(true); } } } }
public void FillTargets(Army army, List <IGameEntity> targets, ref List <StaticString> failureFlags) { if (targets == null) { targets = new List <IGameEntity>(); } IGameService service = Services.GetService <IGameService>(); if (service == null) { return; } IWorldPositionningService service2 = service.Game.Services.GetService <IWorldPositionningService>(); Diagnostics.Assert(service2 != null); IPathfindingService service3 = service.Game.Services.GetService <IPathfindingService>(); Diagnostics.Assert(service2 != null); base.ListNearbyVillages(army); if (base.PointsOfInterest.Count != 0) { for (int i = base.PointsOfInterest.Count - 1; i >= 0; i--) { PointOfInterest pointOfInterest = base.PointsOfInterest[i]; if (pointOfInterest.PointOfInterestImprovement != null && (pointOfInterest.Empire == null || pointOfInterest.Empire.Index != army.Empire.Index)) { Region region = service2.GetRegion(pointOfInterest.WorldPosition); if (region != null && region.MinorEmpire != null) { Village village = region.MinorEmpire.GetAgency <BarbarianCouncil>().Villages.FirstOrDefault((Village iterator) => iterator.WorldPosition == pointOfInterest.WorldPosition); if (village != null) { targets.Add(village); } } } } } List <WorldPosition> list = new List <WorldPosition>(); for (int j = 0; j < 6; j++) { WorldPosition neighbourTile = service2.GetNeighbourTile(army.WorldPosition, (WorldOrientation)j, 1); if (neighbourTile.IsValid && service3.IsTransitionPassable(army.WorldPosition, neighbourTile, army, PathfindingFlags.IgnoreArmies | PathfindingFlags.IgnoreOtherEmpireDistrict | PathfindingFlags.IgnoreDiplomacy | PathfindingFlags.IgnoreFogOfWar | PathfindingFlags.IgnoreZoneOfControl | PathfindingFlags.IgnorePOI | PathfindingFlags.IgnoreSieges | PathfindingFlags.IgnoreKaijuGarrisons, null)) { list.Add(neighbourTile); } } List <int> list2 = new List <int>(); for (int k = 0; k < list.Count; k++) { Region region2 = service2.GetRegion(list[k]); if (region2 != null && !list2.Contains(region2.Index)) { list2.Add(region2.Index); KaijuEmpire kaijuEmpire = region2.KaijuEmpire; if (kaijuEmpire != null) { KaijuCouncil agency = kaijuEmpire.GetAgency <KaijuCouncil>(); if (agency != null) { Kaiju kaiju = agency.Kaiju; if (kaiju != null && kaiju.OnGarrisonMode()) { KaijuGarrison kaijuGarrison = kaiju.KaijuGarrison; if (kaijuGarrison != null && list.Contains(kaijuGarrison.WorldPosition)) { targets.Add(kaijuGarrison); } } } } if (region2.City != null && region2.City.Empire != null && region2.City.Empire.Index != army.Empire.Index) { for (int l = 0; l < region2.City.Districts.Count; l++) { District district = region2.City.Districts[l]; if (list.Contains(district.WorldPosition) && district.Type != DistrictType.Exploitation) { targets.Add(district); } } if (region2.City.Camp != null && list.Contains(region2.City.Camp.WorldPosition)) { targets.Add(region2.City.Camp); } } } } global::Game game = service.Game as global::Game; if (game == null) { return; } for (int m = 0; m < game.Empires.Length; m++) { if (m != army.Empire.Index) { DepartmentOfDefense agency2 = game.Empires[m].GetAgency <DepartmentOfDefense>(); if (agency2 != null) { for (int n = 0; n < agency2.Armies.Count; n++) { Army army2 = agency2.Armies[n]; if (list.Contains(army2.WorldPosition)) { if (army2 is KaijuArmy) { KaijuArmy kaijuArmy = army2 as KaijuArmy; if (kaijuArmy != null && !kaijuArmy.Kaiju.OnArmyMode()) { goto IL_389; } } targets.Add(army2); } IL_389 :; } } DepartmentOfTheInterior agency3 = game.Empires[m].GetAgency <DepartmentOfTheInterior>(); if (agency3 != null) { for (int num = 0; num < agency3.TamedKaijuGarrisons.Count; num++) { KaijuGarrison kaijuGarrison2 = agency3.TamedKaijuGarrisons[num]; if (kaijuGarrison2 != null) { Kaiju kaiju2 = kaijuGarrison2.Kaiju; if (kaiju2 != null && kaiju2.OnGarrisonMode() && list.Contains(kaijuGarrison2.WorldPosition)) { targets.Add(kaijuGarrison2); } } } } } } }