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); }
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); }
private void PrintVariables(QuestBehaviour questBehaviour) { Diagnostics.LogWarning("Quest BT variables: {0}", new object[] { questBehaviour.ToStringVariables() }); Diagnostics.Log("[UpdateArmyObjective] Variables needed by UpdateArmyObjective:"); if (this.TargetCityGUIDVarName != string.Empty) { Diagnostics.LogWarning("[UpdateArmyObjective] TargetCityGUIDVarName = {0}, GUID found = {1}", new object[] { this.TargetCityGUIDVarName, this.Objective.TargetCityGUID }); } if (this.TargetCityVarName != string.Empty) { Diagnostics.LogWarning("[UpdateArmyObjective] TargetCityVarName = {0}, City found = {1}", new object[] { this.TargetCityVarName, this.Objective.TargetCityGUID }); } if (this.TargetEmpireIndexVarName != string.Empty) { Diagnostics.LogWarning("[UpdateArmyObjective] TargetEmpireIndexVarName = {0}, Empire index found = {1}", new object[] { this.TargetEmpireIndexVarName, this.Objective.TargetEmpireIndex }); } if (this.TargetEmpireVarName != string.Empty) { Diagnostics.LogWarning("[UpdateArmyObjective] TargetEmpireVarName = {0}, Empire index found = {1}", new object[] { this.TargetEmpireVarName, this.Objective.TargetEmpireIndex }); } }