ChuckHearthstone/SilverFish

[HubScene] Unable to click the "Quest Log" button.

chucklu opened this issue · 3 comments

// Triton.Bot.Logic.Bots.DefaultBot.DefaultBot
// Token: 0x060013AD RID: 5037 RVA: 0x000BE20C File Offset: 0x000BC40C
private async Task method_45(PegasusScene pegasusScene_0)
{
	this.bool_2 = false;
	DefaultBot.ilog_0.InfoFormat("[HubScene]", Array.Empty<object>());
	PresenceMgr presenceMgr = PresenceMgr.Get();
	if (presenceMgr == null)
	{
		DefaultBot.ilog_0.DebugFormat("[HubScene] PresenceMgr is null.", Array.Empty<object>());
	}
	else
	{
		List<MonoEnum> statusEnums = presenceMgr.GetStatusEnums(BnetPresenceMgr.Get().GetMyPlayer());
		if (statusEnums != null && statusEnums.Count != 0)
		{
			foreach (MonoEnum monoEnum in statusEnums)
			{
				PresenceStatus presenceStatus = monoEnum.AsEnum<PresenceStatus>();
				TritonHs.smethod_4(presenceMgr, ref presenceStatus);
				if (presenceStatus == PresenceStatus.HUB || presenceStatus == PresenceStatus.QUESTLOG || presenceStatus == PresenceStatus.COLLECTION)
				{
					QuestLog questLog = QuestLog.Get();
					if (questLog != null && ShownUIMgr.Get().m_shownUI == ShownUIMgr.UI_WINDOW.QUEST_LOG)
					{
						List<QuestTile> currentQuests = questLog.m_currentQuests;
						TaskAwaiter taskAwaiter;
						TaskAwaiter taskAwaiter2;
						if (currentQuests == null)
						{
							DefaultBot.ilog_0.InfoFormat("[HubScene] Waiting for quest data...", Array.Empty<object>());
							taskAwaiter = Coroutine.Sleep(3000).GetAwaiter();
							if (!taskAwaiter.IsCompleted)
							{
								await taskAwaiter;
								taskAwaiter = taskAwaiter2;
								taskAwaiter2 = default(TaskAwaiter);
							}
							taskAwaiter.GetResult();
							taskAwaiter = default(TaskAwaiter);
							return;
						}
						QuestData questData = new QuestData();
						foreach (QuestTile questTile in currentQuests)
						{
							if (questTile.m_quest != null)
							{
								questData.QuestTiles.Add(new QuestTileData(questTile));
							}
							else
							{
								DefaultBot.ilog_0.WarnFormat("[HubScene] QuestTile with null Quest!", Array.Empty<object>());
							}
						}
						if (questData.QuestTiles.Any(new Func<QuestTileData, bool>(DefaultBot.Class224.<>9.method_0)))
						{
							GameEventManager.Instance.method_2();
							TaskAwaiter<bool> taskAwaiter3 = RoutineManager.CurrentRoutine.Logic("handle_quests", questData).GetAwaiter();
							if (!taskAwaiter3.IsCompleted)
							{
								await taskAwaiter3;
								TaskAwaiter<bool> taskAwaiter4;
								taskAwaiter3 = taskAwaiter4;
								taskAwaiter4 = default(TaskAwaiter<bool>);
							}
							bool result = taskAwaiter3.GetResult();
							taskAwaiter3 = default(TaskAwaiter<bool>);
							if (result)
							{
								QuestTileData questTileData = questData.QuestTiles.FirstOrDefault(new Func<QuestTileData, bool>(DefaultBot.Class224.<>9.method_1));
								if (questTileData != null)
								{
									DefaultBot.ilog_0.InfoFormat("[HubScene] Now canceling the quest [{1}] {0}.", questTileData.AchievementName, questTileData.AchievementId);
									if (!AchieveManager.Get().CanCancelQuest(questTileData.AchievementId))
									{
										DefaultBot.ilog_0.ErrorFormat("[HubScene] Cannot cancel the quest [!CanCancelQuest]!", Array.Empty<object>());
									}
									else
									{
										foreach (QuestTile questTile2 in QuestLog.Get().m_currentQuests)
										{
											if (questTile2.m_quest != null && questTile2.m_quest.ID == questTileData.AchievementId)
											{
												DefaultBot.ilog_0.InfoFormat("[HubScene] Now canceling the quest [{1}] {0}.", questTileData.AchievementName, questTileData.AchievementId);
												NormalButton cancelButton = questTile2.m_cancelButton;
												if (cancelButton != null)
												{
													cancelButton.TriggerPress();
													cancelButton.TriggerRelease();
													taskAwaiter = Coroutine.Sleep(3000).GetAwaiter();
													if (!taskAwaiter.IsCompleted)
													{
														await taskAwaiter;
														taskAwaiter = taskAwaiter2;
														taskAwaiter2 = default(TaskAwaiter);
													}
													taskAwaiter.GetResult();
													taskAwaiter = default(TaskAwaiter);
													return;
												}
												DefaultBot.ilog_0.ErrorFormat("[HubScene] The Quest's button is null!", Array.Empty<object>());
												break;
											}
										}
										List<QuestTile>.Enumerator enumerator3 = default(List<QuestTile>.Enumerator);
									}
								}
								questTileData = null;
							}
						}
						GameEventManager.Instance.method_3();
						DefaultBot.ilog_0.InfoFormat("[HubScene] Now clicking to close the \"Quest Log\" screen.", Array.Empty<object>());
						Client.LeftClickAt(10, 10);
						taskAwaiter = Coroutine.Sleep(3000).GetAwaiter();
						if (!taskAwaiter.IsCompleted)
						{
							await taskAwaiter;
							taskAwaiter = taskAwaiter2;
							taskAwaiter2 = default(TaskAwaiter);
						}
						taskAwaiter.GetResult();
						taskAwaiter = default(TaskAwaiter);
						DefaultBotSettings.Instance.NeedsToCacheQuests = false;
						return;
					}
					else if (DefaultBotSettings.Instance.NeedsToCacheCustomDecks)
					{
						DefaultBot.ilog_0.Info("[HubScene] The bot needs to cache custom decks. Now clicking on the \"Collection\" button.");
						TaskAwaiter taskAwaiter;
						TaskAwaiter taskAwaiter2;
						if (!TritonHs.ClickCollectionButton(true))
						{
							DefaultBot.ilog_0.ErrorFormat("[HubScene] Unable to click the \"Collection\" button.", Array.Empty<object>());
							BotManager.Stop();
							taskAwaiter = Coroutine.Yield().GetAwaiter();
							if (!taskAwaiter.IsCompleted)
							{
								await taskAwaiter;
								taskAwaiter = taskAwaiter2;
								taskAwaiter2 = default(TaskAwaiter);
							}
							taskAwaiter.GetResult();
							taskAwaiter = default(TaskAwaiter);
							return;
						}
						taskAwaiter = Coroutine.Sleep(3000).GetAwaiter();
						if (!taskAwaiter.IsCompleted)
						{
							await taskAwaiter;
							taskAwaiter = taskAwaiter2;
							taskAwaiter2 = default(TaskAwaiter);
						}
						taskAwaiter.GetResult();
						taskAwaiter = default(TaskAwaiter);
					}
					else if (DefaultBotSettings.Instance.NeedsToCacheQuests)
					{
						DefaultBot.ilog_0.Info("[HubScene] The bot needs to cache quests. Now clicking on the \"Quest Log\" button.");
						TaskAwaiter taskAwaiter;
						TaskAwaiter taskAwaiter2;
						if (!TritonHs.ClickQuestButton(true))
						{
							DefaultBot.ilog_0.ErrorFormat("[HubScene] Unable to click the \"Quest Log\" button.", Array.Empty<object>());
							BotManager.Stop();
							taskAwaiter = Coroutine.Yield().GetAwaiter();
							if (!taskAwaiter.IsCompleted)
							{
								await taskAwaiter;
								taskAwaiter = taskAwaiter2;
								taskAwaiter2 = default(TaskAwaiter);
							}
							taskAwaiter.GetResult();
							taskAwaiter = default(TaskAwaiter);
							return;
						}
						taskAwaiter = Coroutine.Sleep(3000).GetAwaiter();
						if (!taskAwaiter.IsCompleted)
						{
							await taskAwaiter;
							taskAwaiter = taskAwaiter2;
							taskAwaiter2 = default(TaskAwaiter);
						}
						taskAwaiter.GetResult();
						taskAwaiter = default(TaskAwaiter);
					}
					else if (DefaultBotSettings.Instance.GameMode != GameMode.Practice)
					{
						if (DefaultBotSettings.Instance.GameMode == GameMode.Arena)
						{
							DefaultBot.ilog_0.Info("[HubScene] Now clicking on the \"The Arena\" button.");
							TaskAwaiter taskAwaiter;
							TaskAwaiter taskAwaiter2;
							if (!TritonHs.ClickArenaButton(true))
							{
								DefaultBot.ilog_0.ErrorFormat("[HubScene] Unable to click the \"The Arena\" button.", Array.Empty<object>());
								BotManager.Stop();
								taskAwaiter = Coroutine.Yield().GetAwaiter();
								if (!taskAwaiter.IsCompleted)
								{
									await taskAwaiter;
									taskAwaiter = taskAwaiter2;
									taskAwaiter2 = default(TaskAwaiter);
								}
								taskAwaiter.GetResult();
								taskAwaiter = default(TaskAwaiter);
								return;
							}
							taskAwaiter = Coroutine.Sleep(3000).GetAwaiter();
							if (!taskAwaiter.IsCompleted)
							{
								await taskAwaiter;
								taskAwaiter = taskAwaiter2;
								taskAwaiter2 = default(TaskAwaiter);
							}
							taskAwaiter.GetResult();
							taskAwaiter = default(TaskAwaiter);
							return;
						}
						else if (DefaultBotSettings.Instance.GameMode == GameMode.Constructed)
						{
							DefaultBot.ilog_0.Info("[HubScene] Now clicking on the \"Play\" button.");
							TaskAwaiter taskAwaiter;
							TaskAwaiter taskAwaiter2;
							if (!TritonHs.ClickPlayButton(true))
							{
								DefaultBot.ilog_0.ErrorFormat("[HubScene] Unable to click the \"Play\" button.", Array.Empty<object>());
								BotManager.Stop();
								taskAwaiter = Coroutine.Yield().GetAwaiter();
								if (!taskAwaiter.IsCompleted)
								{
									await taskAwaiter;
									taskAwaiter = taskAwaiter2;
									taskAwaiter2 = default(TaskAwaiter);
								}
								taskAwaiter.GetResult();
								taskAwaiter = default(TaskAwaiter);
								return;
							}
							taskAwaiter = Coroutine.Sleep(3000).GetAwaiter();
							if (!taskAwaiter.IsCompleted)
							{
								await taskAwaiter;
								taskAwaiter = taskAwaiter2;
								taskAwaiter2 = default(TaskAwaiter);
							}
							taskAwaiter.GetResult();
							taskAwaiter = default(TaskAwaiter);
							return;
						}
						else
						{
							TaskAwaiter taskAwaiter2;
							if (DefaultBotSettings.Instance.GameMode == GameMode.Friendly)
							{
								DefaultBot.ilog_0.Info("[HubScene] Now waiting for a \"Friendly Challenge\".");
								TaskAwaiter taskAwaiter = Coroutine.Sleep(3000).GetAwaiter();
								if (!taskAwaiter.IsCompleted)
								{
									await taskAwaiter;
									taskAwaiter = taskAwaiter2;
									taskAwaiter2 = default(TaskAwaiter);
								}
								taskAwaiter.GetResult();
								taskAwaiter = default(TaskAwaiter);
								return;
							}
							if (DefaultBotSettings.Instance.GameMode == GameMode.TavernBrawl)
							{
								DefaultBot.ilog_0.Info("[HubScene] Now clicking on the \"Tavern Brawl\" button.");
								TaskAwaiter taskAwaiter;
								if (!TritonHs.ClickTavernBrawlButton(true))
								{
									DefaultBot.ilog_0.ErrorFormat("[HubScene] Unable to click the \"Tavern Brawl\" button.", Array.Empty<object>());
									BotManager.Stop();
									taskAwaiter = Coroutine.Yield().GetAwaiter();
									if (!taskAwaiter.IsCompleted)
									{
										await taskAwaiter;
										taskAwaiter = taskAwaiter2;
										taskAwaiter2 = default(TaskAwaiter);
									}
									taskAwaiter.GetResult();
									taskAwaiter = default(TaskAwaiter);
									return;
								}
								taskAwaiter = Coroutine.Sleep(3000).GetAwaiter();
								if (!taskAwaiter.IsCompleted)
								{
									await taskAwaiter;
									taskAwaiter = taskAwaiter2;
									taskAwaiter2 = default(TaskAwaiter);
								}
								taskAwaiter.GetResult();
								taskAwaiter = default(TaskAwaiter);
								return;
							}
						}
					}
					else
					{
						DefaultBot.ilog_0.Info("[HubScene] Now clicking on the \"Solo Adventures\" button.");
						TaskAwaiter taskAwaiter;
						TaskAwaiter taskAwaiter2;
						if (!TritonHs.ClickAdventureButton(true))
						{
							DefaultBot.ilog_0.ErrorFormat("[HubScene] Unable to click the \"Solo Adventures\" button.", Array.Empty<object>());
							BotManager.Stop();
							taskAwaiter = Coroutine.Yield().GetAwaiter();
							if (!taskAwaiter.IsCompleted)
							{
								await taskAwaiter;
								taskAwaiter = taskAwaiter2;
								taskAwaiter2 = default(TaskAwaiter);
							}
							taskAwaiter.GetResult();
							taskAwaiter = default(TaskAwaiter);
							return;
						}
						taskAwaiter = Coroutine.Sleep(3000).GetAwaiter();
						if (!taskAwaiter.IsCompleted)
						{
							await taskAwaiter;
							taskAwaiter = taskAwaiter2;
							taskAwaiter2 = default(TaskAwaiter);
						}
						taskAwaiter.GetResult();
						taskAwaiter = default(TaskAwaiter);
						return;
					}
				}
				else
				{
					TaskAwaiter taskAwaiter;
					TaskAwaiter taskAwaiter2;
					if (presenceStatus != PresenceStatus.STORE)
					{
						DefaultBot.ilog_0.ErrorFormat("[HubScene] Unhandled presence status detected: {0}. Please restart your client and try again. If the error is still not fixed, please report this message.", presenceStatus);
						BotManager.Stop();
						taskAwaiter = Coroutine.Yield().GetAwaiter();
						if (!taskAwaiter.IsCompleted)
						{
							await taskAwaiter;
							taskAwaiter = taskAwaiter2;
							taskAwaiter2 = default(TaskAwaiter);
						}
						taskAwaiter.GetResult();
						taskAwaiter = default(TaskAwaiter);
						return;
					}
					if (StoreManager.Get() == null)
					{
						return;
					}
					Client.LeftClickAtDialog(BnetBar.Get().m_currentTime.Transform.Position);
					taskAwaiter = Coroutine.Sleep(1000).GetAwaiter();
					if (!taskAwaiter.IsCompleted)
					{
						await taskAwaiter;
						taskAwaiter = taskAwaiter2;
						taskAwaiter2 = default(TaskAwaiter);
					}
					taskAwaiter.GetResult();
					taskAwaiter = default(TaskAwaiter);
				}
			}
			List<MonoEnum>.Enumerator enumerator = default(List<MonoEnum>.Enumerator);
		}
		else
		{
			DefaultBot.ilog_0.DebugFormat("[HubScene] PresenceMgr.GetStatus is null or empty.", Array.Empty<object>());
		}
	}
}
else if (DefaultBotSettings.Instance.NeedsToCacheQuests)
					{
						DefaultBot.ilog_0.Info("[HubScene] The bot needs to cache quests. Now clicking on the \"Quest Log\" button.");
						TaskAwaiter taskAwaiter;
						TaskAwaiter taskAwaiter2;
						if (!TritonHs.ClickQuestButton(true))
						{
							DefaultBot.ilog_0.ErrorFormat("[HubScene] Unable to click the \"Quest Log\" button.", Array.Empty<object>());
							BotManager.Stop();
							taskAwaiter = Coroutine.Yield().GetAwaiter();
							if (!taskAwaiter.IsCompleted)
							{
								await taskAwaiter;
								taskAwaiter = taskAwaiter2;
								taskAwaiter2 = default(TaskAwaiter);
							}
							taskAwaiter.GetResult();
							taskAwaiter = default(TaskAwaiter);
							return;
						}
						taskAwaiter = Coroutine.Sleep(3000).GetAwaiter();
						if (!taskAwaiter.IsCompleted)
						{
							await taskAwaiter;
							taskAwaiter = taskAwaiter2;
							taskAwaiter2 = default(TaskAwaiter);
						}
						taskAwaiter.GetResult();
						taskAwaiter = default(TaskAwaiter);
					}
// Triton.Bot.Logic.Bots.DefaultBot.DefaultBotSettings
// Token: 0x17000394 RID: 916
// (get) Token: 0x06001428 RID: 5160 RVA: 0x0000EE1C File Offset: 0x0000D01C
// (set) Token: 0x06001429 RID: 5161 RVA: 0x000CC2A8 File Offset: 0x000CA4A8
[DefaultValue(true)]
[JsonIgnore]
public bool NeedsToCacheQuests
{
	get
	{
		return !this.ClientBroken && this.bool_9;
	}
	set
	{
		if (!value.Equals(this.bool_9))
		{
			this.bool_9 = value;
			base.NotifyPropertyChanged<bool>(() => this.NeedsToCacheQuests);
		}
		DefaultBotSettings.ilog_0.InfoFormat("[DefaultBotSettings] NeedsToCacheQuests = {0}.", this.bool_9);
	}
}

make NeedsToCacheQuests property always return false.