protected override State Execute(QuestBehaviour questBehaviour, params object[] parameters) { global::Empire empire2 = this.Game.Empires.FirstOrDefault((global::Empire empire) => empire.Bits == questBehaviour.Quest.EmpireBits); if (empire2 == null) { Diagnostics.LogError("Failed to retrieve the (lesser) quest empire."); return(State.Running); } ulong num; if (questBehaviour.TryGetQuestVariableValueByName <ulong>(this.ArmyGUIDVarName, out num) && num != 0UL) { IGameEntityRepositoryService service = this.Game.Services.GetService <IGameEntityRepositoryService>(); IGameEntity gameEntity = null; if (!service.TryGetValue(num, out gameEntity)) { Diagnostics.LogWarning("Action failed getting the targeted Army"); return(State.Success); } Army army = gameEntity as Army; if (army == null) { Diagnostics.LogError("Action failed getting the targeted Army"); return(State.Success); } OrderDestroyArmy orderDestroyArmy = new OrderDestroyArmy(army.Empire.Index, num); Diagnostics.Log("Posting order: {0}.", new object[] { orderDestroyArmy.ToString() }); empire2.PlayerControllers.Server.PostOrder(orderDestroyArmy); } return(State.Success); }
protected override State Execute(QuestBehaviour questBehaviour, params object[] parameters) { global::Empire empire2 = this.Game.Empires.FirstOrDefault((global::Empire empire) => empire.Bits == questBehaviour.Quest.EmpireBits); if (empire2 == null) { Diagnostics.LogError("Failed to retrieve the (lesser) quest empire."); return(State.Running); } IEnumerator gameEntities = this.Game.Services.GetService <IGameEntityRepositoryService>().GameEntities; while (gameEntities.MoveNext()) { object obj = gameEntities.Current; Army army = (obj as IGameEntity) as Army; if (army != null && army.HasTag(this.ArmyTag)) { OrderDestroyArmy orderDestroyArmy = new OrderDestroyArmy(army.Empire.Index, army.GUID); Diagnostics.Log("Posting order: {0}.", new object[] { orderDestroyArmy.ToString() }); empire2.PlayerControllers.Server.PostOrder(orderDestroyArmy); } } return(State.Success); }