Decompiled source of GoldChestForAll v1.0.21

GoldChestForAll.dll

Decompiled 3 months ago
using System;
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.Bootstrap;
using BepInEx.Configuration;
using HG.Reflection;
using Microsoft.CodeAnalysis;
using On.RoR2;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("GoldChestForAll")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Mod for Risk of Rain 2")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+80896bdb95b2c28b08174e108d14e5acfdc78100")]
[assembly: AssemblyProduct("GoldChestForAll")]
[assembly: AssemblyTitle("GoldChestForAll")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class MemberNotNullAttribute : Attribute
	{
		public string[] Members { get; }

		public MemberNotNullAttribute(string member)
		{
			Members = new string[1] { member };
		}

		public MemberNotNullAttribute(params string[] members)
		{
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class MemberNotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public string[] Members { get; }

		public MemberNotNullWhenAttribute(bool returnValue, string member)
		{
			ReturnValue = returnValue;
			Members = new string[1] { member };
		}

		public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
		{
			ReturnValue = returnValue;
			Members = members;
		}
	}
}
namespace GoldChestForAll
{
	[BepInPlugin("com.DestroyedClone.GoldChestForAll", "GoldChestForAll", "1.0.21")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class GCFAPlugin : BaseUnityPlugin
	{
		public static BasicPickupDropTable goldChestDropTable;

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

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

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

		public int ParticipatingPlayerCount => Run.instance.participatingPlayerCount;

		public void Start()
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected O, but got Unknown
			CfgCostMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Gold Chest Cost", "Cost Multiplier", 1f, "Multiply the costs of gold chests. Intended for balance, but you can just set it to '1' if you want it unchanged. Applies after \"Additive Cost Multiplier Per Player\". Applies on stage start.");
			CfgIntent = ((BaseUnityPlugin)this).Config.Bind<bool>("Default", "Only Abyssal Depths and Sundered Grove", true, "If true, then only the guaranteed chest on Sundered Grove and Abyssal Depths will be affected. Applied on stage start.");
			CfgCostMultiplierPerPlayerAdditive = ((BaseUnityPlugin)this).Config.Bind<float>("Gold Chest Cost", "Additive Cost Multiplier Per Player", 0f, "Ex: 0.05 would be a 5% increase in cost per player. 5% x 4 players = 20%. Applied on stage start.");
			AsyncOperationHandle<BasicPickupDropTable> val = Addressables.LoadAssetAsync<BasicPickupDropTable>((object)"RoR2/Base/GoldChest/dtGoldChest.asset");
			val.Completed += delegate(AsyncOperationHandle<BasicPickupDropTable> obj)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				goldChestDropTable = obj.Acquire().Result;
			};
			ChestBehavior.ItemDrop += new hook_ItemDrop(DuplicateDrops);
			PurchaseInteraction.Awake += new hook_Awake(MultiplyChestCost);
			if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"))
			{
				ModCompat_RiskOfOptions.Initialize();
			}
		}

		private bool IsValidScene(Transform chestTransform)
		{
			if (CfgIntent.Value)
			{
				bool flag = Object.op_Implicit((Object)(object)chestTransform.parent) && ((Object)chestTransform.parent).name == "HOLDER: Newt Statues and Preplaced Chests";
				return (Object.op_Implicit((Object)(object)chestTransform.parent) && Object.op_Implicit((Object)(object)chestTransform.parent.parent) && ((Object)chestTransform.parent.parent).name == "GROUP: Large Treasure Chests") || flag;
			}
			return true;
		}

		private void MultiplyChestCost(orig_Awake orig, PurchaseInteraction self)
		{
			ChestBehavior self2 = default(ChestBehavior);
			if (NetworkServer.active && IsValidScene(((Component)self).transform) && ((Component)self).TryGetComponent<ChestBehavior>(ref self2) && ChestIsLegendary(self2))
			{
				float num = 1f;
				if (CfgCostMultiplierPerPlayerAdditive.Value != 0f)
				{
					num += (float)ParticipatingPlayerCount * CfgCostMultiplierPerPlayerAdditive.Value;
				}
				float num2 = num * CfgCostMultiplier.Value;
				self.Networkcost = (int)Mathf.Ceil((float)self.cost * num2);
			}
			orig.Invoke(self);
		}

		private void DuplicateDrops(orig_ItemDrop orig, ChestBehavior self)
		{
			if (NetworkServer.active && IsValidScene(((Component)self).transform) && ChestIsLegendary(self) && ParticipatingPlayerCount >= 2)
			{
				self.dropCount += ParticipatingPlayerCount - 1;
			}
			orig.Invoke(self);
		}

		private static bool ChestIsLegendary(ChestBehavior self)
		{
			if (Object.op_Implicit((Object)(object)self) && Object.op_Implicit((Object)(object)self.dropTable))
			{
				return (Object)(object)self.dropTable == (Object)(object)goldChestDropTable;
			}
			return false;
		}
	}
	internal class ModCompat_RiskOfOptions
	{
		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void Initialize()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			ModSettingsManager.SetModDescription("Makes the healthbar look like how it does in ROR1 when immune", "com.DestroyedClone.GoldChestForAll", "GoldChestForAll");
			ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(GCFAPlugin.CfgCostMultiplier));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(GCFAPlugin.CfgIntent));
			ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(GCFAPlugin.CfgCostMultiplierPerPlayerAdditive));
		}
	}
}