ChuckHearthstone/SilverFish

Method 'CollectionManager.GetTaggedDeck' not found

Closed this issue · 5 comments

2020-10-23 20:33:14.571+08:00 [8] ERROR Triton.Common.LogUtilities.Logger - [Tick] Exception during execution:
Buddy.Coroutines.CoroutineUnhandledException: Exception was thrown by coroutine ---> System.MissingMethodException: Method 'CollectionManager.GetTaggedDeck' not found.
at Triton.Game.Mono.MonoClass.method_7(String string_4, Enum20[] enum20_0, Object[] object_0)
at Triton.Game.Mono.MonoClass.method_15[T](String string_4, Enum20[] enum20_0, Object[] object_0)
at Triton.Game.Mapping.CollectionManager.GetTaggedDeck(DeckTag tag)
at Triton.Bot.Logic.Bots.DefaultBot.DefaultBot.Struct57.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Triton.Bot.Logic.Bots.DefaultBot.DefaultBot.Struct56.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Triton.Bot.Logic.Bots.DefaultBot.DefaultBot.Struct60.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Buddy.Coroutines.Coroutine.Class66.Struct18.MoveNext()
--- End of inner exception stack trace ---
at Buddy.Coroutines.Coroutine.method_2(Boolean bool_2)
at Buddy.Coroutines.Coroutine.method_0(Boolean bool_2)
at Buddy.Coroutines.Coroutine.Resume()
at Triton.Bot.Logic.Bots.DefaultBot.DefaultBot.Tick()
at Triton.Bot.BotManager.smethod_1(IBot ibot_1)

DeckTag enum was removed

// Token: 0x02000579 RID: 1401
		public enum DeckTag
		{
			// Token: 0x040010D1 RID: 4305
			Editing,
			// Token: 0x040010D2 RID: 4306
			Arena
		}

The enum was used in following methods

public CollectionDeck GetTaggedDeck(CollectionManager.DeckTag tag)
	{
		CollectionDeck collectionDeck = null;
		if (this.m_taggedDecks.TryGetValue(tag, out collectionDeck) && collectionDeck != null && collectionDeck.IsBrawlDeck)
		{
			TavernBrawlMission tavernBrawlMission = TavernBrawlManager.Get().IsCurrentBrawlTypeActive ? TavernBrawlManager.Get().CurrentMission() : null;
			if (tavernBrawlMission == null || collectionDeck.SeasonId != tavernBrawlMission.seasonId)
			{
				return null;
			}
		}
		return collectionDeck;
	}

public CollectionDeck GetEditedDeck()
	{
		if (SceneMgr.Get().GetMode() == SceneMgr.Mode.DRAFT)
		{
			return this.GetTaggedDeck(CollectionManager.DeckTag.Arena);
		}
		return this.GetTaggedDeck(CollectionManager.DeckTag.Editing);
	}

The new implementation is

public CollectionDeck GetEditedDeck()
	{
		CollectionDeck editedDeck = this.m_EditedDeck;
		if (editedDeck != null && editedDeck.IsBrawlDeck)
		{
			TavernBrawlMission tavernBrawlMission = TavernBrawlManager.Get().IsCurrentBrawlTypeActive ? TavernBrawlManager.Get().CurrentMission() : null;
			if (tavernBrawlMission == null || editedDeck.SeasonId != tavernBrawlMission.seasonId)
			{
				return null;
			}
		}
		return editedDeck;
	}
