Decompiled source of Passive Item Expansion Fix v0.1.0

Passive_Item_Expansion_Fix.dll

Decompiled 15 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using Microsoft.CodeAnalysis;
using RoR2;
using RoR2.EntitlementManagement;
using RoR2.ExpansionManagement;
using RoR2.Skills;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.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 RiskOfResources.Passive_Item_Expansion_Fix
{
	[BepInPlugin("com.riskofresources.fix.dlc.passive", "Passive_Item_Expansion_Fix", "0.1.0")]
	internal class Plugin : BaseUnityPlugin
	{
		public const string version = "0.1.0";

		public const string identifier = "com.riskofresources.fix.dlc.passive";

		protected void Awake()
		{
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate
			{
				//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
				LocalUserEntitlementTracker localUserEntitlementTracker = EntitlementManager.localUserEntitlementTracker;
				foreach (SkillDef allSkillDef in SkillCatalog.allSkillDefs)
				{
					PassiveItemSkillDef val = (PassiveItemSkillDef)(object)((allSkillDef is PassiveItemSkillDef) ? allSkillDef : null);
					if (val != null)
					{
						ItemDef passiveItem = val.passiveItem;
						if (Object.op_Implicit((Object)(object)passiveItem))
						{
							ref ExpansionDef requiredExpansion = ref passiveItem.requiredExpansion;
							if (Object.op_Implicit((Object)(object)requiredExpansion))
							{
								Debug.Log((object)("Removing expansion for item `" + ((Object)passiveItem).name + "`..."));
								EntitlementDef requiredEntitlement = requiredExpansion.requiredEntitlement;
								if (!Object.op_Implicit((Object)(object)requiredEntitlement) || ((BaseUserEntitlementTracker<LocalUser>)(object)localUserEntitlementTracker).AnyUserHasEntitlement(requiredEntitlement))
								{
									requiredExpansion = null;
									foreach (RuleChoiceDef allChoicesDef in RuleCatalog.allChoicesDefs)
									{
										if (allChoicesDef.itemIndex == passiveItem.itemIndex)
										{
											allChoicesDef.requiredExpansionDef = null;
											Debug.Log((object)"...rule choice found.");
										}
									}
								}
								else
								{
									Debug.Log((object)"...content not available.");
								}
							}
						}
					}
				}
			});
		}
	}
}