Decompiled source of Arcrines Artifacts v1.0.0

ArcrinesArtifacts.dll

Decompiled 21 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using On.RoR2;
using R2API;
using RoR2;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Networking;

[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("ArcrinesArtifacts")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ArcrinesArtifacts")]
[assembly: AssemblyTitle("ArcrinesArtifacts")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 ExamplePlugin
{
	internal static class Log
	{
		private static ManualLogSource _logSource;

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

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

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

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

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

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

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
}
namespace ArcrinesArtifacts
{
	[BepInPlugin("com.arcrine.ArcrinesArtifacts", "Arcrine's Artifacts", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class ArcrinesArtifactsPlugin : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_FixedUpdate <>9__12_0;

			public static hook_TakeDamage <>9__12_1;

			public static hook_FixedUpdate <>9__12_2;

			public static hook_OnCharacterDeath <>9__13_0;

			public static CalcChargeRateDelegate <>9__14_2;

			public static hook_Awake <>9__14_0;

			public static hook_RollItem <>9__16_0;

			public static hook_OnInteractionBegin <>9__16_1;

			internal void <ApplyRhythmHooks>b__12_0(orig_FixedUpdate orig, GenericSkill self)
			{
				if (RunArtifactManager.instance.IsArtifactEnabled(rhythmArtifact))
				{
					float rechargeStopwatch = self.rechargeStopwatch;
					orig.Invoke(self);
					if (self.rechargeStopwatch > rechargeStopwatch && self.rechargeStopwatch - rechargeStopwatch < 0.5f)
					{
						self.rechargeStopwatch = rechargeStopwatch;
					}
				}
				else
				{
					orig.Invoke(self);
				}
			}

			internal void <ApplyRhythmHooks>b__12_1(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
			{
				//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e2: Invalid comparison between Unknown and I4
				orig.Invoke(self, damageInfo);
				if (!RunArtifactManager.instance.IsArtifactEnabled(rhythmArtifact))
				{
					return;
				}
				if (Object.op_Implicit((Object)(object)damageInfo.attacker))
				{
					CharacterBody component = damageInfo.attacker.GetComponent<CharacterBody>();
					if (Object.op_Implicit((Object)(object)component) && component.hasEffectiveAuthority)
					{
						float num = damageInfo.damage * 0.02f;
						GenericSkill[] allSkills = component.skillLocator.allSkills;
						foreach (GenericSkill val in allSkills)
						{
							if (val.rechargeStopwatch < val.finalRechargeInterval)
							{
								val.rechargeStopwatch += num;
							}
						}
					}
				}
				if (!Object.op_Implicit((Object)(object)self.body) || !self.body.hasEffectiveAuthority || (int)self.body.teamComponent.teamIndex != 1 || !(damageInfo.damage > 0f))
				{
					return;
				}
				GenericSkill[] allSkills2 = self.body.skillLocator.allSkills;
				foreach (GenericSkill val2 in allSkills2)
				{
					if (val2.rechargeStopwatch < val2.finalRechargeInterval)
					{
						val2.rechargeStopwatch += 1.5f;
					}
				}
			}

			internal void <ApplyRhythmHooks>b__12_2(orig_FixedUpdate orig, CharacterMotor self)
			{
				orig.Invoke(self);
				if (!RunArtifactManager.instance.IsArtifactEnabled(rhythmArtifact) || !Object.op_Implicit((Object)(object)self.body) || !self.body.hasEffectiveAuthority)
				{
					return;
				}
				float magnitude = ((Vector3)(ref self.velocity)).magnitude;
				if (!(magnitude > 0.1f))
				{
					return;
				}
				float num = magnitude * Time.fixedDeltaTime * 0.15f;
				if (!self.isGrounded)
				{
					num *= 2f;
				}
				GenericSkill[] allSkills = self.body.skillLocator.allSkills;
				foreach (GenericSkill val in allSkills)
				{
					if (val.rechargeStopwatch < val.finalRechargeInterval)
					{
						val.rechargeStopwatch += num;
					}
				}
			}

			internal void <ApplyHivemindHooks>b__13_0(orig_OnCharacterDeath orig, GlobalEventManager self, DamageReport damageReport)
			{
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Invalid comparison between Unknown and I4
				//IL_0056: Unknown result type (might be due to invalid IL or missing references)
				//IL_0049: Unknown result type (might be due to invalid IL or missing references)
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
				orig.Invoke(self, damageReport);
				if (!NetworkServer.active || !RunArtifactManager.instance.IsArtifactEnabled(hivemindArtifact) || (int)damageReport.victimTeamIndex != 2)
				{
					return;
				}
				Vector3 val = (Object.op_Implicit((Object)(object)damageReport.victimBody) ? damageReport.victimBody.corePosition : damageReport.damageInfo.position);
				float num = 30f;
				foreach (TeamComponent teamMember in TeamComponent.GetTeamMembers((TeamIndex)2))
				{
					if (Object.op_Implicit((Object)(object)teamMember.body) && (Object)(object)teamMember.body != (Object)(object)damageReport.victimBody && Vector3.Distance(teamMember.body.corePosition, val) <= num)
					{
						teamMember.body.AddTimedBuff(Buffs.TeamWarCry, 5f);
					}
				}
			}

			internal void <ApplyCapitalismHooks>b__14_0(orig_Awake orig, HoldoutZoneController self)
			{
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0035: Expected O, but got Unknown
				orig.Invoke(self);
				((Component)self).gameObject.AddComponent<CapitalismVisuals>();
				object obj = <>9__14_2;
				if (obj == null)
				{
					CalcChargeRateDelegate val = delegate(ref float rate)
					{
						if (RunArtifactManager.instance.IsArtifactEnabled(capitalismArtifact))
						{
							rate = 0f;
						}
					};
					<>9__14_2 = val;
					obj = (object)val;
				}
				self.calcChargeRate += (CalcChargeRateDelegate)obj;
			}

			internal void <ApplyCapitalismHooks>b__14_2(ref float rate)
			{
				if (RunArtifactManager.instance.IsArtifactEnabled(capitalismArtifact))
				{
					rate = 0f;
				}
			}

			internal void <ApplyLocksmithHooks>b__16_0(orig_RollItem orig, ChestBehavior self)
			{
				if (RunArtifactManager.instance.IsArtifactEnabled(locksmithArtifact) && ((Object)((Component)self).gameObject).name.Contains("RustyChest"))
				{
					int num = 0;
					foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
					{
						if (Object.op_Implicit((Object)(object)instance.master.inventory))
						{
							int itemCountPermanent = instance.master.inventory.GetItemCountPermanent(Items.TreasureCache);
							if (itemCountPermanent > num)
							{
								num = itemCountPermanent;
							}
						}
					}
					if (num > 0)
					{
						self.tier1Chance = 80f;
						self.tier2Chance = 20f * (float)num;
						self.tier3Chance = 1f * (float)(num * num);
					}
				}
				orig.Invoke(self);
			}

			internal void <ApplyLocksmithHooks>b__16_1(orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor interactor)
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Invalid comparison between Unknown and I4
				int num = 0;
				Inventory val = null;
				if (RunArtifactManager.instance.IsArtifactEnabled(locksmithArtifact) && (int)self.costType == 12)
				{
					CharacterBody component = ((Component)interactor).GetComponent<CharacterBody>();
					if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.inventory))
					{
						val = component.inventory;
						num = val.GetItemCountPermanent(Items.TreasureCache);
					}
				}
				orig.Invoke(self, interactor);
				if ((Object)(object)val != (Object)null && num > 0)
				{
					int itemCountPermanent = val.GetItemCountPermanent(Items.TreasureCache);
					if (itemCountPermanent < num)
					{
						val.GiveItemPermanent(Items.TreasureCache, num - itemCountPermanent);
					}
				}
			}
		}

		public static ArtifactDef rhythmArtifact;

		public static ArtifactDef hivemindArtifact;

		public static ArtifactDef capitalismArtifact;

		public static ArtifactDef rivalArtifact;

		public static ArtifactDef locksmithArtifact;

		private GameObject potentialPrefab;

		public static GameObject coinPrefab;

		private Inventory customMonsterInventory;

		private float capitalismTimer = 0f;

		public void Awake()
		{
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			Sprite onSprite = LoadSprite("RhythmON.png");
			Sprite offSprite = LoadSprite("RhythmOFF.png");
			Sprite onSprite2 = LoadSprite("HiveON.png");
			Sprite offSprite2 = LoadSprite("HiveOFF.png");
			Sprite onSprite3 = LoadSprite("TaxON.png");
			Sprite offSprite3 = LoadSprite("TaxOFF.png");
			Sprite onSprite4 = LoadSprite("RivalON.png");
			Sprite offSprite4 = LoadSprite("RivalOFF.png");
			Sprite onSprite5 = LoadSprite("LockON.png");
			Sprite offSprite5 = LoadSprite("LockOFF.png");
			rhythmArtifact = CreateArtifact("Artifact of Rhythm", "Cooldowns only recharge when dealing damage or moving.", onSprite, offSprite);
			hivemindArtifact = CreateArtifact("Artifact of the Hivemind", "Killing a monster buffs all nearby monsters.", onSprite2, offSprite2);
			capitalismArtifact = CreateArtifact("Artifact of Capitalism", "The Teleporter no longer charges over time. It drains your gold to charge.", onSprite3, offSprite3);
			rivalArtifact = CreateArtifact("Artifact of the Rival", "Chests drop 3 choices. You pick 1, the monsters get the other 2.", onSprite4, offSprite4);
			locksmithArtifact = CreateArtifact("Artifact of the Locksmith", "Rusted Keys are no longer consumed. Stacking them increases the chance of higher tier rewards.", onSprite5, offSprite5);
			potentialPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/OptionPickup/OptionPickup.prefab").WaitForCompletion();
			coinPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Common/VFX/CoinEmitter.prefab").WaitForCompletion();
			ApplyRhythmHooks();
			ApplyHivemindHooks();
			ApplyCapitalismHooks();
			ApplyRivalHooks();
			ApplyLocksmithHooks();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Arcrine's Artifacts have successfully loaded! Let the chaos begin.");
		}

		private Sprite LoadSprite(string fileName)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), fileName);
			if (File.Exists(text))
			{
				byte[] array = File.ReadAllBytes(text);
				Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
				ImageConversion.LoadImage(val, array);
				return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
			}
			((BaseUnityPlugin)this).Logger.LogError((object)("Could not find icon: " + fileName + " at " + text));
			return null;
		}

		private ArtifactDef CreateArtifact(string name, string description, Sprite onSprite, Sprite offSprite)
		{
			ArtifactDef val = ScriptableObject.CreateInstance<ArtifactDef>();
			val.nameToken = name;
			val.descriptionToken = description;
			val.smallIconSelectedSprite = onSprite;
			val.smallIconDeselectedSprite = offSprite;
			ContentAddition.AddArtifactDef(val);
			return val;
		}

		private void ApplyRhythmHooks()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			object obj = <>c.<>9__12_0;
			if (obj == null)
			{
				hook_FixedUpdate val = delegate(orig_FixedUpdate orig, GenericSkill self)
				{
					if (RunArtifactManager.instance.IsArtifactEnabled(rhythmArtifact))
					{
						float rechargeStopwatch = self.rechargeStopwatch;
						orig.Invoke(self);
						if (self.rechargeStopwatch > rechargeStopwatch && self.rechargeStopwatch - rechargeStopwatch < 0.5f)
						{
							self.rechargeStopwatch = rechargeStopwatch;
						}
					}
					else
					{
						orig.Invoke(self);
					}
				};
				<>c.<>9__12_0 = val;
				obj = (object)val;
			}
			GenericSkill.FixedUpdate += (hook_FixedUpdate)obj;
			object obj2 = <>c.<>9__12_1;
			if (obj2 == null)
			{
				hook_TakeDamage val2 = delegate(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
				{
					//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
					//IL_00e2: Invalid comparison between Unknown and I4
					orig.Invoke(self, damageInfo);
					if (RunArtifactManager.instance.IsArtifactEnabled(rhythmArtifact))
					{
						if (Object.op_Implicit((Object)(object)damageInfo.attacker))
						{
							CharacterBody component = damageInfo.attacker.GetComponent<CharacterBody>();
							if (Object.op_Implicit((Object)(object)component) && component.hasEffectiveAuthority)
							{
								float num = damageInfo.damage * 0.02f;
								GenericSkill[] allSkills = component.skillLocator.allSkills;
								foreach (GenericSkill val4 in allSkills)
								{
									if (val4.rechargeStopwatch < val4.finalRechargeInterval)
									{
										val4.rechargeStopwatch += num;
									}
								}
							}
						}
						if (Object.op_Implicit((Object)(object)self.body) && self.body.hasEffectiveAuthority && (int)self.body.teamComponent.teamIndex == 1 && damageInfo.damage > 0f)
						{
							GenericSkill[] allSkills2 = self.body.skillLocator.allSkills;
							foreach (GenericSkill val5 in allSkills2)
							{
								if (val5.rechargeStopwatch < val5.finalRechargeInterval)
								{
									val5.rechargeStopwatch += 1.5f;
								}
							}
						}
					}
				};
				<>c.<>9__12_1 = val2;
				obj2 = (object)val2;
			}
			HealthComponent.TakeDamage += (hook_TakeDamage)obj2;
			object obj3 = <>c.<>9__12_2;
			if (obj3 == null)
			{
				hook_FixedUpdate val3 = delegate(orig_FixedUpdate orig, CharacterMotor self)
				{
					orig.Invoke(self);
					if (RunArtifactManager.instance.IsArtifactEnabled(rhythmArtifact) && Object.op_Implicit((Object)(object)self.body) && self.body.hasEffectiveAuthority)
					{
						float magnitude = ((Vector3)(ref self.velocity)).magnitude;
						if (magnitude > 0.1f)
						{
							float num = magnitude * Time.fixedDeltaTime * 0.15f;
							if (!self.isGrounded)
							{
								num *= 2f;
							}
							GenericSkill[] allSkills = self.body.skillLocator.allSkills;
							foreach (GenericSkill val4 in allSkills)
							{
								if (val4.rechargeStopwatch < val4.finalRechargeInterval)
								{
									val4.rechargeStopwatch += num;
								}
							}
						}
					}
				};
				<>c.<>9__12_2 = val3;
				obj3 = (object)val3;
			}
			CharacterMotor.FixedUpdate += (hook_FixedUpdate)obj3;
		}

		private void ApplyHivemindHooks()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			object obj = <>c.<>9__13_0;
			if (obj == null)
			{
				hook_OnCharacterDeath val = delegate(orig_OnCharacterDeath orig, GlobalEventManager self, DamageReport damageReport)
				{
					//IL_0023: Unknown result type (might be due to invalid IL or missing references)
					//IL_0029: Invalid comparison between Unknown and I4
					//IL_0056: Unknown result type (might be due to invalid IL or missing references)
					//IL_0049: Unknown result type (might be due to invalid IL or missing references)
					//IL_005b: Unknown result type (might be due to invalid IL or missing references)
					//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
					//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
					orig.Invoke(self, damageReport);
					if (NetworkServer.active && RunArtifactManager.instance.IsArtifactEnabled(hivemindArtifact) && (int)damageReport.victimTeamIndex == 2)
					{
						Vector3 val2 = (Object.op_Implicit((Object)(object)damageReport.victimBody) ? damageReport.victimBody.corePosition : damageReport.damageInfo.position);
						float num = 30f;
						foreach (TeamComponent teamMember in TeamComponent.GetTeamMembers((TeamIndex)2))
						{
							if (Object.op_Implicit((Object)(object)teamMember.body) && (Object)(object)teamMember.body != (Object)(object)damageReport.victimBody && Vector3.Distance(teamMember.body.corePosition, val2) <= num)
							{
								teamMember.body.AddTimedBuff(Buffs.TeamWarCry, 5f);
							}
						}
					}
				};
				<>c.<>9__13_0 = val;
				obj = (object)val;
			}
			GlobalEventManager.OnCharacterDeath += (hook_OnCharacterDeath)obj;
		}

		private void ApplyCapitalismHooks()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			object obj = <>c.<>9__14_0;
			if (obj == null)
			{
				hook_Awake val = delegate(orig_Awake orig, HoldoutZoneController self)
				{
					//IL_002a: Unknown result type (might be due to invalid IL or missing references)
					//IL_002f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0035: Expected O, but got Unknown
					orig.Invoke(self);
					((Component)self).gameObject.AddComponent<CapitalismVisuals>();
					object obj2 = <>c.<>9__14_2;
					if (obj2 == null)
					{
						CalcChargeRateDelegate val2 = delegate(ref float rate)
						{
							if (RunArtifactManager.instance.IsArtifactEnabled(capitalismArtifact))
							{
								rate = 0f;
							}
						};
						<>c.<>9__14_2 = val2;
						obj2 = (object)val2;
					}
					self.calcChargeRate += (CalcChargeRateDelegate)obj2;
				};
				<>c.<>9__14_0 = val;
				obj = (object)val;
			}
			HoldoutZoneController.Awake += (hook_Awake)obj;
			HoldoutZoneController.Update += (hook_Update)delegate(orig_Update orig, HoldoutZoneController self)
			{
				//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
				//IL_0113: Unknown result type (might be due to invalid IL or missing references)
				//IL_0118: Unknown result type (might be due to invalid IL or missing references)
				//IL_011b: Unknown result type (might be due to invalid IL or missing references)
				//IL_012c: Expected O, but got Unknown
				orig.Invoke(self);
				if (NetworkServer.active && RunArtifactManager.instance.IsArtifactEnabled(capitalismArtifact))
				{
					capitalismTimer += Time.deltaTime;
					if (capitalismTimer >= 1f)
					{
						capitalismTimer = 0f;
						uint num = (uint)Mathf.Max(1f, 15f * Run.instance.difficultyCoefficient);
						bool flag = false;
						foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
						{
							CharacterBody body = instance.master.GetBody();
							if (Object.op_Implicit((Object)(object)body))
							{
								float num2 = Vector3.Distance(body.corePosition, ((Component)self).transform.position);
								if (num2 <= self.currentRadius && instance.master.money >= num)
								{
									CharacterMaster master = instance.master;
									master.money -= num;
									flag = true;
									EffectManager.SpawnEffect(coinPrefab, new EffectData
									{
										origin = body.corePosition
									}, true);
									Util.PlaySound("Play_UI_coin", ((Component)body).gameObject);
								}
							}
						}
						if (flag)
						{
							self.charge += 1f / Mathf.Max(1f, self.baseChargeDuration);
						}
					}
				}
			};
		}

		private void ApplyRivalHooks()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			Run.Start += (hook_Start)delegate(orig_Start orig, Run self)
			{
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Expected O, but got Unknown
				orig.Invoke(self);
				if (NetworkServer.active)
				{
					GameObject val = new GameObject("RivalMonsterInventory");
					customMonsterInventory = val.AddComponent<Inventory>();
					NetworkServer.Spawn(val);
				}
			};
			CharacterMaster.OnBodyStart += (hook_OnBodyStart)delegate(orig_OnBodyStart orig, CharacterMaster self, CharacterBody body)
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Invalid comparison between Unknown and I4
				orig.Invoke(self, body);
				if (NetworkServer.active && (int)self.teamIndex == 2 && RunArtifactManager.instance.IsArtifactEnabled(rivalArtifact) && Object.op_Implicit((Object)(object)customMonsterInventory))
				{
					self.inventory.AddItemsFrom(customMonsterInventory);
				}
			};
			ChestBehavior.ItemDrop += (hook_ItemDrop)delegate(orig_ItemDrop orig, ChestBehavior self)
			{
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0049: Invalid comparison between Unknown and I4
				//IL_004c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: Invalid comparison between Unknown and I4
				//IL_0092: Unknown result type (might be due to invalid IL or missing references)
				//IL_0097: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00be: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00da: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
				//IL_0106: Unknown result type (might be due to invalid IL or missing references)
				//IL_0116: Unknown result type (might be due to invalid IL or missing references)
				//IL_011d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0129: Unknown result type (might be due to invalid IL or missing references)
				//IL_012f: Invalid comparison between Unknown and I4
				//IL_0146: Unknown result type (might be due to invalid IL or missing references)
				//IL_014c: Invalid comparison between Unknown and I4
				//IL_0163: Unknown result type (might be due to invalid IL or missing references)
				//IL_0169: Invalid comparison between Unknown and I4
				//IL_0180: Unknown result type (might be due to invalid IL or missing references)
				//IL_0186: Invalid comparison between Unknown and I4
				//IL_0258: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
				if (NetworkServer.active && RunArtifactManager.instance.IsArtifactEnabled(rivalArtifact))
				{
					PickupIndex dropPickup = self.dropPickup;
					if (((PickupIndex)(ref dropPickup)).isValid)
					{
						PickupDef pickupDef = PickupCatalog.GetPickupDef(dropPickup);
						if (pickupDef != null && (int)pickupDef.itemIndex != -1 && (int)pickupDef.itemTier != 3)
						{
							Transform val = (Object.op_Implicit((Object)(object)self.dropTransform) ? self.dropTransform : ((Component)self).transform);
							Vector3 val2 = val.position + Vector3.up * 1.5f;
							Vector3 velocity = Vector3.up * 20f + val.forward * 2f;
							GameObject val3 = Object.Instantiate<GameObject>(potentialPrefab, val2, Quaternion.identity);
							PickupPickerController component = val3.GetComponent<PickupPickerController>();
							List<Option> options = new List<Option>();
							List<Option> list = options;
							Option item = new Option
							{
								available = true
							};
							((Option)(ref item)).pickupIndex = dropPickup;
							list.Add(item);
							List<PickupIndex> list2 = null;
							if ((int)pickupDef.itemTier == 0)
							{
								list2 = Run.instance.availableTier1DropList;
							}
							else if ((int)pickupDef.itemTier == 1)
							{
								list2 = Run.instance.availableTier2DropList;
							}
							else if ((int)pickupDef.itemTier == 2)
							{
								list2 = Run.instance.availableTier3DropList;
							}
							else if ((int)pickupDef.itemTier == 4)
							{
								list2 = Run.instance.availableBossDropList;
							}
							if (list2 != null && list2.Count > 0)
							{
								for (int i = 0; i < 2; i++)
								{
									PickupIndex pickupIndex = list2[Random.Range(0, list2.Count)];
									List<Option> list3 = options;
									item = new Option
									{
										available = true
									};
									((Option)(ref item)).pickupIndex = pickupIndex;
									list3.Add(item);
								}
							}
							component.SetOptionsServer(options.ToArray());
							((UnityEvent<int>)(object)component.onPickupSelected).AddListener((UnityAction<int>)delegate(int selectedIndex)
							{
								//IL_0032: Unknown result type (might be due to invalid IL or missing references)
								//IL_0037: Unknown result type (might be due to invalid IL or missing references)
								//IL_003b: Unknown result type (might be due to invalid IL or missing references)
								//IL_0049: Unknown result type (might be due to invalid IL or missing references)
								//IL_004e: Unknown result type (might be due to invalid IL or missing references)
								//IL_012a: Unknown result type (might be due to invalid IL or missing references)
								//IL_0131: Expected O, but got Unknown
								//IL_0084: Unknown result type (might be due to invalid IL or missing references)
								//IL_00db: Unknown result type (might be due to invalid IL or missing references)
								if (NetworkServer.active)
								{
									List<string> list4 = new List<string>();
									for (int j = 0; j < options.Count; j++)
									{
										if (j != selectedIndex)
										{
											Option val4 = options[j];
											PickupDef pickupDef2 = PickupCatalog.GetPickupDef(((Option)(ref val4)).pickupIndex);
											ItemIndex itemIndex = pickupDef2.itemIndex;
											list4.Add(Language.GetString(pickupDef2.nameToken));
											if (Object.op_Implicit((Object)(object)customMonsterInventory))
											{
												customMonsterInventory.GiveItemPermanent(itemIndex, 1);
											}
											foreach (TeamComponent teamMember in TeamComponent.GetTeamMembers((TeamIndex)2))
											{
												if (Object.op_Implicit((Object)(object)teamMember.body) && Object.op_Implicit((Object)(object)teamMember.body.inventory))
												{
													teamMember.body.inventory.GiveItemPermanent(itemIndex, 1);
												}
											}
										}
									}
									if (list4.Count == 2)
									{
										SimpleChatMessage val5 = new SimpleChatMessage();
										val5.baseToken = "<color=#e57373>The monsters have acquired: " + list4[0] + " and " + list4[1] + "!</color>";
										Chat.SendBroadcastChat((ChatMessageBase)(object)val5);
									}
								}
							});
							NetworkServer.Spawn(val3);
							Rigidbody component2 = val3.GetComponent<Rigidbody>();
							if (Object.op_Implicit((Object)(object)component2))
							{
								component2.velocity = velocity;
							}
							return;
						}
					}
				}
				orig.Invoke(self);
			};
		}

		private void ApplyLocksmithHooks()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			object obj = <>c.<>9__16_0;
			if (obj == null)
			{
				hook_RollItem val = delegate(orig_RollItem orig, ChestBehavior self)
				{
					if (RunArtifactManager.instance.IsArtifactEnabled(locksmithArtifact) && ((Object)((Component)self).gameObject).name.Contains("RustyChest"))
					{
						int num = 0;
						foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
						{
							if (Object.op_Implicit((Object)(object)instance.master.inventory))
							{
								int itemCountPermanent = instance.master.inventory.GetItemCountPermanent(Items.TreasureCache);
								if (itemCountPermanent > num)
								{
									num = itemCountPermanent;
								}
							}
						}
						if (num > 0)
						{
							self.tier1Chance = 80f;
							self.tier2Chance = 20f * (float)num;
							self.tier3Chance = 1f * (float)(num * num);
						}
					}
					orig.Invoke(self);
				};
				<>c.<>9__16_0 = val;
				obj = (object)val;
			}
			ChestBehavior.RollItem += (hook_RollItem)obj;
			object obj2 = <>c.<>9__16_1;
			if (obj2 == null)
			{
				hook_OnInteractionBegin val2 = delegate(orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor interactor)
				{
					//IL_0017: Unknown result type (might be due to invalid IL or missing references)
					//IL_001e: Invalid comparison between Unknown and I4
					int num = 0;
					Inventory val3 = null;
					if (RunArtifactManager.instance.IsArtifactEnabled(locksmithArtifact) && (int)self.costType == 12)
					{
						CharacterBody component = ((Component)interactor).GetComponent<CharacterBody>();
						if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.inventory))
						{
							val3 = component.inventory;
							num = val3.GetItemCountPermanent(Items.TreasureCache);
						}
					}
					orig.Invoke(self, interactor);
					if ((Object)(object)val3 != (Object)null && num > 0)
					{
						int itemCountPermanent = val3.GetItemCountPermanent(Items.TreasureCache);
						if (itemCountPermanent < num)
						{
							val3.GiveItemPermanent(Items.TreasureCache, num - itemCountPermanent);
						}
					}
				};
				<>c.<>9__16_1 = val2;
				obj2 = (object)val2;
			}
			PurchaseInteraction.OnInteractionBegin += (hook_OnInteractionBegin)obj2;
		}
	}
	public class CapitalismVisuals : MonoBehaviour
	{
		private HoldoutZoneController zone;

		private Dictionary<CharacterBody, LineRenderer> tethers = new Dictionary<CharacterBody, LineRenderer>();

		private Material tetherMat;

		private void Awake()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			zone = ((Component)this).GetComponent<HoldoutZoneController>();
			tetherMat = Addressables.LoadAssetAsync<Material>((object)"RoR2/Base/Common/VFX/matGlow1.mat").WaitForCompletion();
		}

		private void Update()
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Expected O, but got Unknown
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			if (!RunArtifactManager.instance.IsArtifactEnabled(ArcrinesArtifactsPlugin.capitalismArtifact))
			{
				return;
			}
			uint num = (uint)Mathf.Max(1f, 15f * Run.instance.difficultyCoefficient);
			foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
			{
				CharacterBody body = instance.master.GetBody();
				if (!Object.op_Implicit((Object)(object)body))
				{
					continue;
				}
				float num2 = Vector3.Distance(body.corePosition, ((Component)zone).transform.position);
				if (num2 <= zone.currentRadius && instance.master.money >= num)
				{
					if (!tethers.ContainsKey(body))
					{
						GameObject val = new GameObject("CapitalismTether");
						val.transform.SetParent(((Component)zone).transform);
						LineRenderer val2 = val.AddComponent<LineRenderer>();
						((Renderer)val2).material = tetherMat;
						val2.startColor = new Color(1f, 0.8f, 0.1f, 1f);
						val2.endColor = new Color(1f, 0.5f, 0f, 0.8f);
						val2.startWidth = 0.4f;
						val2.endWidth = 0.1f;
						val2.positionCount = 2;
						tethers[body] = val2;
					}
					LineRenderer val3 = tethers[body];
					((Renderer)val3).enabled = true;
					val3.SetPosition(0, body.corePosition);
					val3.SetPosition(1, ((Component)zone).transform.position + Vector3.up * 1.5f);
				}
				else if (tethers.ContainsKey(body))
				{
					((Renderer)tethers[body]).enabled = false;
				}
			}
			List<CharacterBody> list = new List<CharacterBody>();
			foreach (KeyValuePair<CharacterBody, LineRenderer> tether in tethers)
			{
				if ((Object)(object)tether.Key == (Object)null)
				{
					Object.Destroy((Object)(object)((Component)tether.Value).gameObject);
					list.Add(tether.Key);
				}
			}
			foreach (CharacterBody item in list)
			{
				tethers.Remove(item);
			}
		}
	}
}