// Triton.Bot.Logic.Bots.DefaultBot.DefaultBot
// Token: 0x06001379 RID: 4985 RVA: 0x000BCFA4 File Offset: 0x000BB1A4
private async Task method_6(CollectionManagerScene collectionManagerScene_0)
{
	DefaultBot.ilog_0.InfoFormat("[CollectionManagerScene_COLLECTION]", Array.Empty<object>());
	CollectionDeckTray collectionDeckTray = CollectionDeckTray.Get();
	if (collectionDeckTray == null)
	{
		DefaultBot.ilog_0.DebugFormat("[CollectionManagerScene_COLLECTION] null.", Array.Empty<object>());
		TaskAwaiter taskAwaiter = Coroutine.Sleep(Client.Random.Next(1000, 2000)).GetAwaiter();
		if (!taskAwaiter.IsCompleted)
		{
			await taskAwaiter;
			TaskAwaiter taskAwaiter2;
			taskAwaiter = taskAwaiter2;
			taskAwaiter2 = default(TaskAwaiter);
		}
		taskAwaiter.GetResult();
		taskAwaiter = default(TaskAwaiter);
	}
	else
	{
		CollectionManager collectionManager = CollectionManager.Get();
		if (collectionManager != null && collectionManager.IsFullyLoaded())
		{
			Stopwatch stopwatch = this.method_9("CollectionManagerScene_COLLECTION");
			if (stopwatch.IsRunning && stopwatch.ElapsedMilliseconds >= 1000L)
			{
				TraySection editingTraySection = collectionDeckTray.m_decksContent.m_editingTraySection;
				CollectionDeck taggedDeck = CollectionManager.Get().GetTaggedDeck(CollectionManager.DeckTag.Editing);
				if (taggedDeck != null && editingTraySection != null)
				{
					if (!collectionManager.GetDeck(taggedDeck.ID).NetworkContentsLoaded())
					{
						DefaultBot.ilog_0.DebugFormat("[CollectionManagerScene_COLLECTION] !m_netContentsLoaded.", Array.Empty<object>());
						TaskAwaiter taskAwaiter = Coroutine.Sleep(Client.Random.Next(1000, 2000)).GetAwaiter();
						if (!taskAwaiter.IsCompleted)
						{
							await taskAwaiter;
							TaskAwaiter taskAwaiter2;
							taskAwaiter = taskAwaiter2;
							taskAwaiter2 = default(TaskAwaiter);
						}
						taskAwaiter.GetResult();
						taskAwaiter = default(TaskAwaiter);
						stopwatch.Reset();
					}
					else
					{
						DefaultBot.ilog_0.InfoFormat("[CollectionManagerScene_COLLECTION] The contents of the deck have been obtained. Now clicking on the \"Done\" button.", Array.Empty<object>());
						Client.LeftClickAt(collectionDeckTray.m_doneButton.m_ButtonText.Transform.Position);
						TaskAwaiter taskAwaiter = Coroutine.Sleep(Client.Random.Next(1000, 2000)).GetAwaiter();
						if (!taskAwaiter.IsCompleted)
						{
							await taskAwaiter;
							TaskAwaiter taskAwaiter2;
							taskAwaiter = taskAwaiter2;
							taskAwaiter2 = default(TaskAwaiter);
						}
						taskAwaiter.GetResult();
						taskAwaiter = default(TaskAwaiter);
						stopwatch.Reset();
					}
				}
				else if (!DefaultBotSettings.Instance.NeedsToCacheCustomDecks)
				{
					DefaultBot.ilog_0.InfoFormat("[CollectionManagerScene_COLLECTION] We do not need to cache custom decks. Now leaving the \"Collection Manager\".", Array.Empty<object>());
					Client.LeftClickAt(collectionDeckTray.m_doneButton.m_ButtonText.Transform.Position);
					TaskAwaiter taskAwaiter = Coroutine.Sleep(Client.Random.Next(1000, 2000)).GetAwaiter();
					if (!taskAwaiter.IsCompleted)
					{
						await taskAwaiter;
						TaskAwaiter taskAwaiter2;
						taskAwaiter = taskAwaiter2;
						taskAwaiter2 = default(TaskAwaiter);
					}
					taskAwaiter.GetResult();
					taskAwaiter = default(TaskAwaiter);
					stopwatch.Reset();
				}
				else
				{
					try
					{
						Utility.smethod_4();
					}
					catch (Exception arg)
					{
						DefaultBot.ilog_0.ErrorFormat("[CollectionManagerScene_COLLECTION] An exception occurred when calling CacheCustomDecks: {0}.", arg);
						BotManager.Stop();
						return;
					}
					List<CollectionDeckBoxVisual> list = new List<CollectionDeckBoxVisual>();
					foreach (TraySection traySection in collectionDeckTray.m_decksContent.m_traySections)
					{
						CollectionDeckBoxVisual deckBox = traySection.m_deckBox;
						long deckID = deckBox.GetDeckID();
						string text = deckBox.m_deckName.Text;
						bool isWild = deckBox.m_isWild;
						if (deckID != -1L && !deckBox.IsLocked() && deckBox.IsEnabled())
						{
							if (!collectionManager.GetDeck(deckID).m_netContentsLoaded)
							{
								if (Utility.smethod_2(deckID, text, isWild))
								{
									DefaultBot.ilog_0.InfoFormat("[CollectionManagerScene_COLLECTION] We need the contents of this deck.", Array.Empty<object>());
									list.Add(deckBox);
								}
							}
							else
							{
								DefaultBot.ilog_0.InfoFormat("[CollectionManagerScene_COLLECTION] We have the contents of this deck already.", Array.Empty<object>());
							}
						}
					}
					if (list.Any<CollectionDeckBoxVisual>())
					{
						DefaultBot.ilog_0.InfoFormat("[CollectionManagerScene_COLLECTION] Now choosing a random deck to load the contents of.", Array.Empty<object>());
						list.ElementAt(Client.Random.Next(0, list.Count)).TriggerTap();
						TaskAwaiter taskAwaiter = Coroutine.Sleep(Client.Random.Next(1000, 2000)).GetAwaiter();
						if (!taskAwaiter.IsCompleted)
						{
							await taskAwaiter;
							TaskAwaiter taskAwaiter2;
							taskAwaiter = taskAwaiter2;
							taskAwaiter2 = default(TaskAwaiter);
						}
						taskAwaiter.GetResult();
						taskAwaiter = default(TaskAwaiter);
						stopwatch.Reset();
					}
					else
					{
						List<CustomDeckCache> list2 = new List<CustomDeckCache>();
						foreach (CustomDeckCache customDeckCache in MainSettings.Instance.CustomDecks)
						{
							if (collectionManager.GetDeck(customDeckCache.DeckId) == null)
							{
								list2.Add(customDeckCache);
							}
						}
						if (list2.Any<CustomDeckCache>())
						{
							DefaultBot.ilog_0.DebugFormat("[CollectionManagerScene_COLLECTION] Now removing [{0}] decks that no longer exist.", list2.Count);
							foreach (CustomDeckCache customDeckCache2 in list2)
							{
								MainSettings.Instance.CustomDecks.Remove(customDeckCache2);
								try
								{
									File.Delete(CustomDeckCache.GetFileNameFor(customDeckCache2.DeckId));
								}
								catch
								{
								}
							}
						}
						MainSettings.Instance.LastDeckCachePid = TritonHs.Memory.Process.Id;
						MainSettings.Instance.Save();
						DefaultBotSettings.Instance.NeedsToCacheCustomDecks = false;
						GameEventManager.Instance.method_8();
						stopwatch.Reset();
					}
				}
			}
			else
			{
				if (!stopwatch.IsRunning)
				{
					stopwatch.Restart();
				}
				DefaultBot.ilog_0.DebugFormat("[CollectionManagerScene_COLLECTION] Waiting to be in this state longer.", Array.Empty<object>());
				TaskAwaiter taskAwaiter = Coroutine.Sleep(Client.Random.Next(1000, 2000)).GetAwaiter();
				if (!taskAwaiter.IsCompleted)
				{
					await taskAwaiter;
					TaskAwaiter taskAwaiter2;
					taskAwaiter = taskAwaiter2;
					taskAwaiter2 = default(TaskAwaiter);
				}
				taskAwaiter.GetResult();
				taskAwaiter = default(TaskAwaiter);
			}
		}
		else
		{
			DefaultBot.ilog_0.DebugFormat("[CollectionManagerScene_COLLECTION] !IsFullyLoaded.", Array.Empty<object>());
			TaskAwaiter taskAwaiter = Coroutine.Sleep(Client.Random.Next(1000, 2000)).GetAwaiter();
			if (!taskAwaiter.IsCompleted)
			{
				await taskAwaiter;
				TaskAwaiter taskAwaiter2;
				taskAwaiter = taskAwaiter2;
				taskAwaiter2 = default(TaskAwaiter);
			}
			taskAwaiter.GetResult();
			taskAwaiter = default(TaskAwaiter);
		}
	}
}

Solution:

// Triton.Game.Mapping.CollectionManager
// Token: 0x06003F47 RID: 16199
public CollectionDeck GetTaggedDeck(CollectionManager.DeckTag tag)
{
return base.method_14("GetEditedDeck", Array.Empty());
}