Decompiled source of BountiesReworked v1.0.0

DigitalrootBountiesreworked.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("DigitalrootBountiesFixed")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DigitalrootBountiesFixed")]
[assembly: AssemblyTitle("DigitalrootBountiesFixed")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace DigitalrootBountiesFixed
{
	[BepInPlugin("digitalroot.mods.bounties.fixed", "Digitalroot Bounties Fixed", "1.2.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "digitalroot.mods.bounties.fixed";

		public const string PluginName = "Digitalroot Bounties Fixed";

		public const string PluginVersion = "1.2.0";

		internal static ManualLogSource Log;

		private bool _registered;

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)"Digitalroot Bounties Fixed v1.2.0 loaded - restoring legacy bounty catalogue.");
			((MonoBehaviour)this).InvokeRepeating("TryRegisterBounties", 3f, 2f);
		}

		private void TryRegisterBounties()
		{
			if (_registered)
			{
				return;
			}
			try
			{
				Type type = Type.GetType("EpicLoot.API, EpicLoot");
				if (type == null)
				{
					return;
				}
				MethodInfo method = type.GetMethod("AddBountyTarget", BindingFlags.Static | BindingFlags.Public);
				if (method == null)
				{
					Log.LogError((object)"Epic Loot API method AddBountyTarget was not found.");
					((MonoBehaviour)this).CancelInvoke("TryRegisterBounties");
					return;
				}
				if ((Object)(object)ZNetScene.instance == (Object)null)
				{
					Log.LogDebug((object)"ZNetScene not ready yet - retrying...");
					return;
				}
				int num = 0;
				int num2 = 0;
				int num3 = 0;
				foreach (string allBounty in BountyData.AllBounties)
				{
					if (allBounty.StartsWith("RRRN|", StringComparison.Ordinal))
					{
						num2++;
						continue;
					}
					string[] array = allBounty.Split(new char[1] { '|' });
					if (array.Length != 5)
					{
						num3++;
						continue;
					}
					string text = array[0];
					if ((Object)(object)ZNetScene.instance.GetPrefab(text) == (Object)null)
					{
						num2++;
						continue;
					}
					string text2 = BountyData.ToJson(array);
					try
					{
						if (method.Invoke(null, new object[1] { text2 }) != null)
						{
							num++;
						}
						else
						{
							num3++;
						}
					}
					catch (Exception ex)
					{
						num3++;
						Log.LogWarning((object)("Failed to add legacy bounty '" + text + "': " + (ex.InnerException?.Message ?? ex.Message)));
					}
				}
				Log.LogInfo((object)($"Legacy bounties processed: {num} added, " + $"{num2} skipped (missing optional prefab/RRRN), {num3} failed."));
				_registered = true;
				((MonoBehaviour)this).CancelInvoke("TryRegisterBounties");
			}
			catch (Exception arg)
			{
				Log.LogError((object)$"Error while registering legacy bounties: {arg}");
			}
		}
	}
	public static class BountyData
	{
		public static readonly List<string> AllBounties = new List<string>
		{
			B("Deer", "Meadows", 1, 0, 10),
			B("Boar", "Meadows", 1, 0, 10),
			B("Boar", "Meadows", 1, 0, 10),
			B("Neck", "Meadows", 1, 0, 10),
			B("Neck", "Meadows", 1, 0, 10),
			B("Greyling", "Meadows", 1, 0, 10),
			B("Greyling", "Meadows", 1, 0, 10),
			B("Boar", "Meadows", 2, 0, 15),
			B("Neck", "Meadows", 2, 0, 15),
			B("Greydwarf_Shaman", "Meadows", 2, 1, 25),
			B("Greydwarf_Elite", "Meadows", 10, 3, 100),
			B("BlobElite", "Meadows", 0, 1, 25),
			B("Skeleton_Poison", "Meadows", 5, 0, 25),
			B("Skeleton_Poison", "Meadows", 1, 1, 30),
			B("Troll", "Meadows", 0, 1, 50),
			B("Ghost", "Meadows", 1, 0, 20),
			B("Ghost", "Meadows", 1, 0, 20),
			B("Wraith", "Meadows", 0, 1, 50),
			B("Lox", "Meadows", 3, 0, 50),
			B("Eikthyr", "Meadows", 3, 2, 100),
			B("Eikthyr", "Meadows", 5, 2, 120),
			B("Eikthyr", "Meadows", 5, 3, 120),
			B("Eikthyr", "Meadows", 8, 5, 160),
			B("RRRM_EikthyrBoar", "Meadows", 1, 0, 10),
			B("RRRN_wildbandit1", "Meadows", 1, 0, 10),
			B("RRRN_wildbandit2", "Meadows", 1, 0, 10),
			B("RRRN_wildbandit3", "Meadows", 1, 0, 10),
			B("RRRM_EikthyrWolf", "Meadows", 6, 0, 30),
			B("RRRM_EikthyrNeckT3R", "Meadows", 4, 0, 60),
			B("EikthyrLox", "Meadows", 7, 3, 80),
			B("EikthyrNeckT3M", "Meadows", 9, 5, 110),
			B("EikthyrNeckT4", "Meadows", 11, 6, 140),
			B("Greydwarf", "BlackForest", 2, 0, 20),
			B("Greydwarf", "BlackForest", 2, 0, 20),
			B("Skeleton", "BlackForest", 2, 0, 20),
			B("Skeleton", "BlackForest", 2, 0, 20),
			B("Ghost", "BlackForest", 2, 0, 25),
			B("Greydwarf_Shaman", "BlackForest", 3, 0, 30),
			B("Skeleton", "BlackForest", 4, 0, 35),
			B("Greydwarf_Elite", "BlackForest", 0, 1, 25),
			B("Troll", "BlackForest", 0, 1, 55),
			B("Greydwarf_Shaman", "BlackForest", 4, 1, 45),
			B("gd_king", "BlackForest", 5, 2, 185),
			B("gd_king", "BlackForest", 7, 2, 205),
			B("gd_king", "BlackForest", 9, 3, 225),
			B("gd_king", "BlackForest", 9, 3, 225),
			B("gd_king", "BlackForest", 12, 3, 255),
			B("GhostWarrior", "BlackForest", 2, 0, 20),
			B("SkeletonWarrior", "BlackForest", 2, 0, 20),
			B("SkeletonWarriorFire", "BlackForest", 2, 0, 20),
			B("SkeletonWarriorIce", "BlackForest", 2, 0, 20),
			B("TanSpider", "BlackForest", 2, 0, 20),
			B("ForestSpider", "BlackForest", 2, 0, 20),
			B("Greydwarf_Purple_Shroom", "BlackForest", 2, 0, 20),
			B("Greydwarf_Purple", "BlackForest", 2, 0, 20),
			B("Molluscan", "BlackForest", 2, 0, 20),
			B("RRRM_ForestSpider", "BlackForest", 2, 0, 20),
			B("RRRM_GhostWarrior", "BlackForest", 2, 0, 20),
			B("RRRM_SkeletonWarrior", "BlackForest", 2, 0, 20),
			B("RRRM_SkeletonWarriorFire", "BlackForest", 2, 0, 20),
			B("RRRM_SkeletonWarriorIce", "BlackForest", 2, 0, 20),
			B("RRRM_TanSpider", "BlackForest", 2, 0, 20),
			B("RRRM_GDTosser", "BlackForest", 2, 0, 20),
			B("RRR_GDThornweaver", "BlackForest", 3, 0, 30),
			B("RRRN_wildbanditgiant", "BlackForest", 4, 1, 60),
			B("RRRN_wildbandit3", "BlackForest", 4, 1, 60),
			B("TrollT2Elite", "BlackForest", 6, 1, 80),
			B("GDElderBrute", "BlackForest", 6, 1, 85),
			B("GDBurningTorch", "BlackForest", 7, 1, 80),
			B("TrollT3Elite", "BlackForest", 7, 2, 90),
			B("TrollT4Elite", "BlackForest", 10, 2, 110),
			B("Blob", "Swamp", 3, 0, 35),
			B("BlobElite", "Swamp", 4, 0, 40),
			B("BlobElite", "Swamp", 5, 0, 45),
			B("BlobElite", "Swamp", 5, 0, 45),
			B("BlobElite", "Swamp", 5, 0, 45),
			B("BlobElite", "Swamp", 6, 0, 50),
			B("BlobElite", "Swamp", 5, 0, 45),
			B("BlobElite", "Swamp", 5, 0, 45),
			B("BlobElite", "Swamp", 5, 0, 45),
			B("BlobElite", "Swamp", 5, 0, 45),
			B("Skeleton", "Swamp", 3, 0, 30),
			B("Leech", "Swamp", 3, 0, 30),
			B("Ghost", "Swamp", 0, 0, 30),
			B("Draugr", "Swamp", 3, 0, 40),
			B("Surtling", "Swamp", 3, 0, 30),
			B("Surtling", "Swamp", 4, 0, 40),
			B("Wraith", "Swamp", 0, 1, 60),
			B("Wraith", "Swamp", 3, 1, 80),
			B("Draugr_Elite", "Swamp", 0, 1, 60),
			B("Draugr_Elite", "Swamp", 5, 1, 90),
			B("Draugr_Elite", "Swamp", 5, 1, 90),
			B("Draugr_Elite", "Swamp", 5, 1, 90),
			B("Draugr_Elite", "Swamp", 5, 1, 90),
			B("Skeleton", "Swamp", 5, 1, 60),
			B("Skeleton_Poison", "Swamp", 5, 1, 70),
			B("Bonemass", "Swamp", 6, 2, 190),
			B("Eikthyr", "Swamp", 5, 1, 130),
			B("gd_king", "Swamp", 5, 1, 150),
			B("Bonemass", "Swamp", 7, 2, 210),
			B("Bonemass", "Swamp", 8, 2, 220),
			B("Bonemass", "Swamp", 9, 2, 230),
			B("Bonemass", "Swamp", 8, 4, 220),
			B("Bonemass", "Swamp", 11, 4, 250),
			B("GreenSpider", "Swamp", 3, 0, 30),
			B("GreenSpider", "Swamp", 3, 0, 30),
			B("RRRM_GreenSpider", "Swamp", 3, 0, 30),
			B("RRR_GhostVengeful", "Swamp", 3, 0, 30),
			B("UndeadHrungnir", "Swamp", 5, 1, 70),
			B("SkeletonT3Captain", "Swamp", 5, 1, 80),
			B("SkeletonT4Captain", "Swamp", 6, 2, 90),
			B("WraithT3", "Swamp", 7, 2, 40),
			B("Wolf", "Mountain", 4, 0, 40),
			B("Wolf", "Mountain", 4, 0, 40),
			B("Hatchling", "Mountain", 4, 0, 40),
			B("Hatchling", "Mountain", 4, 0, 40),
			B("Skeleton", "Mountain", 4, 0, 40),
			B("Skeleton", "Mountain", 4, 0, 40),
			B("Surtling", "Mountain", 4, 0, 40),
			B("Draugr_Ranged", "Mountain", 4, 0, 40),
			B("Skeleton", "Mountain", 5, 0, 50),
			B("Fenring", "Mountain", 0, 2, 60),
			B("Fenring", "Mountain", 5, 2, 110),
			B("Wolf", "Mountain", 5, 1, 80),
			B("StoneGolem", "Mountain", 0, 2, 90),
			B("StoneGolem", "Mountain", 7, 3, 170),
			B("Ghost", "Mountain", 4, 0, 50),
			B("Ghost", "Mountain", 4, 0, 50),
			B("Wraith", "Mountain", 4, 0, 55),
			B("Wraith", "Mountain", 4, 0, 55),
			B("Eikthyr", "Mountain", 6, 1, 130),
			B("gd_king", "Mountain", 7, 1, 150),
			B("Dragon", "Mountain", 7, 2, 220),
			B("Dragon", "Mountain", 8, 2, 240),
			B("Dragon", "Mountain", 8, 2, 240),
			B("Dragon", "Mountain", 10, 2, 260),
			B("Dragon", "Mountain", 10, 2, 260),
			B("Dragon", "Mountain", 9, 2, 250),
			B("Dragon", "Mountain", 11, 3, 290),
			B("Bear", "Mountain", 4, 0, 50),
			B("Bear", "Mountain", 4, 0, 50),
			B("Bear", "Mountain", 4, 0, 50),
			B("Bear", "Mountain", 5, 0, 40),
			B("Bear", "Mountain", 4, 1, 40),
			B("IceGolem", "Mountain", 4, 0, 40),
			B("SkeletonWarriorIce", "Mountain", 4, 0, 40),
			B("FrostSpider", "Mountain", 4, 0, 40),
			B("FrigidSpider", "Mountain", 4, 0, 40),
			B("ObsidianGolem", "Mountain", 4, 0, 40),
			B("RRRM_StormWolf", "Mountain", 4, 0, 40),
			B("RRRM_FrigidSpider", "Mountain", 4, 0, 40),
			B("RRRM_FrostSpider", "Mountain", 4, 0, 40),
			B("RRRM_IceGolem", "Mountain", 4, 0, 40),
			B("RRRN_mountainbandit1", "Mountain", 4, 0, 40),
			B("RRRN_mountainbandit2", "Mountain", 4, 0, 40),
			B("RRRN_mountainbandit3", "Mountain", 9, 1, 140),
			B("IceGolem", "Mountain", 11, 3, 340),
			B("Serpent", "Ocean", 6, 1, 30),
			B("Kraken", "Ocean", 24, 25, 3030),
			B("RRRM_StormHatchling", "Ocean", 5, 1, 60),
			B("RRRM_DrownedSoul", "Ocean", 4, 0, 35),
			B("RRRM_SmallPolarSerpent", "Ocean", 9, 1, 60),
			B("Goblin", "Plains", 5, 1, 65),
			B("Goblin", "Plains", 5, 1, 65),
			B("Goblin", "Plains", 5, 1, 65),
			B("Hatchling", "Plains", 5, 1, 50),
			B("Skeleton", "Plains", 5, 1, 50),
			B("Lox", "Plains", 5, 1, 95),
			B("Surtling", "Plains", 5, 1, 50),
			B("Draugr_Ranged", "Plains", 5, 1, 50),
			B("Skeleton", "Plains", 6, 1, 60),
			B("Deathsquito", "Plains", 5, 1, 50),
			B("Deathsquito", "Plains", 5, 1, 50),
			B("Deathsquito", "Plains", 8, 4, 65),
			B("GoblinBrute", "Plains", 0, 4, 95),
			B("GoblinBrute", "Plains", 8, 4, 135),
			B("GoblinBrute", "Plains", 10, 4, 195),
			B("GoblinShaman", "Plains", 10, 4, 215),
			B("GoblinShaman", "Plains", 15, 5, 265),
			B("Ghost", "Plains", 5, 1, 50),
			B("Ghost", "Plains", 5, 1, 50),
			B("Wraith", "Plains", 5, 1, 50),
			B("Wraith", "Plains", 5, 1, 50),
			B("Eikthyr", "Plains", 5, 2, 80),
			B("gd_king", "Plains", 8, 2, 90),
			B("gd_king", "Plains", 10, 3, 100),
			B("Dragon", "Plains", 9, 3, 230),
			B("Dragon", "Plains", 12, 4, 300),
			B("Dragon", "Plains", 15, 7, 400),
			B("Bonemass", "Plains", 15, 7, 400),
			B("Bonemass", "Plains", 15, 5, 350),
			B("Bonemass", "Plains", 20, 6, 370),
			B("Bonemass", "Plains", 25, 7, 550),
			B("GoblinKing", "Plains", 15, 4, 550),
			B("GoblinKing", "Plains", 17, 4, 580),
			B("GoblinKing", "Plains", 25, 5, 650),
			B("GoblinKing", "Plains", 35, 9, 850),
			B("GoblinKing", "Plains", 35, 9, 850),
			B("GoblinKing", "Plains", 45, 11, 1050),
			B("GoblinKing", "Plains", 45, 11, 1050),
			B("GoblinKing", "Plains", 55, 13, 1250),
			B("GoblinKing", "Plains", 65, 14, 1300),
			B("GoblinKing", "Plains", 75, 16, 1450),
			B("GoblinKing", "Plains", 80, 16, 2050),
			B("GoblinBase", "Plains", 5, 1, 50),
			B("GoblinShamanNew", "Plains", 5, 1, 50),
			B("GoblinShamanNew", "Plains", 6, 1, 50),
			B("GoblinShamanNew", "Plains", 5, 1, 50),
			B("BrownSpider", "Plains", 5, 1, 50),
			B("RRRM_BrownSpider", "Plains", 5, 1, 50),
			B("RRRN_plainsbandit1", "Plains", 5, 1, 50),
			B("RRRN_plainsbandit2", "Plains", 5, 1, 50),
			B("RRRN_plainsbandit3", "Plains", 11, 3, 200),
			B("Ghost", "Mistlands", 5, 1, 60),
			B("Ghost", "Mistlands", 5, 1, 60),
			B("Wraith", "Mistlands", 5, 1, 60),
			B("Wraith", "Mistlands", 5, 1, 60),
			B("Eikthyr", "Mistlands", 5, 1, 90),
			B("TreeSpider", "Mistlands", 5, 1, 60),
			B("TreeSpider", "Mistlands", 5, 1, 60),
			B("Spider_Boss", "Mistlands", 8, 6, 160),
			B("RRRM_DarkProtector", "Mistlands", 5, 1, 60),
			B("RRRM_DarkSpider", "Mistlands", 5, 1, 60),
			B("RRRM_PoisonDarkSpider", "Mistlands", 5, 1, 60),
			B("RRRM_TreeSpider", "Mistlands", 5, 1, 60),
			B("RRRN_Svartalfr", "Mistlands", 5, 1, 60),
			B("RRRN_SvartalfrArcher", "Mistlands", 5, 1, 60),
			B("RRRN_SvartalfrMage", "Mistlands", 5, 1, 60),
			B("RRRN_SvartalfrHeavy", "Mistlands", 5, 1, 60),
			B("RRRN_SvartalfrBrigade", "Mistlands", 5, 1, 60),
			B("RRR_Grig", "Mistlands", 7, 2, 100),
			B("RRRM_MotherDarkSpider", "Mistlands", 8, 3, 110),
			B("RRRN_SvartalfrQueen", "Mistlands", 14, 6, 310),
			B("Surtling", "AshLands", 6, 2, 70),
			B("Surtling", "AshLands", 6, 2, 70),
			B("Surtling", "AshLands", 6, 2, 70),
			B("Surtling", "AshLands", 6, 2, 70),
			B("GoblinKing", "AshLands", 81, 17, 2070),
			B("GoblinKing", "AshLands", 81, 17, 2070),
			B("GoblinKing", "AshLands", 81, 17, 2070),
			B("GoblinKing", "AshLands", 81, 17, 2070),
			B("GoblinKing", "AshLands", 81, 17, 2070),
			B("FireGolem", "AshLands", 6, 2, 70),
			B("SkeletonWarriorFire", "AshLands", 6, 2, 70),
			B("RRRM_ElderSurtling", "AshLands", 6, 2, 70),
			B("RRRM_AshHatchling", "AshLands", 6, 2, 70),
			B("RRRM_AshNeck", "AshLands", 6, 2, 70),
			B("RRRM_BurnedBones", "AshLands", 6, 2, 70),
			B("RRRM_SwollenBody", "AshLands", 8, 4, 140),
			B("RRRM_FireGolem", "AshLands", 6, 2, 70),
			B("RRRM_BlazingBones", "AshLands", 6, 2, 70),
			B("RRRM_DamnedOne", "AshLands", 12, 4, 130),
			B("RRRM_BlazingDamnedOne", "AshLands", 14, 4, 140),
			B("Troll", "DeepNorth", 7, 2, 80),
			B("Troll", "DeepNorth", 8, 3, 90),
			B("Troll", "DeepNorth", 10, 3, 100),
			B("Troll", "DeepNorth", 12, 4, 130),
			B("Dragon", "DeepNorth", 82, 17, 2080),
			B("Dragon", "DeepNorth", 82, 17, 2080),
			B("Dragon", "DeepNorth", 82, 17, 2080),
			B("Dragon", "DeepNorth", 82, 17, 2080),
			B("Bear", "DeepNorth", 7, 2, 90),
			B("Bear", "DeepNorth", 7, 2, 80),
			B("SkeletonWarriorIce", "DeepNorth", 7, 2, 80),
			B("IceGolem", "DeepNorth", 7, 2, 80),
			B("RRRM_AngryFrozenCorpse", "DeepNorth", 7, 2, 80),
			B("RRRM_FrozenCorpse", "DeepNorth", 7, 2, 80),
			B("RRRM_PolarFenring", "DeepNorth", 7, 2, 80),
			B("RRRM_PolarLox", "DeepNorth", 7, 2, 80),
			B("RRRM_SilverGolem", "DeepNorth", 7, 2, 80),
			B("RRRM_DevourerFenring", "DeepNorth", 9, 8, 180),
			B("RRRM_StormFenring", "DeepNorth", 9, 8, 180),
			B("RRRM_ForgottenOne", "DeepNorth", 9, 8, 180),
			B("RRRM_Jotunn", "DeepNorth", 12, 12, 280)
		};

		private static string B(string targetId, string biome, int iron, int gold, int coins)
		{
			return $"{targetId}|{biome}|{iron}|{gold}|{coins}";
		}

		public static string ToJson(string[] parts)
		{
			return "{\"TargetID\":\"" + parts[0] + "\",\"Biome\":\"" + parts[1] + "\",\"RewardIron\":" + parts[2] + ",\"RewardGold\":" + parts[3] + ",\"RewardCoins\":" + parts[4] + "}";
		}
	}
}