private void Order_KaijuRisen(object sender, TicketRaisedEventArgs e) { if (e.Result == PostOrderResponse.Processed) { OrderKaijuChangeMode orderKaijuChangeMode = e.Order as OrderKaijuChangeMode; Kaiju kaiju = null; if (!this.gameEntityRepositoryService.TryGetValue <Kaiju>(orderKaijuChangeMode.KaijuGUID, out kaiju) || !this.MajorEmpire.TamedKaijus.Contains(kaiju)) { return; } AICommander aicommander = this.aiCommanders.Find((AICommander match) => match.ForceArmyGUID == kaiju.KaijuArmy.GUID); if (aicommander == null) { this.AddCommander(new AICommander_KaijuSupport { ForceArmyGUID = kaiju.KaijuArmy.GUID, Empire = base.AIEntity.Empire, AIPlayer = base.AIEntity.AIPlayer }); return; } aicommander.Initialize(); aicommander.Load(); aicommander.CreateMission(); } }
public override void Execute(Army army, global::PlayerController playerController, out Ticket ticket, EventHandler <TicketRaisedEventArgs> ticketRaisedEventHandler, params object[] parameters) { ticket = null; ArmyAction.FailureFlags.Clear(); if (army is KaijuArmy) { KaijuArmy kaijuArmy = army as KaijuArmy; if (kaijuArmy != null) { OrderKaijuChangeMode order = new OrderKaijuChangeMode(kaijuArmy.Kaiju, true, false, true); Diagnostics.Assert(playerController != null); playerController.PostOrder(order, out ticket, ticketRaisedEventHandler); } } }
private SynchronousJobState SyncrhronousJob_Relocate() { if (this.validatedRelocationMessages.Count > 0) { for (int i = this.validatedRelocationMessages.Count - 1; i >= 0; i--) { bool flag = false; bool flag2 = false; KaijuRelocationMessage kaijuRelocationMessage = this.validatedRelocationMessages[i]; Kaiju kaiju = null; List <StaticString> list = new List <StaticString>(); if (!this.gameEntityRepositoryService.TryGetValue <Kaiju>(kaijuRelocationMessage.KaijuGUID, out kaiju) || !this.MajorEmpire.TamedKaijus.Contains(kaiju) || !this.garrisonAction_MigrateKaiju.CanExecute(kaiju.KaijuGarrison, ref list, new object[0])) { flag2 = true; } if (kaiju != null && kaiju.KaijuGarrison != null && kaiju.KaijuGarrison.IsInEncounter) { flag = true; } if (!flag2) { OrderRelocateKaiju order = new OrderRelocateKaiju(kaiju.GUID, kaijuRelocationMessage.TargetPosition, this.garrisonAction_MigrateKaiju.Name); base.AIEntity.Empire.PlayerControllers.AI.PostOrder(order); } if (!flag) { this.validatedRelocationMessages.RemoveAt(i); base.AIEntity.AIPlayer.Blackboard.CancelMessage(kaijuRelocationMessage); } } if (this.validatedRelocationMessages.Count == 0 && this.KaijusToRise.Count == 0) { return(SynchronousJobState.Success); } return(SynchronousJobState.Running); } else { if (this.KaijusToRise.Count <= 0) { return(SynchronousJobState.Success); } int j = this.KaijusToRise.Count - 1; while (j >= 0) { bool flag3 = false; bool flag4 = false; Kaiju kaiju2 = null; List <StaticString> list2 = new List <StaticString>(); if (!this.gameEntityRepositoryService.TryGetValue <Kaiju>(this.KaijusToRise[j], out kaiju2) || !this.MajorEmpire.TamedKaijus.Contains(kaiju2) || !this.garrisonAction_RiseKaiju.CanExecute(kaiju2.KaijuGarrison, ref list2, new object[0])) { flag3 = true; } if (kaiju2 != null && kaiju2.KaijuGarrison != null && kaiju2.KaijuGarrison.IsInEncounter) { flag4 = true; } if (!flag3) { List <StaticString> list3 = new List <StaticString>(); if (this.garrisonAction_MigrateKaiju.CanExecute(kaiju2.KaijuGarrison, ref list3, new object[0])) { Army army = this.ChooseArmyToSupport(); if (army != null && this.worldPositionningService.GetDistance(kaiju2.WorldPosition, army.WorldPosition) > 6) { Region bestSupportRegionForKaiju = this.GetBestSupportRegionForKaiju(kaiju2, army, null); if (bestSupportRegionForKaiju != null && kaiju2.Region != bestSupportRegionForKaiju) { WorldPosition validKaijuSupportPosition = this.GetValidKaijuSupportPosition(bestSupportRegionForKaiju, army); if (validKaijuSupportPosition.IsValid) { OrderRelocateKaiju order2 = new OrderRelocateKaiju(kaiju2.GUID, validKaijuSupportPosition, this.garrisonAction_MigrateKaiju.Name); base.AIEntity.Empire.PlayerControllers.AI.PostOrder(order2); return(SynchronousJobState.Running); } } } } OrderKaijuChangeMode order3 = new OrderKaijuChangeMode(kaiju2, false, true, true); Ticket ticket = null; base.AIEntity.Empire.PlayerControllers.AI.PostOrder(order3, out ticket, new EventHandler <TicketRaisedEventArgs>(this.Order_KaijuRisen)); } if (!flag4) { this.KaijusToRise.RemoveAt(j); if (this.KaijusToRise.Count == 0) { return(SynchronousJobState.Success); } return(SynchronousJobState.Running); } else { j--; } } if (this.KaijusToRise.Count == 0) { return(SynchronousJobState.Success); } return(SynchronousJobState.Running); } }