public override bool Initialize(QuestBehaviour questBehaviour) { City city; if (this.CityGUID == GameEntityGUID.Zero && !string.IsNullOrEmpty(this.CityVarName) && questBehaviour.TryGetQuestVariableValueByName <City>(this.CityVarName, out city)) { if (city == null) { Diagnostics.LogError("City is null or empty, quest variable (varname: '{0}')", new object[] { this.CityVarName }); return(false); } this.CityGUID = city.GUID; } ulong num; if (this.ArmyGuid == 0UL && !string.IsNullOrEmpty(this.ArmyGuidVarName) && questBehaviour.TryGetQuestVariableValueByName <ulong>(this.ArmyGuidVarName, out num)) { if (num == 0UL) { Diagnostics.LogError("QuestBehaviourTreeNode_ConditionCheck_IsArmyAtCity : Army guid is invalid"); return(false); } this.ArmyGuid = new GameEntityGUID(num); } return(base.Initialize(questBehaviour)); }
protected override bool Initialize(QuestBehaviour questBehaviour) { Diagnostics.Log("UpdateVariable.Initialize"); global::Game game = Services.GetService <IGameService>().Game as global::Game; if (game == null) { Diagnostics.LogError("Cannot retrieve game service, Action_uptateVariable"); } if (this.EmpireIndex != -1) { QuestVariable questVariable = questBehaviour.QuestVariables.FirstOrDefault((QuestVariable match) => match.Name == this.EmpireVarName); if (questVariable == null) { questVariable = new QuestVariable(this.EmpireVarName); questBehaviour.QuestVariables.Add(questVariable); } questVariable.Object = game.Empires[this.EmpireIndex]; } MajorEmpire majorEmpire; if (this.EmpireIndex == -1 && this.EmpireVarName != string.Empty && questBehaviour.TryGetQuestVariableValueByName <MajorEmpire>(this.EmpireVarName, out majorEmpire)) { this.EmpireIndex = majorEmpire.Index; } return(true); }
protected override bool Initialize(QuestBehaviour questBehaviour) { if (this.WinnerArmyGUID != GameEntityGUID.Zero && !questBehaviour.QuestVariables.Exists((QuestVariable match) => match.Name == this.Output_WinnerVarName)) { QuestVariable questVariable = new QuestVariable(this.Output_WinnerVarName); questVariable.Object = this.WinnerArmyGUID; questBehaviour.QuestVariables.Add(questVariable); } this.SaveEnemyArmyGUIDs(questBehaviour); MajorEmpire majorEmpire; if (this.FocusedEmpireVarName != string.Empty && questBehaviour.TryGetQuestVariableValueByName <MajorEmpire>(this.FocusedEmpireVarName, out majorEmpire)) { this.FocusedEmpireIndex = majorEmpire.Index; } if (this.UpdateVarName) { this.UpdateVars = true; } else { this.UpdateVars = false; } IGameService service = Services.GetService <IGameService>(); this.gameEntityRepositoryService = service.Game.Services.GetService <IGameEntityRepositoryService>(); return(base.Initialize(questBehaviour)); }
protected override bool Initialize(QuestBehaviour questBehaviour) { IGameService service = Services.GetService <IGameService>(); if (service == null || service.Game == null) { Diagnostics.LogError("Failed to retrieve the game service."); return(false); } this.Game = (service.Game as global::Game); if (this.Game == null) { Diagnostics.LogError("Failed to cast gameService.Game to Game."); return(false); } if (this.ArmyGUID == 0UL) { ulong armyGUID; if (!string.IsNullOrEmpty(this.ArmyGUIDVarName) && questBehaviour.TryGetQuestVariableValueByName <ulong>(this.ArmyGUIDVarName, out armyGUID)) { this.ArmyGUID = armyGUID; } } else { QuestVariable questVariable = questBehaviour.QuestVariables.FirstOrDefault((QuestVariable match) => match.Name == this.ArmyGUIDVarName); if (questVariable == null) { questVariable = new QuestVariable(this.ArmyGUIDVarName); questBehaviour.QuestVariables.Add(questVariable); } questVariable.Object = this.ArmyGUID; } return(base.Initialize(questBehaviour)); }
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, EventTerraformDeviceEntityCreated e, params object[] parameters) { global::Game game = Services.GetService <IGameService>().Game as global::Game; if (this.DevicePositionVarName == string.Empty) { return(State.Success); } IEnumerable <WorldPosition> source; if (this.DevicePositionVarName != null && questBehaviour.TryGetQuestVariableValueByName <WorldPosition>(this.DevicePositionVarName, out source)) { this.DevicePositions = source.ToArray <WorldPosition>(); } if (this.DevicePositions != null && this.DevicePositions[0] == e.TerraformDevice.WorldPosition) { IQuestManagementService service = game.Services.GetService <IQuestManagementService>(); if (service != null) { this.EntityGUID = e.TerraformDevice.GUID; QuestVariable questVariable = new QuestVariable(this.Output_EntityVarName, e.TerraformDevice); service.State.AddGlobalVariable(questBehaviour.Initiator.Index, questVariable); } return(State.Success); } return(State.Running); }
protected override bool Initialize(QuestBehaviour questBehaviour) { if (string.IsNullOrEmpty(this.ConstructionName)) { if (string.IsNullOrEmpty(this.ConstructionNameVarName)) { Diagnostics.LogError("Missing attribute 'ConstructionNameVarName'"); return(false); } string text; if (!questBehaviour.TryGetQuestVariableValueByName <string>(this.ConstructionNameVarName, out text)) { Diagnostics.LogError("Cannot retrieve quest variable (varname: '{0}')", new object[] { this.ConstructionNameVarName }); return(false); } if (string.IsNullOrEmpty(text)) { Diagnostics.LogError("Construction name is null or empty (varname: '{0}')", new object[] { this.ConstructionNameVarName }); return(false); } this.ConstructionName = text; } if (this.CityGUID != GameEntityGUID.Zero && !string.IsNullOrEmpty(this.Output_CityVarName) && !questBehaviour.QuestVariables.Exists((QuestVariable match) => match.Name == this.Output_CityVarName)) { IGameService service = Services.GetService <IGameService>(); if (service == null) { Diagnostics.LogError("Unable to retrieve the game service."); return(false); } IGameEntityRepositoryService service2 = service.Game.Services.GetService <IGameEntityRepositoryService>(); if (service2 == null) { Diagnostics.LogError("Unable to retrieve the game entity repository service."); return(false); } City @object; if (service2.TryGetValue <City>(this.CityGUID, out @object)) { QuestVariable questVariable = new QuestVariable(this.Output_CityVarName); questVariable.Object = @object; questBehaviour.QuestVariables.Add(questVariable); } } City city = null; if (this.CityGUID == GameEntityGUID.Zero && !string.IsNullOrEmpty(this.TargetCityVarName) && questBehaviour.TryGetQuestVariableValueByName <City>(this.TargetCityVarName, out city)) { this.CityGUID = city.GUID; } return(base.Initialize(questBehaviour)); }
protected override State Execute(QuestBehaviour questBehaviour, params object[] parameters) { if (this.SpawnLocationVarName != null) { IEnumerable <WorldPosition> source; WorldPosition worldPosition; if (questBehaviour.TryGetQuestVariableValueByName <WorldPosition>(this.SpawnLocationVarName, out source)) { this.SpawnLocations = source.ToArray <WorldPosition>(); } else if (questBehaviour.TryGetQuestVariableValueByName <WorldPosition>(this.SpawnLocationVarName, out worldPosition)) { this.SpawnLocations = new WorldPosition[] { worldPosition }; } } if (this.SpawnLocations != null) { IGameEntity gameEntity; if (this.gameEntityRepositoryService != null && this.gameEntityRepositoryService.TryGetValue(this.ArmyGUID, out gameEntity) && gameEntity != null) { return(State.Success); } this.SpawnArmy(questBehaviour); if (!string.IsNullOrEmpty(this.DroplistRewardOnDeathName)) { IGameService service = Services.GetService <IGameService>(); Diagnostics.Assert(service != null && service.Game != null && service.Game is global::Game); IQuestRewardRepositoryService service2 = (service.Game as global::Game).GetService <IQuestRewardRepositoryService>(); Diagnostics.Assert(service2 != null); service2.AddRewardForArmyKill(this.ArmyGUID, this.DroplistRewardOnDeathName); } } else { Diagnostics.LogError("Position to spawn is invalid: {0}", new object[] { questBehaviour.ToStringVariables() }); } return(State.Success); }
private void RefreshVar(QuestBehaviour questBehaviour) { object obj; if (questBehaviour.TryGetQuestVariableValueByName <object>(this.ArmyGuidVarName, out obj)) { ulong num; if (obj is ulong) { num = (ulong)obj; } else if (obj is GameEntityGUID) { num = (GameEntityGUID)obj; } else { num = 0UL; } if (num != 0UL && this.ArmyGuid != num) { this.ArmyGuid = num; } } if (questBehaviour.TryGetQuestVariableValueByName <object>(this.CityVarName, out obj)) { if (obj is City) { this.CityGUID = ((City)obj).GUID; return; } if (obj is ulong) { this.CityGUID = (ulong)obj; return; } if (obj is GameEntityGUID) { this.CityGUID = (GameEntityGUID)obj; } } }
protected override State Execute(QuestBehaviour questBehaviour, params object[] parameters) { if (!string.IsNullOrEmpty(this.EmpireIndexVarName)) { int num = -1; if (!questBehaviour.TryGetQuestVariableValueByName <int>(this.EmpireIndexVarName, out num)) { Diagnostics.LogError("Cannot retrieve quest variable (varname: '{0}')", new object[] { this.EmpireIndexVarName }); return(State.Failure); } if (num != questBehaviour.Initiator.Index) { return(State.Success); } IGameService service = Services.GetService <IGameService>(); if (service == null) { return(State.Failure); } global::Game game = service.Game as global::Game; if (game == null) { return(State.Failure); } DepartmentOfTheInterior agency = game.Empires[num].GetAgency <DepartmentOfTheInterior>(); if (agency == null) { return(State.Failure); } if (agency.Cities.Count == 0) { Diagnostics.LogError("Empire does not have cities"); return(State.Failure); } City city = agency.Cities[0]; if (string.IsNullOrEmpty(this.Output_CityVarName)) { Diagnostics.LogError("Cannot retrieve quest variable (varname: '{0}')", new object[] { this.Output_CityVarName }); return(State.Failure); } this.UpdateQuestVariable(questBehaviour, this.Output_CityVarName, city); this.StoredCity = city.GUID; } return(State.Success); }
public override bool Initialize(QuestBehaviour questBehaviour) { if (this.RegionIndex == -1) { Region region; if (!questBehaviour.TryGetQuestVariableValueByName <Region>(this.RegionVarName, out region)) { Diagnostics.LogError("Cannot retrieve quest variable (varname: '{0}')", new object[] { this.RegionVarName }); return(false); } if (region == null) { Diagnostics.LogError("Region is null or empty, quest variable (varname: '{0}')", new object[] { this.RegionVarName }); return(false); } this.RegionIndex = region.Index; } IEnumerable <global::Empire> enumerable; if (this.IgnoredEmpiresIndex == null && questBehaviour.TryGetQuestVariableValueByName <global::Empire>(this.IgnoredEmpiresVarName, out enumerable)) { int num = enumerable.Count <global::Empire>(); this.IgnoredEmpiresIndex = new int[num]; int num2 = 0; foreach (global::Empire empire in enumerable) { this.IgnoredEmpiresIndex[num2] = empire.Index; num2++; } } return(base.Initialize(questBehaviour)); }
protected override bool Initialize(QuestBehaviour questBehaviour) { if (string.IsNullOrEmpty(this.DiplomaticTermDefinitionName)) { return(false); } MajorEmpire majorEmpire; if (this.TargetEmpireVarName != string.Empty && questBehaviour.TryGetQuestVariableValueByName <MajorEmpire>(this.TargetEmpireVarName, out majorEmpire)) { this.TargetEmpireIndex = majorEmpire.Index; } return(base.Initialize(questBehaviour)); }
public override bool Initialize(QuestBehaviour questBehaviour) { if (!string.IsNullOrEmpty(this.InterpretedVarName)) { Diagnostics.LogError("InterpretedVarName is deprecated, use InterpretedValue instead"); } global::Empire empire; if (this.EmpireIndex == -1 && questBehaviour.TryGetQuestVariableValueByName <global::Empire>(this.EmpireVarName, out empire) && empire != null) { this.EmpireIndex = empire.Index; } return(base.Initialize(questBehaviour)); }
private void SaveEnemyArmyGUIDs(QuestBehaviour questBehaviour) { if (this.EnemyArmyGUIDVarName != null && this.EnemyArmyGUIDs == null) { this.EnemyArmyGUIDs = new ulong[this.EnemyArmyGUIDVarName.Length]; for (int i = 0; i < this.EnemyArmyGUIDVarName.Length; i++) { ulong num = GameEntityGUID.Zero; if (!questBehaviour.TryGetQuestVariableValueByName <ulong>(this.EnemyArmyGUIDVarName[i], out num)) { this.EnemyArmyGUIDs = null; return; } this.EnemyArmyGUIDs[i] = num; } } }
protected override bool Initialize(QuestBehaviour questBehaviour) { IGameService service = Services.GetService <IGameService>(); global::Game game = service.Game as global::Game; if (service == null || service.Game == null || !(service.Game is global::Game)) { Diagnostics.LogError("Unable to retrieve the game service."); return(false); } IGameEntityRepositoryService service2 = service.Game.Services.GetService <IGameEntityRepositoryService>(); if (service2 == null) { Diagnostics.LogError("Unable to retrieve the game entity repository service."); return(false); } IEnumerable <WorldPosition> source; if (this.DevicePositions == null && questBehaviour.TryGetQuestVariableValueByName <WorldPosition>(this.DevicePositionVarName, out source)) { this.DevicePositions = source.ToArray <WorldPosition>(); } if (this.EntityGUID == 0UL) { this.EntityGUID = service2.GenerateGUID(); } QuestVariable questVariable = questBehaviour.GetQuestVariableByName(this.Output_EntityVarName); if (questVariable == null) { questVariable = new QuestVariable(this.Output_EntityVarName); questBehaviour.QuestVariables.Add(questVariable); IQuestManagementService service3 = game.Services.GetService <IQuestManagementService>(); if (service3 != null) { QuestVariable questVariable2 = new QuestVariable(this.Output_EntityVarName, this.EntityGUID); service3.State.AddGlobalVariable(questBehaviour.Initiator.Index, questVariable2); } } questVariable.Object = this.EntityGUID; return(base.Initialize(questBehaviour)); }
protected override State Execute(QuestBehaviour questBehaviour, params object[] parameters) { IEnumerable <WorldPosition> source; if (this.SpawnLocationVarName != null && questBehaviour.TryGetQuestVariableValueByName <WorldPosition>(this.SpawnLocationVarName, out source)) { this.SpawnLocations = source.ToArray <WorldPosition>(); } if (this.SpawnLocations != null) { this.SpawnArmies(questBehaviour); } else { Diagnostics.LogError("Position to spawn is invalid: {0}", new object[] { questBehaviour.ToStringVariables() }); } return(State.Success); }
protected override State Execute(QuestBehaviour questBehaviour, params object[] parameters) { if (!string.IsNullOrEmpty(this.ResourceName)) { if (!string.IsNullOrEmpty(this.EmpireIndexVarName)) { int num = -1; if (!questBehaviour.TryGetQuestVariableValueByName <int>(this.EmpireIndexVarName, out num)) { Diagnostics.LogError("Cannot retrieve quest variable (varname: '{0}')", new object[] { this.EmpireIndexVarName }); return(State.Failure); } if (num != questBehaviour.Initiator.Index) { return(State.Success); } } if (questBehaviour.Initiator is MajorEmpire && (questBehaviour.Initiator as MajorEmpire).ELCPIsEliminated) { return(State.Success); } if (this.ResourceName.Contains("Booster")) { for (int i = 0; i < this.Amount; i++) { OrderBuyoutAndActivateBooster order = new OrderBuyoutAndActivateBooster(questBehaviour.Initiator.Index, this.ResourceName, 0UL, false); questBehaviour.Initiator.PlayerControllers.Server.PostOrder(order); } } else { Order order2 = new OrderTransferResources(questBehaviour.Initiator.Index, this.ResourceName, (float)this.Amount, 0UL); questBehaviour.Initiator.PlayerControllers.Server.PostOrder(order2); } } return(State.Success); }
private void ComputeArmyGUID(QuestBehaviour questBehaviour) { if (this.ArmyGUID == GameEntityGUID.Zero) { ulong num; if (questBehaviour.TryGetQuestVariableValueByName <ulong>(this.ArmyGUIDVarName, out num)) { if (num == 0UL) { Diagnostics.LogWarning("[UpdateArmyObjective] Invalid Army GUID not found in quest variables, will try in Execute()"); } else { this.ArmyGUID = num; } } else { Diagnostics.LogWarning("[UpdateArmyObjective] Invalid Army GUID not found in quest variables, will try in Execute()"); } } }
protected override bool Initialize(QuestBehaviour questBehaviour) { if (this.TargetEmpireIndex == -1) { global::Empire empire; if (!questBehaviour.TryGetQuestVariableValueByName <global::Empire>(this.TargetEmpireVarName, out empire)) { Diagnostics.LogError("Cannot retrieve quest variable (varname: '{0}')", new object[] { this.TargetEmpireVarName }); return(false); } if (empire == null) { Diagnostics.LogError("Quest variable object is null (varname: '{0}')", new object[] { this.TargetEmpireVarName }); return(false); } this.TargetEmpireIndex = empire.Index; } IGameService service = Services.GetService <IGameService>(); if (service == null || service.Game == null) { Diagnostics.LogError("Failed to retrieve the game service."); return(false); } this.playerControllerRepositoryService = service.Game.Services.GetService <IPlayerControllerRepositoryService>(); if (this.playerControllerRepositoryService == null) { Diagnostics.LogError("Failed to retrieve the player controller repository service."); return(false); } this.game = (service.Game as global::Game); return(base.Initialize(questBehaviour)); }
public override bool Initialize(QuestBehaviour questBehaviour) { if (this.RegionIndex == -1) { Region region; if (!questBehaviour.TryGetQuestVariableValueByName <Region>(this.RegionVarName, out region)) { Diagnostics.LogError("Cannot retrieve quest variable (varname: '{0}')", new object[] { this.RegionVarName }); return(false); } if (region == null) { Diagnostics.LogError("Region is null or empty, quest variable (varname: '{0}')", new object[] { this.RegionVarName }); return(false); } this.RegionIndex = region.Index; } ulong num; if (!this.CheckAllArmies && this.ArmyGuid == 0UL && !string.IsNullOrEmpty(this.ArmyGuidVarName) && questBehaviour.TryGetQuestVariableValueByName <ulong>(this.ArmyGuidVarName, out num)) { if (num == 0UL) { Diagnostics.LogError("QuestBehaviourTreeNode_ConditionCheck_IsArmyAlive : Army guid is invalid"); return(false); } this.ArmyGuid = new GameEntityGUID(num); } return(base.Initialize(questBehaviour)); }
protected override State Execute(QuestBehaviour questBehaviour, EventDiplomaticContractStateChange e, params object[] parameters) { Empire empireWhichInitiated = e.DiplomaticContract.EmpireWhichInitiated; Empire empireWhichReceives = e.DiplomaticContract.EmpireWhichReceives; if (base.CheckAgainstQuestInitiatorFilter(questBehaviour, empireWhichInitiated, base.QuestInitiatorFilter) || (this.IsMutual && base.CheckAgainstQuestInitiatorFilter(questBehaviour, empireWhichReceives, base.QuestInitiatorFilter))) { if (this.State != QuestBehaviourTreeNode_Decorator_DiplomaticContract.QuestDiplomaticContractState.Any && !e.DiplomaticContract.State.ToString().Equals(this.State.ToString())) { return(Amplitude.Unity.AI.BehaviourTree.State.Running); } if (!string.IsNullOrEmpty(this.TargetEmpireVarName) || this.TargetEmpireIndex != -1) { if (this.TargetEmpireIndex == -1) { MajorEmpire majorEmpire; if (questBehaviour.TryGetQuestVariableValueByName <MajorEmpire>(this.TargetEmpireVarName, out majorEmpire) && ((!this.IsMutual && empireWhichReceives != majorEmpire) || (this.IsMutual && empireWhichReceives != majorEmpire && empireWhichInitiated != majorEmpire))) { return(Amplitude.Unity.AI.BehaviourTree.State.Running); } } else if ((!this.IsMutual && empireWhichReceives.Index != this.TargetEmpireIndex) || (this.IsMutual && empireWhichReceives.Index != this.TargetEmpireIndex && empireWhichInitiated.Index != this.TargetEmpireIndex)) { return(Amplitude.Unity.AI.BehaviourTree.State.Running); } } for (int i = 0; i < e.DiplomaticContract.Terms.Count; i++) { if (e.DiplomaticContract.Terms[i].Definition.Name == this.DiplomaticTermDefinitionName) { return(Amplitude.Unity.AI.BehaviourTree.State.Success); } } } return(Amplitude.Unity.AI.BehaviourTree.State.Running); }
protected override bool Initialize(QuestBehaviour questBehaviour) { IGameService service = Services.GetService <IGameService>(); if (service == null) { Diagnostics.LogError("Unable to retrieve the game service."); return(false); } this.GameEntityRepositoryService = service.Game.Services.GetService <IGameEntityRepositoryService>(); if (this.GameEntityRepositoryService == null) { Diagnostics.LogError("Unable to retrieve the game entity repository service."); return(false); } District @object; if (this.DistrictGUID != GameEntityGUID.Zero && !string.IsNullOrEmpty(this.Output_DistrictSimObjectVarName) && !questBehaviour.QuestVariables.Exists((QuestVariable match) => match.Name == this.Output_DistrictSimObjectVarName) && this.GameEntityRepositoryService.TryGetValue <District>(this.DistrictGUID, out @object)) { QuestVariable questVariable = new QuestVariable(this.Output_DistrictSimObjectVarName); questVariable.Object = @object; questBehaviour.QuestVariables.Add(questVariable); } City object2; if (this.CityGUID != GameEntityGUID.Zero && !string.IsNullOrEmpty(this.Output_CityVarName) && !questBehaviour.QuestVariables.Exists((QuestVariable match) => match.Name == this.Output_CityVarName) && this.GameEntityRepositoryService.TryGetValue <City>(this.CityGUID, out object2)) { QuestVariable questVariable2 = new QuestVariable(this.Output_CityVarName); questVariable2.Object = object2; questBehaviour.QuestVariables.Add(questVariable2); } City city = null; if (this.CityGUID == GameEntityGUID.Zero && !string.IsNullOrEmpty(this.TargetCityVarName) && questBehaviour.TryGetQuestVariableValueByName <City>(this.TargetCityVarName, out city) && city != null) { this.CityGUID = city.GUID; } return(base.Initialize(questBehaviour)); }
protected void SpawnArmy(QuestBehaviour questBehaviour) { if (!string.IsNullOrEmpty(this.ArmyDroplist)) { IGameService service = Services.GetService <IGameService>(); if (service == null || service.Game == null) { Diagnostics.LogError("Failed to retrieve the game service."); return; } global::Game game = service.Game as global::Game; if (game == null) { Diagnostics.LogError("Failed to cast gameService.Game to Game."); return; } IDatabase <Droplist> database = Databases.GetDatabase <Droplist>(false); if (database == null) { return; } string text = this.ArmyDroplist; if (this.ArmyDroplistSuffix != string.Empty) { text = text + "_" + this.ArmyDroplistSuffix; } Droplist droplist; if (!database.TryGetValue(text, out droplist)) { Diagnostics.LogError("Cannot retrieve drop list '{0}' in quest definition '{1}'", new object[] { text, questBehaviour.Quest.QuestDefinition.Name }); return; } if (!string.IsNullOrEmpty(this.EmpireArmyOwnerVarName)) { global::Empire empire = null; object obj; if (questBehaviour.TryGetQuestVariableValueByName <object>(this.EmpireArmyOwnerVarName, out obj)) { if (obj is global::Empire) { empire = (obj as global::Empire); } else if (obj is int) { empire = game.Empires[(int)obj]; } if (empire != null) { this.EmpireArmyOwner = empire; } } } global::Empire empire2 = this.EmpireArmyOwner; if (empire2 == null || empire2 is LesserEmpire || this.UseBehaviorInitiatorEmpire) { empire2 = questBehaviour.Initiator; } if (this.UseBehaviorInitiatorEmpire) { this.EmpireArmyOwner = questBehaviour.Initiator; } if (this.EmpireArmyOwner is MajorEmpire && (this.EmpireArmyOwner as MajorEmpire).ELCPIsEliminated) { return; } Droplist droplist2; DroppableArmyDefinition droppableArmyDefinition = droplist.Pick(empire2, out droplist2, new object[0]) as DroppableArmyDefinition; if (droppableArmyDefinition != null) { int num = 0; if (this.ScaleWithMaxEra) { num = DepartmentOfScience.GetMaxEraNumber() - 1; } int val = 0; IDatabase <AnimationCurve> database2 = Databases.GetDatabase <AnimationCurve>(false); AnimationCurve animationCurve; if (database2 != null && database2.TryGetValue(QuestBehaviourTreeNode_Action_SpawnArmy.questUnitLevelEvolution, out animationCurve)) { float propertyValue = questBehaviour.Initiator.GetPropertyValue(SimulationProperties.GameSpeedMultiplier); val = (int)animationCurve.EvaluateWithScaledAxis((float)game.Turn, propertyValue, 1f); val = Math.Max(0, Math.Min(100, val)); } num = Math.Max(num, val); StaticString[] array = Array.ConvertAll <string, StaticString>(droppableArmyDefinition.UnitDesigns, (string input) => input); bool flag = false; IDatabase <UnitDesign> database3 = Databases.GetDatabase <UnitDesign>(false); for (int i = 0; i < array.Length; i++) { UnitDesign unitDesign; if (database3.TryGetValue(array[i], out unitDesign) && unitDesign != null && unitDesign.Tags.Contains(DownloadableContent16.TagSeafaring)) { flag = true; break; } } IEnumerable <WorldPosition> enumerable = null; questBehaviour.TryGetQuestVariableValueByName <WorldPosition>(this.ForbiddenSpawnLocationVarName, out enumerable); List <WorldPosition> list = this.SpawnLocations.ToList <WorldPosition>().Randomize(null); IWorldPositionningService service2 = game.Services.GetService <IWorldPositionningService>(); IPathfindingService service3 = game.Services.GetService <IPathfindingService>(); Diagnostics.Assert(service2 != null); WorldPosition worldPosition = WorldPosition.Invalid; if (!questBehaviour.Quest.QuestDefinition.IsGlobal) { PathfindingMovementCapacity pathfindingMovementCapacity = PathfindingMovementCapacity.Water; if (!flag) { pathfindingMovementCapacity |= PathfindingMovementCapacity.Ground; } for (int j = 0; j < list.Count; j++) { WorldPosition worldPosition2 = list[j]; if (DepartmentOfDefense.CheckWhetherTargetPositionIsValidForUseAsArmySpawnLocation(worldPosition2, pathfindingMovementCapacity)) { if (enumerable != null) { if (enumerable.Contains(worldPosition2)) { goto IL_330; } this.AddPositionToForbiddenSpawnPosition(questBehaviour, worldPosition2); } worldPosition = worldPosition2; break; } IL_330 :; } if (!service3.IsTileStopable(worldPosition, PathfindingMovementCapacity.Ground | PathfindingMovementCapacity.Water, PathfindingFlags.IgnoreFogOfWar)) { worldPosition = WorldPosition.Invalid; } if (!worldPosition.IsValid && list.Count > 0) { List <WorldPosition> list2 = new List <WorldPosition>(); Queue <WorldPosition> queue = new Queue <WorldPosition>(); worldPosition = list[0]; bool flag2 = false; if (worldPosition.IsValid) { flag2 = service2.IsWaterTile(worldPosition); } do { if (queue.Count > 0) { worldPosition = queue.Dequeue(); } for (int k = 0; k < 6; k++) { WorldPosition neighbourTileFullCyclic = service2.GetNeighbourTileFullCyclic(worldPosition, (WorldOrientation)k, 1); if (!list2.Contains(neighbourTileFullCyclic) && list2.Count < 19) { queue.Enqueue(neighbourTileFullCyclic); list2.Add(neighbourTileFullCyclic); } } if (!DepartmentOfDefense.CheckWhetherTargetPositionIsValidForUseAsArmySpawnLocation(worldPosition, pathfindingMovementCapacity) || !service3.IsTileStopable(worldPosition, PathfindingMovementCapacity.Ground | PathfindingMovementCapacity.Water, PathfindingFlags.IgnoreFogOfWar) || flag2 != service2.IsWaterTile(worldPosition)) { worldPosition = WorldPosition.Invalid; } }while (worldPosition == WorldPosition.Invalid && queue.Count > 0); } if (!worldPosition.IsValid) { string format = "Cannot find a valid position to spawn on: {0}"; object[] array2 = new object[1]; array2[0] = string.Join(",", list.Select(delegate(WorldPosition position) { WorldPosition worldPosition3 = position; return(worldPosition3.ToString()); }).ToArray <string>()); Diagnostics.LogError(format, array2); return; } } OrderSpawnArmy orderSpawnArmy; if (worldPosition.IsValid) { list.Clear(); list.Add(worldPosition); WorldOrientation worldOrientation = WorldOrientation.East; for (int l = 0; l < 6; l++) { WorldPosition neighbourTile = service2.GetNeighbourTile(worldPosition, worldOrientation, 1); bool flag3 = flag == service2.IsWaterTile(neighbourTile); if (neighbourTile.IsValid && flag3 && service3.IsTileStopable(worldPosition, PathfindingMovementCapacity.Ground | PathfindingMovementCapacity.Water, PathfindingFlags.IgnoreFogOfWar)) { list.Add(neighbourTile); } worldOrientation = worldOrientation.Rotate(1); } orderSpawnArmy = new OrderSpawnArmy(this.EmpireArmyOwner.Index, list.ToArray(), num, true, this.CanMoveOnSpawn, true, questBehaviour.Quest.QuestDefinition.IsGlobal || this.ForceGlobalArmySymbol, array); } else { orderSpawnArmy = new OrderSpawnArmy(this.EmpireArmyOwner.Index, list.ToArray(), num, true, this.CanMoveOnSpawn, true, questBehaviour.Quest.QuestDefinition.IsGlobal || this.ForceGlobalArmySymbol, array); } orderSpawnArmy.GameEntityGUID = this.ArmyGUID; Diagnostics.Log("Posting order: {0} at {1}", new object[] { orderSpawnArmy.ToString(), worldPosition }); if (!string.IsNullOrEmpty(this.TransferResourceName) && this.TransferResourceAmount > 0) { Ticket ticket; this.EmpireArmyOwner.PlayerControllers.Server.PostOrder(orderSpawnArmy, out ticket, new EventHandler <TicketRaisedEventArgs>(this.OrderSpawnArmy_TicketRaised)); return; } this.EmpireArmyOwner.PlayerControllers.Server.PostOrder(orderSpawnArmy); } } }
private bool TryInitializingTargets(QuestBehaviour questBehaviour, bool forceUpdate = false) { bool result = true; if ((this.TargetRegionIndex == -1 || forceUpdate) && !string.IsNullOrEmpty(this.TargetRegionVarName)) { Region region = null; if (!questBehaviour.TryGetQuestVariableValueByName <Region>(this.TargetRegionVarName, out region)) { Diagnostics.LogWarning("Cannot retrieve quest variable (varname: '{0}')", new object[] { this.TargetRegionVarName }); result = false; } else { this.TargetRegionIndex = region.Index; } } if ((this.TargetEntityGUID == GameEntityGUID.Zero || forceUpdate) && !string.IsNullOrEmpty(this.TargetVarName)) { IGameEntity gameEntity = null; if (!questBehaviour.TryGetQuestVariableValueByName <IGameEntity>(this.TargetVarName, out gameEntity)) { Diagnostics.LogWarning("Cannot retrieve quest variable (varname: '{0}')", new object[] { this.TargetVarName }); result = false; } else { this.TargetEntityGUID = gameEntity.GUID; } } if ((this.ForceArmyGUID == GameEntityGUID.Zero || forceUpdate) && !string.IsNullOrEmpty(this.ForceArmyVarName)) { IGameEntity gameEntity2 = null; ulong forceArmyGUID = 0UL; GameEntityGUID zero = GameEntityGUID.Zero; if (questBehaviour.TryGetQuestVariableValueByName <IGameEntity>(this.ForceArmyVarName, out gameEntity2)) { this.ForceArmyGUID = gameEntity2.GUID; } else if (questBehaviour.TryGetQuestVariableValueByName <ulong>(this.ForceArmyVarName, out forceArmyGUID)) { this.ForceArmyGUID = forceArmyGUID; } else if (questBehaviour.TryGetQuestVariableValueByName <GameEntityGUID>(this.ForceArmyVarName, out zero)) { this.ForceArmyGUID = zero; } else { Diagnostics.LogWarning("Cannot retrieve quest variable (varname: '{0}')", new object[] { this.ForceArmyVarName }); result = false; } } return(result); }
protected override bool Initialize(QuestBehaviour questBehaviour) { string text; if (!string.IsNullOrEmpty(this.ResourceNameVarName) && string.IsNullOrEmpty(this.ResourceName) && questBehaviour.TryGetQuestVariableValueByName <string>(this.ResourceNameVarName, out text)) { if (string.IsNullOrEmpty(text)) { Diagnostics.LogError("Resource name is null or empty, quest variable (varname: '{0}')", new object[] { this.ResourceNameVarName }); } this.ResourceName = text; } QuestRegisterVariable questRegisterVariable; if (!string.IsNullOrEmpty(this.WantedAmountVarName) && this.WantedAmount == -1 && questBehaviour.TryGetQuestVariableValueByName <QuestRegisterVariable>(this.WantedAmountVarName, out questRegisterVariable)) { if (questRegisterVariable == null) { Diagnostics.LogError("QuestRegisterVariable is null, quest variable (varname: '{0}')", new object[] { this.WantedAmountVarName }); } this.WantedAmount = questRegisterVariable.Value; } this.TryInitializingTargets(questBehaviour, false); return(base.Initialize(questBehaviour)); }
private void ComputeObjective(QuestBehaviour questBehaviour) { if (!string.IsNullOrEmpty(this.TargetCityGUIDVarName) || !string.IsNullOrEmpty(this.TargetCityVarName)) { IGameEntity gameEntity; if (this.CityGUID == GameEntityGUID.Zero || !this.gameEntityRepositoryService.TryGetValue(this.CityGUID, out gameEntity) || !(gameEntity is City)) { ulong num = GameEntityGUID.Zero; City city; if (this.TargetCityVarName != string.Empty && questBehaviour.TryGetQuestVariableValueByName <City>(this.TargetCityVarName, out city)) { this.CityGUID = city.GUID; this.Objective.TargetCityGUID = city.GUID; if (city.Empire != null) { this.Objective.TargetEmpireIndex = city.Empire.Index; } } else if (this.TargetCityGUIDVarName != string.Empty && questBehaviour.TryGetQuestVariableValueByName <ulong>(this.TargetCityGUIDVarName, out num)) { this.CityGUID = num; this.Objective.TargetCityGUID = num; IGameEntity gameEntity2; this.gameEntityRepositoryService.TryGetValue(num, out gameEntity2); if ((gameEntity2 as City).Empire != null) { this.Objective.TargetEmpireIndex = (gameEntity2 as City).Empire.Index; } } else if (this.CityGUID == GameEntityGUID.Zero || !this.gameEntityRepositoryService.TryGetValue(this.CityGUID, out gameEntity) || !(gameEntity is City)) { Diagnostics.LogWarning("[UpdateArmyObjective] No city can be found in the quest variables ({0} {1})", new object[] { this.TargetCityVarName, this.TargetCityGUIDVarName }); City city2 = null; if (questBehaviour.Initiator != null && this.Objective.BehaviourType == QuestArmyObjective.QuestBehaviourType.Offense) { DepartmentOfTheInterior agency = questBehaviour.Initiator.GetAgency <DepartmentOfTheInterior>(); if (agency != null && agency.Cities != null && agency.Cities.Count > 0) { city2 = agency.Cities[UnityEngine.Random.Range(0, agency.Cities.Count - 1)]; } } if (city2 == null) { this.Objective.BehaviourType = QuestArmyObjective.QuestBehaviourType.Roaming; } else { this.CityGUID = city2.GUID; this.Objective.TargetEmpireIndex = city2.Empire.Index; } } } this.Objective.TargetCityGUID = this.CityGUID; } if (this.Objective.TargetEmpireIndex == -1) { global::Empire empire = null; int targetEmpireIndex = -1; if (this.TargetEmpireVarName != string.Empty && questBehaviour.TryGetQuestVariableValueByName <global::Empire>(this.TargetEmpireVarName, out empire)) { this.Objective.TargetEmpireIndex = empire.Index; } else if (this.TargetEmpireIndexVarName != string.Empty && questBehaviour.TryGetQuestVariableValueByName <int>(this.TargetEmpireIndexVarName, out targetEmpireIndex)) { this.Objective.TargetEmpireIndex = targetEmpireIndex; } else if (this.TargetEmpireIndexVarName != string.Empty || this.TargetEmpireVarName != string.Empty) { this.Objective.TargetEmpireIndex = questBehaviour.Initiator.Index; } } if (this.SiegeTurnsNumberVarName != string.Empty) { int num2 = -1; if ((questBehaviour.TryGetQuestVariableValueByName <int>(this.SiegeTurnsNumberVarName, out num2) || int.TryParse(this.SiegeTurnsNumberVarName, out num2)) && num2 >= 0) { this.Objective.SiegeTurnsNumber = num2; } } if (this.TurnBeforeLeavingRegionVarName != string.Empty) { int num3 = -1; if ((questBehaviour.TryGetQuestVariableValueByName <int>(this.TurnBeforeLeavingRegionVarName, out num3) || int.TryParse(this.TurnBeforeLeavingRegionVarName, out num3)) && num3 >= 0) { this.Objective.TurnBeforeLeavingRegion = num3; } } }
protected override bool Initialize(QuestBehaviour questBehaviour) { IGameService service = Services.GetService <IGameService>(); if (service == null || service.Game == null) { Diagnostics.LogError("Failed to retrieve the game service."); return(false); } global::Game game = service.Game as global::Game; if (game == null) { Diagnostics.LogError("Failed to cast gameService.Game to Game."); return(false); } this.gameEntityRepositoryService = game.Services.GetService <IGameEntityRepositoryService>(); if (this.gameEntityRepositoryService == null) { Diagnostics.LogError("Failed to retrieve the game entity repository service."); return(false); } IEnumerable <WorldPosition> source; if (this.SpawnLocations == null && questBehaviour.TryGetQuestVariableValueByName <WorldPosition>(this.SpawnLocationVarName, out source)) { this.SpawnLocations = source.ToArray <WorldPosition>(); } if (!string.IsNullOrEmpty(this.ForbiddenSpawnLocationVarName) && !questBehaviour.QuestVariables.Exists((QuestVariable match) => match.Name == this.ForbiddenSpawnLocationVarName)) { QuestVariable questVariable = new QuestVariable(this.ForbiddenSpawnLocationVarName); questVariable.Object = new List <WorldPosition>(); questBehaviour.QuestVariables.Add(questVariable); } if (string.IsNullOrEmpty(this.ArmyTag)) { Diagnostics.LogError("Spawned armies requires an identifing tag"); return(false); } if (string.IsNullOrEmpty(this.ArmyUnitTag)) { Diagnostics.LogError("Spawned armies requires an identifing tag"); return(false); } if (this.EmpireArmyOwnerIndex == -1) { if (!string.IsNullOrEmpty(this.EmpireArmyOwnerVarName)) { global::Empire empireArmyOwner; if (!questBehaviour.TryGetQuestVariableValueByName <global::Empire>(this.EmpireArmyOwnerVarName, out empireArmyOwner)) { Diagnostics.LogError("Cannot retrieve quest variable (varname: '{0}')", new object[] { this.EmpireArmyOwnerVarName }); return(false); } this.EmpireArmyOwner = empireArmyOwner; } if (this.EmpireArmyOwner == null) { this.EmpireArmyOwner = game.Empires.FirstOrDefault((global::Empire match) => match.Name == "LesserEmpire#0"); if (this.EmpireArmyOwner == null) { Diagnostics.LogError("Failed to retrieve the (lesser) quest empire."); return(false); } } this.EmpireArmyOwnerIndex = this.EmpireArmyOwner.Index; } else { this.EmpireArmyOwner = game.Empires[this.EmpireArmyOwnerIndex]; } return(base.Initialize(questBehaviour)); }
public SimulationObjectWrapper GetTargetSimulationObjectWrapper(QuestBehaviour questBehaviour) { if (global::GameManager.Preferences.QuestVerboseMode) { Diagnostics.Log("ELCP: {0} QuestBehaviourPrerequisites.GetTargetSimulationObjectWrapper {1} {2}", new object[] { questBehaviour.Initiator, this.TargetGUID, base.Target }); } if (base.XmlSerializableTarget == "$Empire") { this.targetSimulationObjectWrapper = questBehaviour.Initiator; return(this.targetSimulationObjectWrapper); } global::Empire empire; if (questBehaviour.TryGetQuestVariableValueByName <global::Empire>(base.Target, out empire) && empire != null) { this.EmpireIndex = empire.Index; return(empire); } if (this.EmpireIndex >= 0) { IGameService service = Services.GetService <IGameService>(); if (service == null || service.Game == null) { Diagnostics.LogError("Failed to retrieve the game service."); return(null); } global::Game game = service.Game as global::Game; if (game == null) { Diagnostics.LogError("Failed to cast gameService.Game to Game."); return(null); } if (game.Empires[this.EmpireIndex] != null) { return(game.Empires[this.EmpireIndex]); } } IGameEntity gameEntity; if (questBehaviour.TryGetQuestVariableValueByName <IGameEntity>(base.Target, out gameEntity) && gameEntity != null && gameEntity.GUID != GameEntityGUID.Zero && gameEntity is SimulationObjectWrapper) { this.TargetGUID = gameEntity.GUID; this.targetSimulationObjectWrapper = (gameEntity as SimulationObjectWrapper); return(this.targetSimulationObjectWrapper); } if (this.TargetGUID != GameEntityGUID.Zero) { IGameService service2 = Services.GetService <IGameService>(); if (service2 == null || service2.Game == null) { Diagnostics.LogError("Failed to retrieve the game service."); return(null); } global::Game game2 = service2.Game as global::Game; if (game2 == null) { Diagnostics.LogError("Failed to cast gameService.Game to Game."); return(null); } IGameEntityRepositoryService service3 = game2.Services.GetService <IGameEntityRepositoryService>(); if (service3 == null) { Diagnostics.LogError("Failed to retrieve the game entity repository service."); return(null); } if (service3.TryGetValue(this.TargetGUID, out gameEntity) && gameEntity != null && gameEntity.GUID != GameEntityGUID.Zero && gameEntity is SimulationObjectWrapper) { this.TargetGUID = gameEntity.GUID; this.targetSimulationObjectWrapper = (gameEntity as SimulationObjectWrapper); return(this.targetSimulationObjectWrapper); } } return(null); }
protected override bool Initialize(QuestBehaviour questBehaviour) { if (string.IsNullOrEmpty(this.ResourceName)) { string text; if (questBehaviour.TryGetQuestVariableValueByName <string>(this.ResourceNameVarName, out text)) { if (string.IsNullOrEmpty(text)) { Diagnostics.LogError("Resource name is null or empty, quest variable (varname: '{0}')", new object[] { this.ResourceNameVarName }); return(false); } this.ResourceName = text; } else { IDroppable droppable; if (!questBehaviour.TryGetQuestVariableValueByName <IDroppable>(this.ResourceNameVarName, out droppable)) { Diagnostics.LogError("Cannot retrieve quest variable (varname: '{0}')", new object[] { this.ResourceNameVarName }); return(false); } DroppableString droppableString = droppable as DroppableString; if (droppableString == null || string.IsNullOrEmpty(droppableString.Value)) { Diagnostics.LogError("Resource name is null or empty, quest variable (varname: '{0}')", new object[] { this.ResourceNameVarName }); return(false); } this.ResourceName = droppableString.Value; } } if (this.Amount == -1) { QuestRegisterVariable questRegisterVariable; IDroppable droppable2; if (questBehaviour.TryGetQuestVariableValueByName <QuestRegisterVariable>(this.AmountVarName, out questRegisterVariable)) { if (questRegisterVariable == null) { Diagnostics.LogError("QuestRegisterVariable is null, quest variable (varname: '{0}')", new object[] { this.ResourceNameVarName }); return(false); } this.Amount = questRegisterVariable.Value; } else if (questBehaviour.TryGetQuestVariableValueByName <IDroppable>(this.AmountVarName, out droppable2)) { if (droppable2 == null) { Diagnostics.LogError("QuestDropListVariableDefinition is null, quest variable (varname: '{0}')", new object[] { this.AmountVarName }); return(false); } DroppableInteger droppableInteger = droppable2 as DroppableInteger; if (droppableInteger == null) { Diagnostics.LogError("QuestDropListVariableDefinition does not contains a DroppableInteger (varname: '{0}')", new object[] { this.AmountVarName }); return(false); } this.Amount = droppableInteger.Value; } else { float f; if (!questBehaviour.TryGetQuestVariableValueByName <float>(this.AmountVarName, out f)) { Diagnostics.LogError("Cannot retrieve quest variable (varname: '{0}')", new object[] { this.AmountVarName }); return(false); } this.Amount = Mathf.RoundToInt(f); } } return(base.Initialize(questBehaviour)); }
protected override bool Initialize(QuestBehaviour questBehaviour) { IGameService service = Services.GetService <IGameService>(); if (service == null || service.Game == null) { Diagnostics.LogError("Failed to retrieve the game service."); return(false); } global::Game game = service.Game as global::Game; if (game == null) { Diagnostics.LogError("Failed to cast gameService.Game to Game."); return(false); } this.gameEntityRepositoryService = game.Services.GetService <IGameEntityRepositoryService>(); if (this.gameEntityRepositoryService == null) { Diagnostics.LogError("Failed to retrieve the game entity repository service."); return(false); } IEnumerable <WorldPosition> source; if (this.SpawnLocations == null && questBehaviour.TryGetQuestVariableValueByName <WorldPosition>(this.SpawnLocationVarName, out source)) { this.SpawnLocations = source.ToArray <WorldPosition>(); } if (!string.IsNullOrEmpty(this.ForbiddenSpawnLocationVarName) && !questBehaviour.QuestVariables.Exists((QuestVariable match) => match.Name == this.ForbiddenSpawnLocationVarName)) { QuestVariable questVariable = new QuestVariable(this.ForbiddenSpawnLocationVarName); questVariable.Object = new List <WorldPosition>(); questBehaviour.QuestVariables.Add(questVariable); } if (this.ArmyGUID != GameEntityGUID.Zero && !questBehaviour.QuestVariables.Exists((QuestVariable match) => match.Name == this.OutputEnemyArmyGUIDVarName)) { QuestVariable questVariable2 = new QuestVariable(this.OutputEnemyArmyGUIDVarName); questVariable2.Object = this.ArmyGUID; questBehaviour.QuestVariables.Add(questVariable2); } if (this.EmpireArmyOwnerIndex == -1) { if (!string.IsNullOrEmpty(this.EmpireArmyOwnerVarName)) { global::Empire empireArmyOwner; if (!questBehaviour.TryGetQuestVariableValueByName <global::Empire>(this.EmpireArmyOwnerVarName, out empireArmyOwner)) { Diagnostics.LogError("Cannot retrieve quest variable (varname: '{0}')", new object[] { this.EmpireArmyOwnerVarName }); return(false); } this.EmpireArmyOwner = empireArmyOwner; } if (this.EmpireArmyOwner == null) { this.EmpireArmyOwner = game.Empires.FirstOrDefault((global::Empire match) => match.Name == "LesserEmpire#0"); if (this.EmpireArmyOwner == null) { Diagnostics.LogError("Failed to retrieve the (lesser) quest empire."); return(false); } } this.EmpireArmyOwnerIndex = this.EmpireArmyOwner.Index; } else { this.EmpireArmyOwner = game.Empires[this.EmpireArmyOwnerIndex]; } if (this.ArmyDroplistSuffixVarName != string.Empty && this.ArmyDroplistSuffix == string.Empty) { string text; if (!questBehaviour.TryGetQuestVariableValueByName <string>(this.ArmyDroplistSuffixVarName, out text)) { Diagnostics.LogError("Cannot retrieve quest variable (varname: '{0}', are you sure it is a string?)", new object[] { this.ArmyDroplistSuffixVarName }); return(false); } if (text == string.Empty) { Diagnostics.LogError("The suffix is an empty string (varname: '{0}')", new object[] { this.ArmyDroplistSuffixVarName }); return(false); } this.ArmyDroplistSuffix = text; } if (this.ArmyGUID == 0UL && !string.IsNullOrEmpty(this.OutputEnemyArmyGUIDVarName)) { QuestVariable questVariable3 = questBehaviour.GetQuestVariableByName(this.OutputEnemyArmyGUIDVarName); if (questVariable3 == null) { questVariable3 = new QuestVariable(this.OutputEnemyArmyGUIDVarName); questBehaviour.QuestVariables.Add(questVariable3); } this.ArmyGUID = this.gameEntityRepositoryService.GenerateGUID(); questVariable3.Object = this.ArmyGUID; if (this.OutputEnemyArmyGUIDIsGlobal) { IQuestManagementService service2 = game.Services.GetService <IQuestManagementService>(); if (service2 != null) { QuestVariable questVariable4 = new QuestVariable(this.OutputEnemyArmyGUIDVarName, this.ArmyGUID); service2.State.AddGlobalVariable(questBehaviour.Initiator.Index, questVariable4); } } } return(base.Initialize(questBehaviour)); }