Decompiled source of Huntdown Addon v1.0.0

plugins/HuntdownAddon/HuntdownAddon.dll

Decompiled 8 hours ago
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Huntdown;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("HuntdownAddon")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Yeah :D")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+e26360f7c96fa668bb8320c512c7b0f93350c8c4")]
[assembly: AssemblyProduct("HuntdownAddon")]
[assembly: AssemblyTitle("HuntdownAddon")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 HuntdownAddon
{
	public static class ConfigSettings
	{
		private enum ConfigSections
		{
			[Description("1: Toggle Missions")]
			Toggle,
			[Description("2: Mission Weights")]
			Weight,
			[Description("1: Mission Rewards")]
			Reward
		}

		public enum ConfigIndexes
		{
			ToggleBaboonHawk,
			ToggleDuo,
			ToggleInfection,
			ToggleHorde,
			WeightBaboonHawk,
			WeightDuo,
			WeightInfection,
			WeightHorde,
			RewardAbsurd,
			RewardStupid
		}

		public static readonly ConfigurableSetting[] AllConfigSettings = (ConfigurableSetting[])(object)new ConfigurableSetting[10]
		{
			new ConfigurableSetting
			{
				Index = ConfigIndexes.ToggleBaboonHawk,
				Section = ConfigSections.Toggle.GetDescription(),
				Key = "Lone Baboon Hawk Mission Enabled",
				DefaultValue = true,
				Description = new ConfigDescription("Whether a Lone Baboon Hawk can be assigned as the hunt target target or not", (AcceptableValueBase)null, Array.Empty<object>())
			},
			new ConfigurableSetting
			{
				Index = ConfigIndexes.ToggleDuo,
				Section = ConfigSections.Toggle.GetDescription(),
				Key = "Dynamic Duo Mission Enabled",
				DefaultValue = true,
				Description = new ConfigDescription("Whether a Dynamic Duo can be assigned as the hunt target target or not", (AcceptableValueBase)null, Array.Empty<object>())
			},
			new ConfigurableSetting
			{
				Index = ConfigIndexes.ToggleInfection,
				Section = ConfigSections.Toggle.GetDescription(),
				Key = "Zombie Infection Mission Enabled",
				DefaultValue = true,
				Description = new ConfigDescription("Whether a Zombie Infection can be assigned as the hunt target target or not", (AcceptableValueBase)null, Array.Empty<object>())
			},
			new ConfigurableSetting
			{
				Index = ConfigIndexes.ToggleHorde,
				Section = ConfigSections.Toggle.GetDescription(),
				Key = "Left 4 Dead 2 Mission Enabled",
				DefaultValue = true,
				Description = new ConfigDescription("Whether a Massive Horde can be assigned as the hunt target target or not", (AcceptableValueBase)null, Array.Empty<object>())
			},
			new ConfigurableSetting
			{
				Index = ConfigIndexes.WeightBaboonHawk,
				Section = ConfigSections.Weight.GetDescription(),
				Key = "Lone Baboon Hawk Mission Weight",
				DefaultValue = 40,
				Description = new ConfigDescription("Higher value = more likely. The likelihood that a Lone Baboon Hawk will be the target.", (AcceptableValueBase)null, Array.Empty<object>())
			},
			new ConfigurableSetting
			{
				Index = ConfigIndexes.WeightDuo,
				Section = ConfigSections.Weight.GetDescription(),
				Key = "Dynamic Duo Mission Weight",
				DefaultValue = 30,
				Description = new ConfigDescription("Higher value = more likely. The likelihood that a Dynamic Duo will be the target.", (AcceptableValueBase)null, Array.Empty<object>())
			},
			new ConfigurableSetting
			{
				Index = ConfigIndexes.WeightInfection,
				Section = ConfigSections.Weight.GetDescription(),
				Key = "Zombie Infection Mission Weight",
				DefaultValue = 6,
				Description = new ConfigDescription("Higher value = more likely. The likelihood that a Zombie Infection will be the target.", (AcceptableValueBase)null, Array.Empty<object>())
			},
			new ConfigurableSetting
			{
				Index = ConfigIndexes.WeightHorde,
				Section = ConfigSections.Weight.GetDescription(),
				Key = "Left 4 Dead 2 Mission Weight",
				DefaultValue = 2,
				Description = new ConfigDescription("Higher value = more likely. The likelihood that a Massive Horde will be the target.", (AcceptableValueBase)null, Array.Empty<object>())
			},
			new ConfigurableSetting
			{
				Index = ConfigIndexes.RewardAbsurd,
				Section = ConfigSections.Reward.GetDescription(),
				Key = "Absurd Mission Reward",
				DefaultValue = 365,
				Description = new ConfigDescription("How much the scrap dropped from an absurd mission is worth (Zombie Infection).", (AcceptableValueBase)null, Array.Empty<object>())
			},
			new ConfigurableSetting
			{
				Index = ConfigIndexes.RewardStupid,
				Section = ConfigSections.Reward.GetDescription(),
				Key = "Stupid Mission Reward",
				DefaultValue = 510,
				Description = new ConfigDescription("How much the scrap dropped from a stupid mission is worth (Left 4 Dead 2).", (AcceptableValueBase)null, Array.Empty<object>())
			}
		};

		public static ConfigEntryBase[] ConfigEntries = (ConfigEntryBase[])(object)new ConfigEntryBase[AllConfigSettings.Length];

		private static string GetDescription(this Enum value)
		{
			FieldInfo field = value.GetType().GetField(value.ToString());
			if (field.GetCustomAttributes(typeof(DescriptionAttribute), inherit: false) is DescriptionAttribute[] source && source.Any())
			{
				return source.First().Description;
			}
			return value.ToString();
		}

		public static void BindConfigSettings()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < AllConfigSettings.Length; i++)
			{
				HuntdownAddon._logger.LogInfo((object)$"[{i}] Binding - {AllConfigSettings[i].Key}");
				BindAnyObject(AllConfigSettings[i], i);
			}
		}

		private static void BindAnyObject(ConfigurableSetting setting, int index)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			if (setting.DefaultValue is int || setting.DefaultValue is Enum)
			{
				ConfigEntryBase[] configEntries = ConfigEntries;
				string section = setting.Section;
				string key = setting.Key;
				int defaultValue = (int)setting.DefaultValue;
				ConfigDescription description = setting.Description;
				configEntries[index] = (ConfigEntryBase)(object)Bind(section, key, defaultValue, (description != null) ? description.Description : null);
			}
			else if (setting.DefaultValue is bool)
			{
				ConfigEntryBase[] configEntries2 = ConfigEntries;
				string section2 = setting.Section;
				string key2 = setting.Key;
				bool defaultValue2 = (bool)setting.DefaultValue;
				ConfigDescription description2 = setting.Description;
				configEntries2[index] = (ConfigEntryBase)(object)Bind(section2, key2, defaultValue2, (description2 != null) ? description2.Description : null);
			}
		}

		private static ConfigEntry<T> Bind<T>(string section, string key, T DefaultValue, string Description = null)
		{
			return ((BaseUnityPlugin)HuntdownAddon._instance).Config.Bind<T>(section, key, DefaultValue, Description);
		}
	}
	[BepInPlugin("HuntdownAddon", "HuntdownAddon", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class HuntdownAddon : BaseUnityPlugin
	{
		public static HuntdownAddon _instance;

		public static RewardPool AbsurdRewardPool;

		public static RewardPool StupidRewardPool;

		public static ManualLogSource _logger;

		private void Awake()
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			if ((Object)(object)_instance == (Object)null)
			{
				_instance = this;
			}
			_logger = ((BaseUnityPlugin)this).Logger;
			ConfigSettings.BindConfigSettings();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin HuntdownAddon is loaded!");
			StoredItem[] storedItems = Huntdown._storedItems;
			StoredItem[] array = (StoredItem[])(object)new StoredItem[3]
			{
				storedItems[71],
				storedItems[49],
				storedItems[77]
			};
			int num = (int)ConfigSettings.ConfigEntries[8].BoxedValue;
			AbsurdRewardPool = new RewardPool(array, num);
			StoredItem[] array2 = (StoredItem[])(object)new StoredItem[1] { storedItems[25] };
			int num2 = (int)ConfigSettings.ConfigEntries[9].BoxedValue;
			StupidRewardPool = new RewardPool(array2, num2);
			RewardPool[] possibleRewardPools = Huntdown._possibleRewardPools;
			Dictionary<EnemyKey, int> spawnDictionary = new Dictionary<EnemyKey, int> { 
			{
				(EnemyKey)10,
				1
			} };
			AddHunt(spawnDictionary, "Lone Baboon Hawk", (int)ConfigSettings.ConfigEntries[4].BoxedValue, possibleRewardPools[0], (bool)ConfigSettings.ConfigEntries[0].BoxedValue);
			Dictionary<EnemyKey, int> spawnDictionary2 = new Dictionary<EnemyKey, int>
			{
				{
					(EnemyKey)4,
					1
				},
				{
					(EnemyKey)1,
					1
				}
			};
			AddHunt(spawnDictionary2, "Dynamic Duo", (int)ConfigSettings.ConfigEntries[5].BoxedValue, possibleRewardPools[2], (bool)ConfigSettings.ConfigEntries[1].BoxedValue);
			Dictionary<EnemyKey, int> spawnDictionary3 = new Dictionary<EnemyKey, int> { 
			{
				(EnemyKey)6,
				8
			} };
			AddHunt(spawnDictionary3, "Zombie Infection", (int)ConfigSettings.ConfigEntries[6].BoxedValue, AbsurdRewardPool, (bool)ConfigSettings.ConfigEntries[2].BoxedValue);
			Dictionary<EnemyKey, int> spawnDictionary4 = new Dictionary<EnemyKey, int> { 
			{
				(EnemyKey)6,
				20
			} };
			AddHunt(spawnDictionary4, "Left 4 Dead 2", (int)ConfigSettings.ConfigEntries[7].BoxedValue, StupidRewardPool, (bool)ConfigSettings.ConfigEntries[3].BoxedValue);
		}

		public void AddHunt(Dictionary<EnemyKey, int> spawnDictionary, string name, int weight, RewardPool rewards, bool enabled = true)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			Array.Resize(ref Huntdown._possibleMissions, Huntdown._possibleMissions.Length + 1);
			Huntdown._possibleMissions[Huntdown._possibleMissions.Length - 1] = new Mission(name, weight, spawnDictionary, enabled, rewards);
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"Added additional hunt '{name}' with a weight of {weight}.");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "HuntdownAddon";

		public const string PLUGIN_NAME = "HuntdownAddon";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}