Decompiled source of CustomInteractiblesSpawnChance v1.1.1

CustomInteractiblesSpawnChance.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
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 Microsoft.CodeAnalysis;
using On.RoR2;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
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("CustomInteractiblesSpawnChance")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+2619167e6e23ef7448a7a5bba9a8b89a6f160d21")]
[assembly: AssemblyProduct("CustomInteractiblesSpawnChance")]
[assembly: AssemblyTitle("CustomInteractiblesSpawnChance")]
[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 CustomSpawnChanceForCleansingPoolsChestsAndShrines_v2
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.pseudo.CustomInteractiblesSpawnChance", "Custom spawn shrine", "1.1.1")]
	public class CustomSpawnChanceForCleansingPoolsChestsAndShrines_v2 : BaseUnityPlugin
	{
		public const string PluginGUID = "com.pseudo.CustomInteractiblesSpawnChance";

		public const string PluginName = "Custom spawn shrine";

		public const string PluginVersion = "1.1.1";

		private static readonly List<string> Interactibles = new List<string>
		{
			"iscChest1", "iscChest2", "iscChest1Stealthed", "iscCategoryChestDamage", "iscCategoryChestHealing", "iscCategoryChestUtility", "iscCategoryChest2Damage", "iscCategoryChest2Healing", "iscCategoryChest2Utility", "iscGoldChest",
			"iscTripleShop", "iscTripleShopLarge", "iscTripleShopEquipment", "iscCasinoChest", "iscBarrel1", "iscLunarChest", "iscEquipmentBarrel", "iscScrapper", "iscRadarTower", "iscDuplicator",
			"iscDuplicatorLarge", "iscDuplicatorWild", "iscDuplicatorMilitary", "iscBrokenTurret1", "iscBrokenDrone1", "iscBrokenDrone2", "iscBrokenEmergencyDrone", "iscBrokenMissileDrone", "iscBrokenEquipmentDrone", "iscBrokenFlameDrone",
			"iscBrokenMegaDrone", "iscShrineChance", "iscShrineCombat", "iscShrineBlood", "iscShrineBoss", "iscShrineHealing", "iscShrineRestack", "iscShrineGoldshoresAccess", "iscShrineCleanse", "iscVoidCamp",
			"iscVoidChest", "iscVoidCoinBarrel"
		};

		private static readonly Dictionary<string, string> InteractibleToLocalized = new Dictionary<string, string>
		{
			{ "iscChest1", "Small Chest" },
			{ "iscChest2", "Large Chest" },
			{ "iscChest1Stealthed", "Invisible Chest" },
			{ "iscCategoryChestDamage", "Damage Chest" },
			{ "iscCategoryChestHealing", "Healing Chest" },
			{ "iscCategoryChestUtility", "Utility Chest" },
			{ "iscCategoryChest2Damage", "Large Damage Chest" },
			{ "iscCategoryChest2Healing", "Large Healing Chest" },
			{ "iscCategoryChest2Utility", "Large Utility Chest" },
			{ "iscGoldChest", "Legendary Chest" },
			{ "iscTripleShop", "Common Triple Shop" },
			{ "iscTripleShopLarge", "Uncommon Triple Shop" },
			{ "iscTripleShopEquipment", "Triple Equipment Shop" },
			{ "iscCasinoChest", "Adaptive Chest" },
			{ "iscBarrel1", "Barrel" },
			{ "iscLunarChest", "Lunar Pod" },
			{ "iscEquipmentBarrel", "Equipment Barrel" },
			{ "iscScrapper", "Scrapper" },
			{ "iscRadarTower", "Radio Scanner" },
			{ "iscDuplicator", "Common 3D Printer" },
			{ "iscDuplicatorLarge", "Uncommon 3D Printer" },
			{ "iscDuplicatorWild", "Overgrown 3D Printer" },
			{ "iscDuplicatorMilitary", "Mili-Tech Printer" },
			{ "iscBrokenTurret1", "Gunner Turret" },
			{ "iscBrokenDrone1", "Gunner Drone" },
			{ "iscBrokenDrone2", "Healing Drone" },
			{ "iscBrokenEmergencyDrone", "Emergency Drone" },
			{ "iscBrokenMissileDrone", "Missile Drone" },
			{ "iscBrokenEquipmentDrone", "Equipment Drone" },
			{ "iscBrokenFlameDrone", "Incinerator Drone" },
			{ "iscBrokenMegaDrone", "TC-280 Prototype" },
			{ "iscShrineChance", "Shrine of Chance" },
			{ "iscShrineCombat", "Shrine of Combat" },
			{ "iscShrineBlood", "Shrine of Blood" },
			{ "iscShrineBoss", "Shrine of the Mountain" },
			{ "iscShrineHealing", "Shrine of the Woods" },
			{ "iscShrineRestack", "Shrine of Order" },
			{ "iscShrineGoldshoresAccess", "Altar of Gold" },
			{ "iscShrineCleanse", "Cleansing Pool" },
			{ "iscVoidCamp", "Void Seed" },
			{ "iscVoidChest", "Void Cradle" },
			{ "iscVoidTriple", "Void Potential" },
			{ "iscVoidCoinBarrel", "Void Stalk" }
		};

		public static Dictionary<string, ConfigEntry<float>> InteractibleToBind = new Dictionary<string, ConfigEntry<float>>
		{
			["iscChest1"] = IscChest1,
			["iscChest2"] = IscChest2,
			["iscChest1Stealthed"] = IscChest1Stealthed,
			["iscCategoryChestDamage"] = IscCategoryChestDamage,
			["iscCategoryChestHealing"] = IscCategoryChestHealing,
			["iscCategoryChestUtility"] = IscCategoryChestUtility,
			["iscCategoryChest2Damage"] = IscCategoryChest2Damage,
			["iscCategoryChest2Healing"] = IscCategoryChest2Healing,
			["iscCategoryChest2Utility"] = IscCategoryChest2Utility,
			["iscGoldChest"] = IscGoldChest,
			["iscTripleShop"] = IscTripleShop,
			["iscTripleShopLarge"] = IscTripleShopLarge,
			["iscTripleShopEquipment"] = IscTripleShopEquipment,
			["iscCasinoChest"] = IscCasinoChest,
			["iscBarrel1"] = IscBarrel1,
			["iscLunarChest"] = IscLunarChest,
			["iscEquipmentBarrel"] = IscEquipmentBarrel,
			["iscScrapper"] = IscScrapper,
			["iscRadarTower"] = IscRadarTower,
			["iscDuplicator"] = IscDuplicator,
			["iscDuplicatorLarge"] = IscDuplicatorLarge,
			["iscDuplicatorWild"] = IscDuplicatorWild,
			["iscDuplicatorMilitary"] = IscDuplicatorMilitary,
			["iscBrokenTurret1"] = IscBrokenTurret1,
			["iscBrokenDrone1"] = IscBrokenDrone1,
			["iscBrokenDrone2"] = IscBrokenDrone2,
			["iscBrokenEmergencyDrone"] = IscBrokenEmergencyDrone,
			["iscBrokenMissileDrone"] = IscBrokenMissileDrone,
			["iscBrokenEquipmentDrone"] = IscBrokenEquipmentDrone,
			["iscBrokenFlameDrone"] = IscBrokenFlameDrone,
			["iscBrokenMegaDrone"] = IscBrokenMegaDrone,
			["iscShrineChance"] = IscShrineChance,
			["iscShrineCombat"] = IscShrineCombat,
			["iscShrineBlood"] = IscShrineBlood,
			["iscShrineBoss"] = IscShrineBoss,
			["iscShrineHealing"] = IscShrineHealing,
			["iscShrineRestack"] = IscShrineRestack,
			["iscShrineGoldshoresAccess"] = IscShrineGoldshoresAccess,
			["iscShrineCleanse"] = IscShrineCleanse,
			["iscVoidCamp"] = IscVoidCamp,
			["iscVoidChest"] = IscVoidChest,
			["iscVoidTriple"] = IscVoidTriple,
			["iscVoidCoinBarrel"] = IscVoidCoinBarrel
		};

		public static Dictionary<string, string> InteractibleToGroup = new Dictionary<string, string>
		{
			{ "iscChest1", "Chests" },
			{ "iscChest2", "Chests" },
			{ "iscChest1Stealthed", "Chests" },
			{ "iscCategoryChestDamage", "Chests" },
			{ "iscCategoryChestHealing", "Chests" },
			{ "iscCategoryChestUtility", "Chests" },
			{ "iscCategoryChest2Damage", "Chests" },
			{ "iscCategoryChest2Healing", "Chests" },
			{ "iscCategoryChest2Utility", "Chests" },
			{ "iscGoldChest", "Chests" },
			{ "iscTripleShop", "Multishop" },
			{ "iscTripleShopLarge", "Multishop" },
			{ "iscTripleShopEquipment", "Multishop" },
			{ "iscCasinoChest", "Multishop" },
			{ "iscBarrel1", "Misc" },
			{ "iscLunarChest", "Misc" },
			{ "iscEquipmentBarrel", "Misc" },
			{ "iscScrapper", "Misc" },
			{ "iscRadarTower", "Misc" },
			{ "iscDuplicator", "Printers" },
			{ "iscDuplicatorLarge", "Printers" },
			{ "iscDuplicatorWild", "Printers" },
			{ "iscDuplicatorMilitary", "Printers" },
			{ "iscBrokenTurret1", "Drones" },
			{ "iscBrokenDrone1", "Drones" },
			{ "iscBrokenDrone2", "Drones" },
			{ "iscBrokenEmergencyDrone", "Drones" },
			{ "iscBrokenMissileDrone", "Drones" },
			{ "iscBrokenEquipmentDrone", "Drones" },
			{ "iscBrokenFlameDrone", "Drones" },
			{ "iscBrokenMegaDrone", "Drones" },
			{ "iscShrineChance", "Shrines" },
			{ "iscShrineCombat", "Shrines" },
			{ "iscShrineBlood", "Shrines" },
			{ "iscShrineBoss", "Shrines" },
			{ "iscShrineHealing", "Shrines" },
			{ "iscShrineRestack", "Shrines" },
			{ "iscShrineGoldshoresAccess", "Shrines" },
			{ "iscShrineCleanse", "Shrines" },
			{ "iscVoidCamp", "Void" },
			{ "iscVoidChest", "Void" },
			{ "iscVoidTriple", "Void" },
			{ "iscVoidCoinBarrel", "Void" }
		};

		public static ConfigEntry<float> InteractibleCountMultiplier { get; set; }

		public static ConfigEntry<bool> ResetConfig { get; set; }

		public static ConfigEntry<float> IscChest1 { get; set; }

		public static ConfigEntry<float> IscChest2 { get; set; }

		public static ConfigEntry<float> IscChest1Stealthed { get; set; }

		public static ConfigEntry<float> IscCategoryChestDamage { get; set; }

		public static ConfigEntry<float> IscCategoryChestHealing { get; set; }

		public static ConfigEntry<float> IscCategoryChestUtility { get; set; }

		public static ConfigEntry<float> IscCategoryChest2Damage { get; set; }

		public static ConfigEntry<float> IscCategoryChest2Healing { get; set; }

		public static ConfigEntry<float> IscCategoryChest2Utility { get; set; }

		public static ConfigEntry<float> IscGoldChest { get; set; }

		public static ConfigEntry<float> IscTripleShop { get; set; }

		public static ConfigEntry<float> IscTripleShopLarge { get; set; }

		public static ConfigEntry<float> IscTripleShopEquipment { get; set; }

		public static ConfigEntry<float> IscCasinoChest { get; set; }

		public static ConfigEntry<float> IscBarrel1 { get; set; }

		public static ConfigEntry<float> IscLunarChest { get; set; }

		public static ConfigEntry<float> IscEquipmentBarrel { get; set; }

		public static ConfigEntry<float> IscScrapper { get; set; }

		public static ConfigEntry<float> IscRadarTower { get; set; }

		public static ConfigEntry<float> IscDuplicator { get; set; }

		public static ConfigEntry<float> IscDuplicatorLarge { get; set; }

		public static ConfigEntry<float> IscDuplicatorWild { get; set; }

		public static ConfigEntry<float> IscDuplicatorMilitary { get; set; }

		public static ConfigEntry<float> IscBrokenTurret1 { get; set; }

		public static ConfigEntry<float> IscBrokenDrone1 { get; set; }

		public static ConfigEntry<float> IscBrokenDrone2 { get; set; }

		public static ConfigEntry<float> IscBrokenEmergencyDrone { get; set; }

		public static ConfigEntry<float> IscBrokenMissileDrone { get; set; }

		public static ConfigEntry<float> IscBrokenEquipmentDrone { get; set; }

		public static ConfigEntry<float> IscBrokenFlameDrone { get; set; }

		public static ConfigEntry<float> IscBrokenMegaDrone { get; set; }

		public static ConfigEntry<float> IscShrineChance { get; set; }

		public static ConfigEntry<float> IscShrineCombat { get; set; }

		public static ConfigEntry<float> IscShrineBlood { get; set; }

		public static ConfigEntry<float> IscShrineBoss { get; set; }

		public static ConfigEntry<float> IscShrineHealing { get; set; }

		public static ConfigEntry<float> IscShrineRestack { get; set; }

		public static ConfigEntry<float> IscShrineGoldshoresAccess { get; set; }

		public static ConfigEntry<float> IscShrineCleanse { get; set; }

		public static ConfigEntry<float> IscVoidCamp { get; set; }

		public static ConfigEntry<float> IscVoidChest { get; set; }

		public static ConfigEntry<float> IscVoidTriple { get; set; }

		public static ConfigEntry<float> IscVoidCoinBarrel { get; set; }

		public void Awake()
		{
			Log.Init(((BaseUnityPlugin)this).Logger);
			ConfigSetup();
			Hooks();
		}

		private void ConfigSetup()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Expected O, but got Unknown
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Expected O, but got Unknown
			SliderConfig val = new SliderConfig
			{
				min = 10f,
				max = 10000f
			};
			SliderConfig val2 = new SliderConfig
			{
				min = 0f,
				max = 10000f
			};
			InteractibleCountMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("!General", "Count multiplier", 100f, new ConfigDescription("Multiply the TOTAL number of spawnable interactibles. (Capped at 10000% or 100x).", (AcceptableValueBase)null, Array.Empty<object>()));
			ModSettingsManager.AddOption((BaseOption)new SliderOption(InteractibleCountMultiplier, val));
			ResetConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("!General", "Reset config on next launch.", true, new ConfigDescription("Config will change from using values from 0-100 to 0%-10000%. This will reset all values to 100% on next launch.", (AcceptableValueBase)null, Array.Empty<object>()));
			if (ResetConfig.Value)
			{
				InteractibleCountMultiplier.Value = 100f;
			}
			foreach (string interactible in Interactibles)
			{
				ConfigEntry<float> val3 = ((BaseUnityPlugin)this).Config.Bind<float>(InteractibleToGroup[interactible], InteractibleToLocalized[interactible], 100f, new ConfigDescription("Multiply the weighted chance to spawn a/an " + InteractibleToLocalized[interactible] + ". Where 100% is unchanged, 200% is 2x(twice) and 50% is 0.5x(half).", (AcceptableValueBase)null, Array.Empty<object>()));
				if (ResetConfig.Value)
				{
					val3.Value = 100f;
				}
				InteractibleToBind[interactible] = val3;
				ModSettingsManager.AddOption((BaseOption)new SliderOption(val3, val2));
			}
			ResetConfig.Value = false;
		}

		private void Hooks()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			SceneDirector.GenerateInteractableCardSelection += new hook_GenerateInteractableCardSelection(SceneDirector_GenerateInteractableCardSelection);
		}

		private WeightedSelection<DirectorCard> SceneDirector_GenerateInteractableCardSelection(orig_GenerateInteractableCardSelection methodReference, SceneDirector thisReference)
		{
			thisReference.interactableCredit = (int)((float)thisReference.interactableCredit * Mathf.Clamp(InteractibleCountMultiplier.Value / 100f, 0.1f, 100f));
			WeightedSelection<DirectorCard> val = methodReference.Invoke(thisReference);
			for (int i = 0; i < val.Count; i++)
			{
				if (val == null)
				{
					continue;
				}
				_ = ref val.choices[i];
				if (1 == 0)
				{
					continue;
				}
				string name = ((Object)val.choices[i].value.spawnCard).name;
				if (InteractibleToBind.TryGetValue(name.Replace("Sandy", "").Replace("Snowy", ""), out var value))
				{
					if (value.Value < 0f)
					{
						value.Value = 0f;
					}
					val.choices[i].weight *= value.Value / 100f;
				}
			}
			return val;
		}
	}
	internal static class Log
	{
		internal static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void LogDebug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void LogError(object data)
		{
			_logSource.LogError(data);
		}

		internal static void LogFatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void LogInfo(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void LogMessage(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void LogWarning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
}