Decompiled source of GoopUpgrades Updated Temp v1.0.3

GoopUpgrades.dll

Decompiled 2 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib;
using REPOLib.Modules;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("GoopUpgrades")]
[assembly: AssemblyProduct("GoopUpgrades")]
[assembly: AssemblyCopyright("Copyright © GoopSwagger 2025")]
[assembly: ComVisible(false)]
[assembly: Guid("809fa50d-9398-446b-86a3-eaa45523ae0b")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.0")]
[module: UnverifiableCode]
[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 UnityEngine
{
	public class AssetBundle : Object
	{
		public static AssetBundle LoadFromFile(string path)
		{
			return null;
		}

		public T LoadAsset<T>(string name) where T : Object
		{
			return default(T);
		}

		public static AssetBundleCreateRequest LoadFromFileAsync(string path)
		{
			return null;
		}

		public string[] GetAllAssetNames()
		{
			return Array.Empty<string>();
		}
	}
	public class AssetBundleCreateRequest : AsyncOperation
	{
		public AssetBundle assetBundle => null;
	}
	public class AssetBundleRequest : AsyncOperation
	{
		public Object[] allAssets => Array.Empty<Object>();
	}
	public class AudioSource : Behaviour
	{
	}
	public class AudioClip : Object
	{
	}
	[StructLayout(LayoutKind.Sequential, Size = 1)]
	public struct MinMaxGradient
	{
		public static MinMaxGradient op_Implicit(Gradient g)
		{
			return default(MinMaxGradient);
		}
	}
	public struct ColorOverLifetimeModule
	{
		public MinMaxGradient color { get; set; }
	}
	public class ParticleSystem : Component
	{
		public ColorOverLifetimeModule colorOverLifetime { get; }

		public void Play()
		{
		}
	}
}
namespace TMPro
{
	public class TMP_Text : MonoBehaviour
	{
		public string text { get; set; }

		public FontStyles fontStyle { get; set; }

		public TextAlignmentOptions alignment { get; set; }
	}
	public class TextMeshProUGUI : TMP_Text
	{
	}
	public enum FontStyles
	{
		Normal,
		Bold,
		Italic
	}
	public enum TextAlignmentOptions
	{
		Left = 257,
		Center = 514,
		Right = 1025
	}
}
namespace GoopUpgrades
{
	internal static class Fields
	{
		public static readonly FieldInfo PH_invincibleTimer = AccessTools.Field(typeof(PlayerHealth), "invincibleTimer");

		public static readonly FieldInfo PH_playerAvatar = AccessTools.Field(typeof(PlayerHealth), "playerAvatar");

		public static readonly FieldInfo PH_godMode = AccessTools.Field(typeof(PlayerHealth), "godMode");

		public static readonly FieldInfo PH_health = AccessTools.Field(typeof(PlayerHealth), "health");

		public static readonly FieldInfo PH_photonView = AccessTools.Field(typeof(PlayerHealth), "photonView");

		public static readonly FieldInfo PH_hurtFreeze = AccessTools.Field(typeof(PlayerHealth), "hurtFreeze");

		public static readonly FieldInfo PH_materialEffect = AccessTools.Field(typeof(PlayerHealth), "materialEffect");

		public static readonly FieldInfo PH_materialEffectLerp = AccessTools.Field(typeof(PlayerHealth), "materialEffectLerp");

		public static readonly FieldInfo PH_instancedMaterials = AccessTools.Field(typeof(PlayerHealth), "instancedMaterials");

		public static readonly FieldInfo PH_eyeMaterial = AccessTools.Field(typeof(PlayerHealth), "eyeMaterial");

		public static readonly FieldInfo PH_pupilMaterial = AccessTools.Field(typeof(PlayerHealth), "pupilMaterial");

		public static readonly FieldInfo PH_materialHurtColor = AccessTools.Field(typeof(PlayerHealth), "materialHurtColor");

		public static readonly FieldInfo PA_isDisabled = AccessTools.Field(typeof(PlayerAvatar), "isDisabled");

		public static readonly FieldInfo PA_deadSet = AccessTools.Field(typeof(PlayerAvatar), "deadSet");

		public static readonly FieldInfo PC_playerSteamID = AccessTools.Field(typeof(PlayerController), "playerSteamID");

		public static readonly FieldInfo PPE_explosionSize = AccessTools.Field(typeof(ParticlePrefabExplosion), "explosionSize");

		public static readonly FieldInfo PPE_explosionDamage = AccessTools.Field(typeof(ParticlePrefabExplosion), "explosionDamage");

		public static readonly FieldInfo PPE_explosionDamageEnemy = AccessTools.Field(typeof(ParticlePrefabExplosion), "explosionDamageEnemy");

		public static readonly FieldInfo SemiUI_uiText = AccessTools.Field(typeof(SemiUI), "uiText");

		private static PropertyInfo _tmpTextProp;

		public static float GetFloat(FieldInfo fi, object obj)
		{
			return (float)fi.GetValue(obj);
		}

		public static int GetInt(FieldInfo fi, object obj)
		{
			return (int)fi.GetValue(obj);
		}

		public static bool GetBool(FieldInfo fi, object obj)
		{
			return (bool)fi.GetValue(obj);
		}

		public static T Get<T>(FieldInfo fi, object obj)
		{
			return (T)fi.GetValue(obj);
		}

		public static void Set(FieldInfo fi, object obj, object val)
		{
			fi.SetValue(obj, val);
		}

		public static string GetString(FieldInfo fi, object obj)
		{
			return (string)fi.GetValue(obj);
		}

		public static void SetTMPText(object tmpTextObj, string value)
		{
			if (tmpTextObj != null)
			{
				if (_tmpTextProp == null)
				{
					_tmpTextProp = tmpTextObj.GetType().GetProperty("text");
				}
				_tmpTextProp?.SetValue(tmpTextObj, value);
			}
		}
	}
	internal static class CameraGlitchHelper
	{
		private static readonly MethodInfo _playLongHurt = AccessTools.Method(typeof(CameraGlitch), "PlayLongHurt", (Type[])null, (Type[])null);

		private static readonly MethodInfo _playShortHurt = AccessTools.Method(typeof(CameraGlitch), "PlayShortHurt", (Type[])null, (Type[])null);

		public static void PlayLongHurt()
		{
			_playLongHurt?.Invoke(CameraGlitch.Instance, new object[1] { false });
		}

		public static void PlayShortHurt()
		{
			_playShortHurt?.Invoke(CameraGlitch.Instance, new object[1] { false });
		}
	}
	[BepInPlugin("GoopSwagger.GoopUpgrades", "GoopUpgrades", "1.0.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class GoopUpgradesPlugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(Upgrades), "RegisterUpgrades")]
		public static class Patch_Upgrades_RegisterUpgrades
		{
			[HarmonyPostfix]
			private static void Postfix()
			{
				try
				{
					FixUpgradeDisplayNames();
				}
				catch
				{
				}
			}
		}

		[HarmonyPatch(typeof(PlayerTumble))]
		public static class Patch_PlayerTumble
		{
			[HarmonyPatch("HitEnemy")]
			[HarmonyPostfix]
			private static void HitEnemyPostfix(PlayerTumble __instance)
			{
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0076: Unknown result type (might be due to invalid IL or missing references)
				if (!SemiFunc.IsMasterClientOrSingleplayer() || instance.upgradeTumbleBlast == null)
				{
					return;
				}
				string text = SemiFunc.PlayerGetSteamID(__instance.playerAvatar);
				int level = instance.upgradeTumbleBlast.GetLevel(text);
				if (level > 0)
				{
					Vector3 position = ((Component)__instance.playerAvatar).transform.position;
					TumbleBlastExplosion(level, position);
					if (GameManager.Multiplayer())
					{
						tumbleBlastExplosionEvent.RaiseEvent((object)new object[2] { level, position }, NetworkingEvents.RaiseOthers, SendOptions.SendReliable);
					}
				}
			}
		}

		[HarmonyPatch(typeof(SemiFunc))]
		public static class Patch_SemiFunc
		{
			[HarmonyPatch("UIHideHealth")]
			[HarmonyPostfix]
			private static void UIHideHealthPostfix()
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Expected O, but got Unknown
				if ((Object)ShieldUI.instance != (Object)null)
				{
					((SemiUI)ShieldUI.instance).Hide();
				}
			}
		}

		[HarmonyPatch(typeof(PlayerHealth))]
		public static class Patch_PlayerHealth
		{
			[HarmonyPatch("Awake")]
			[HarmonyPostfix]
			public static void AwakePostfix(PlayerHealth __instance)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Expected O, but got Unknown
				if ((Object)((Component)__instance).GetComponent<PlayerShield>() == (Object)null)
				{
					((Component)__instance).gameObject.AddComponent<PlayerShield>();
				}
			}

			[HarmonyPatch("Start")]
			[HarmonyPostfix]
			public static void StartPostfix(PlayerHealth __instance)
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Expected O, but got Unknown
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Expected O, but got Unknown
				PlayerShield component = ((Component)__instance).GetComponent<PlayerShield>();
				try
				{
					PlayerAvatar val = Fields.Get<PlayerAvatar>(Fields.PH_playerAvatar, __instance);
					if (!((Object)component != (Object)null) || instance.upgradeShield == null || !((Object)val != (Object)null))
					{
						return;
					}
					int num = (component.shieldMax = (component.shieldValue = 10 * instance.upgradeShield.GetLevel(SemiFunc.PlayerGetSteamID(val))));
					if (GameManager.Multiplayer())
					{
						PhotonView obj = Fields.Get<PhotonView>(Fields.PH_photonView, __instance);
						if (obj != null)
						{
							obj.RPC("UpdateShieldRPC", (RpcTarget)1, new object[3] { num, num, false });
						}
					}
				}
				catch (NullReferenceException)
				{
				}
			}

			[HarmonyPatch("Hurt")]
			[HarmonyPrefix]
			private static void HurtPrefix(PlayerHealth __instance, ref int damage, bool savingGrace, int enemyIndex = -1, bool hurtByHeal = false)
			{
				if (damage <= 0 || hurtByHeal)
				{
					return;
				}
				PlayerShield component = ((Component)__instance).GetComponent<PlayerShield>();
				if (!((Object)(object)component == (Object)null))
				{
					component.regenerationTimer = 15f;
					if (component.shieldValue > 0)
					{
						damage = component.DamageShield(__instance, damage);
					}
				}
			}

			[HarmonyPatch("HurtOther")]
			[HarmonyPrefix]
			private static void HurtOtherPrefix(PlayerHealth __instance, ref int damage, Vector3 hurtPosition, bool savingGrace, int enemyIndex = -1, bool hurtByHeal = false)
			{
				if (damage > 0)
				{
					((Component)__instance).GetComponent<PlayerShield>().regenerationTimer = 15f;
				}
			}
		}

		[HarmonyPatch(typeof(PlayerAvatar))]
		public static class Patch_PlayerAvatar
		{
			[HarmonyPatch("Revive")]
			[HarmonyPostfix]
			public static void RevivePostfix(PlayerAvatar __instance)
			{
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Expected O, but got Unknown
				PlayerShield component = ((Component)((Component)__instance).GetComponent<PlayerHealth>()).GetComponent<PlayerShield>();
				if (instance.upgradeShield != null && (Object)__instance != (Object)null)
				{
					component.regenerationTimer = 15f;
					component.shieldValue = 0;
				}
			}
		}

		[HarmonyPatch(typeof(EnergyUI))]
		public static class Patch_EnergyUI
		{
			private static bool offset;

			private static readonly MethodInfo _semiUIUpdate = AccessTools.Method(typeof(SemiUI), "Update", (Type[])null, (Type[])null);

			[HarmonyPatch("Start")]
			[HarmonyPostfix]
			private static void StartPostfix(EnergyUI __instance)
			{
				offset = false;
			}

			[HarmonyPatch("Update")]
			[HarmonyPostfix]
			private static void UpdatePostfix(EnergyUI __instance)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Expected O, but got Unknown
				//IL_0051: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0080: Unknown result type (might be due to invalid IL or missing references)
				//IL_0085: Unknown result type (might be due to invalid IL or missing references)
				//IL_008a: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c3: 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_00d7: 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)
				if ((Object)PlayerController.instance == (Object)null)
				{
					return;
				}
				string @string = Fields.GetString(Fields.PC_playerSteamID, PlayerController.instance);
				if (@string != null && instance.upgradeShield != null)
				{
					int level = instance.upgradeShield.GetLevel(@string);
					if (level > 0 && !offset)
					{
						((SemiUI)__instance).showPosition = ((SemiUI)__instance).showPosition + new Vector2(0f, -31f);
						((SemiUI)__instance).hidePosition = ((SemiUI)__instance).hidePosition + new Vector2(0f, -31f);
						offset = true;
					}
					else if (level <= 0 && offset)
					{
						((SemiUI)__instance).showPosition = ((SemiUI)__instance).showPosition - new Vector2(0f, -31f);
						((SemiUI)__instance).hidePosition = ((SemiUI)__instance).hidePosition - new Vector2(0f, -31f);
						offset = false;
					}
				}
			}
		}

		[HarmonyPatch(typeof(OverchargeUI))]
		public static class Patch_OverchargeUI
		{
			private static bool offset;

			[HarmonyPatch("Start")]
			[HarmonyPostfix]
			private static void StartPostfix(OverchargeUI __instance)
			{
				offset = false;
			}

			[HarmonyPatch("Update")]
			[HarmonyPostfix]
			private static void UpdatePostfix(OverchargeUI __instance)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Expected O, but got Unknown
				//IL_0051: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0080: Unknown result type (might be due to invalid IL or missing references)
				//IL_0085: Unknown result type (might be due to invalid IL or missing references)
				//IL_008a: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c3: 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_00d7: 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)
				if ((Object)PlayerController.instance == (Object)null)
				{
					return;
				}
				string @string = Fields.GetString(Fields.PC_playerSteamID, PlayerController.instance);
				if (@string != null && instance.upgradeShield != null)
				{
					int level = instance.upgradeShield.GetLevel(@string);
					if (level > 0 && !offset)
					{
						((SemiUI)__instance).showPosition = ((SemiUI)__instance).showPosition + new Vector2(0f, -31f);
						((SemiUI)__instance).hidePosition = ((SemiUI)__instance).hidePosition + new Vector2(0f, -31f);
						offset = true;
					}
					else if (level <= 0 && offset)
					{
						((SemiUI)__instance).showPosition = ((SemiUI)__instance).showPosition - new Vector2(0f, -31f);
						((SemiUI)__instance).hidePosition = ((SemiUI)__instance).hidePosition - new Vector2(0f, -31f);
						offset = false;
					}
				}
			}
		}

		public static GoopUpgradesPlugin instance;

		public const string PluginGUID = "GoopSwagger.GoopUpgrades";

		public const string PluginVersion = "1.0.2";

		public const float SHIELD_CHARGE_DELAY = 15f;

		public const int SHIELD_PER_UPGRADE = 10;

		public static bool ignoreShield;

		public PlayerUpgrade upgradeTumbleBlast;

		public PlayerUpgrade upgradeShield;

		private object assetBundle;

		private MethodInfo _loadAssetMethod;

		public static NetworkedEvent tumbleBlastExplosionEvent;

		private T BundleLoad<T>(string name) where T : Object
		{
			if (assetBundle == null || _loadAssetMethod == null)
			{
				return default(T);
			}
			object? obj = _loadAssetMethod.MakeGenericMethod(typeof(T)).Invoke(assetBundle, new object[1] { name });
			return (T)((obj is T) ? obj : null);
		}

		internal static void FixUpgradeDisplayNames()
		{
			if (StatsManager.instance?.upgradesInfo == null)
			{
				return;
			}
			Dictionary<string, string> dictionary = new Dictionary<string, string>
			{
				{ "playerUpgradeShield", "Shield" },
				{ "playerUpgradeTumbleBlast", "Tumble Blast" }
			};
			Type type = typeof(StatsManager).Assembly.GetType("UpgradeInfo") ?? AppDomain.CurrentDomain.GetAssemblies().SelectMany(delegate(Assembly a)
			{
				try
				{
					return a.GetTypes();
				}
				catch
				{
					return Array.Empty<Type>();
				}
			}).FirstOrDefault((Type t) => t.Name == "UpgradeInfo");
			if (type == null)
			{
				return;
			}
			FieldInfo field = type.GetField("displayName");
			if (field == null)
			{
				return;
			}
			foreach (KeyValuePair<string, string> item in dictionary)
			{
				object obj = Activator.CreateInstance(type);
				field.SetValue(obj, item.Value);
				StatsManager.instance.upgradesInfo.GetType().GetMethod("set_Item")?.Invoke(StatsManager.instance.upgradesInfo, new object[2] { item.Key, obj });
			}
		}

		private void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Expected O, but got Unknown
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Expected O, but got Unknown
			if ((Object)instance == (Object)null)
			{
				instance = this;
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"GoopUpgrades v1.0.2 loading...");
			new Harmony("GoopSwagger.GoopUpgrades").PatchAll();
			string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "goopupgrades");
			string text2 = "Upgrades";
			ConfigEntry<bool> enableTumbleBlast = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition(text2, "Enable Tumble Blast"), true, (ConfigDescription)null);
			ConfigEntry<bool> enableShield = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition(text2, "Enable Shield"), true, (ConfigDescription)null);
			Action<object> action = delegate(object bundleObj)
			{
				object bundleObj2 = bundleObj;
				MethodInfo loadAssetGeneric = null;
				MethodInfo[] methods2 = bundleObj2.GetType().GetMethods();
				foreach (MethodInfo methodInfo3 in methods2)
				{
					if (methodInfo3.Name == "LoadAsset" && methodInfo3.IsGenericMethodDefinition)
					{
						ParameterInfo[] parameters2 = methodInfo3.GetParameters();
						if (parameters2.Length == 1 && parameters2[0].ParameterType == typeof(string))
						{
							loadAssetGeneric = methodInfo3;
							break;
						}
					}
				}
				instance.assetBundle = bundleObj2;
				methods2 = bundleObj2.GetType().GetMethods();
				foreach (MethodInfo methodInfo4 in methods2)
				{
					if (methodInfo4.Name == "LoadAsset" && methodInfo4.IsGenericMethodDefinition)
					{
						ParameterInfo[] parameters3 = methodInfo4.GetParameters();
						if (parameters3.Length == 1 && parameters3[0].ParameterType == typeof(string))
						{
							instance._loadAssetMethod = methodInfo4;
							break;
						}
					}
				}
				if (enableTumbleBlast.Value)
				{
					GameObject upgradeItem = LoadAsset<GameObject>("Item Upgrade Player Tumble Blast");
					upgradeTumbleBlast = RegisterUpgrade(upgradeItem, "Tumble Blast", "TumbleBlast", 2, null);
				}
				if (enableShield.Value)
				{
					GameObject upgradeItem2 = LoadAsset<GameObject>("Item Upgrade Player Shield");
					upgradeShield = RegisterUpgrade(upgradeItem2, "Shield", "Shield", 1, delegate(PlayerAvatar player, int value)
					{
						//IL_003f: Unknown result type (might be due to invalid IL or missing references)
						//IL_004a: Expected O, but got Unknown
						AccessTools.Method(typeof(SemiUI), "Update", (Type[])null, (Type[])null)?.Invoke(EnergyUI.instance, null);
						if (SemiFunc.IsMasterClientOrSingleplayer())
						{
							PlayerShield component = ((Component)player.playerHealth).GetComponent<PlayerShield>();
							if ((Object)component != (Object)null)
							{
								int num = (component.shieldMax = 10 * value);
								component.shieldValue = Mathf.Min(component.shieldValue + 10, num);
								if (GameManager.Multiplayer())
								{
									PhotonView obj2 = Fields.Get<PhotonView>(Fields.PH_photonView, player.playerHealth);
									if (obj2 != null)
									{
										obj2.RPC("UpdateShieldRPC", (RpcTarget)1, new object[3] { component.shieldValue, component.shieldMax, false });
									}
								}
							}
						}
					});
				}
				T LoadAsset<T>(string name) where T : notnull, Object
				{
					object? obj = loadAssetGeneric?.MakeGenericMethod(typeof(T)).Invoke(bundleObj2, new object[1] { name });
					return (T)((obj is T) ? obj : null);
				}
			};
			MethodInfo methodInfo = null;
			MethodInfo[] methods = typeof(BundleLoader).GetMethods();
			foreach (MethodInfo methodInfo2 in methods)
			{
				if (methodInfo2.Name != "LoadBundle")
				{
					continue;
				}
				ParameterInfo[] parameters = methodInfo2.GetParameters();
				if (parameters.Length == 3 && !(parameters[0].ParameterType != typeof(string)) && !(parameters[2].ParameterType != typeof(bool)))
				{
					Type parameterType = parameters[1].ParameterType;
					if (parameterType.IsGenericType && parameterType.GetGenericTypeDefinition() == typeof(Action<>))
					{
						methodInfo = methodInfo2;
						break;
					}
				}
			}
			if (methodInfo != null)
			{
				Type parameterType2 = methodInfo.GetParameters()[1].ParameterType;
				_ = parameterType2.GetGenericArguments()[0];
				Delegate @delegate = Delegate.CreateDelegate(parameterType2, action.Target, action.Method);
				methodInfo.Invoke(null, new object[3] { text, @delegate, false });
				((BaseUnityPlugin)this).Logger.LogInfo((object)"BundleLoader.LoadBundle invoked successfully.");
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Could not find BundleLoader.LoadBundle(string, Action<AssetBundle>, bool)!");
			}
			SceneManager.sceneLoaded += OnSceneLoaded;
			tumbleBlastExplosionEvent = new NetworkedEvent("Tumble Blast Explosion", (Action<EventData>)HandleTumbleBlastExplosionEvent);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"GoopUpgrades v1.0.2 loaded.");
		}

		private static void HandleTumbleBlastExplosionEvent(EventData eventData)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			object[] obj = (object[])eventData.CustomData;
			int level = (int)obj[0];
			Vector3 position = (Vector3)obj[1];
			TumbleBlastExplosion(level, position);
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			InitializeShieldUI();
		}

		private void InitializeShieldUI()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			if (instance.assetBundle != null && !(instance._loadAssetMethod == null))
			{
				GameObject val = GameObject.Find("Game Hud") ?? GameObject.Find("HUD Canvas") ?? GameObject.Find("Game HUD");
				if ((Object)val != (Object)null && (Object)val.transform.Find("Shield") == (Object)null)
				{
					Object.Instantiate<GameObject>(instance.BundleLoad<GameObject>("Shield")).transform.SetParent(val.transform, false);
				}
			}
		}

		private static PlayerUpgrade RegisterUpgrade(GameObject upgradeItem, string upgradeName, string upgradeId, int maxAmountInShop, Action<PlayerAvatar, int> upgradeAction)
		{
			Item val = ScriptableObject.CreateInstance<Item>();
			AccessTools.Field(typeof(Item), "itemType").SetValue(val, 3);
			AccessTools.Field(typeof(Item), "emojiIcon").SetValue(val, 11);
			AccessTools.Field(typeof(Item), "itemVolume").SetValue(val, 6);
			string name = (((Object)val).name = "Item Upgrade Player " + upgradeName);
			val.itemName = upgradeName + " Upgrade";
			val.maxAmount = 10;
			val.maxAmountInShop = maxAmountInShop;
			val.maxPurchaseAmount = 0;
			val.maxPurchase = false;
			Value val2 = ScriptableObject.CreateInstance<Value>();
			val2.valueMin = 2250f;
			val2.valueMax = 3000f;
			val.value = val2;
			((Object)upgradeItem).name = name;
			ItemAttributes component = upgradeItem.GetComponent<ItemAttributes>();
			component.item = val;
			REPOLibItemUpgrade component2 = upgradeItem.GetComponent<REPOLibItemUpgrade>();
			AccessTools.Field(typeof(REPOLibItemUpgrade), "_upgradeId").SetValue(component2, upgradeId);
			Items.RegisterItem(component);
			return Upgrades.RegisterUpgrade(upgradeId, val, (Action<PlayerAvatar, int>)null, upgradeAction);
		}

		private static void TumbleBlastExplosion(int level, Vector3 position)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			ExplosionPreset obj = instance.BundleLoad<ExplosionPreset>("Tumble Blast Preset");
			GameObject obj2 = Resources.Load<GameObject>("Effects/Part Prefab Explosion");
			float num = 1.2f + (float)(level - 1) * 0.2f;
			ParticlePrefabExplosion component = Object.Instantiate<GameObject>(obj2, position, Quaternion.identity).GetComponent<ParticlePrefabExplosion>();
			component.forceMultiplier = 5f;
			Fields.Set(Fields.PPE_explosionSize, component, (num > 1.8f) ? 1.8f : num);
			Fields.Set(Fields.PPE_explosionDamage, component, 20 + (level - 1) * 15);
			Fields.Set(Fields.PPE_explosionDamageEnemy, component, 40 + (level - 1) * 15);
			component.lightColorOverTime = new Gradient();
			component.particleFire.Play();
			component.particleSmoke.Play();
			((Behaviour)component.light).enabled = true;
			obj.explosionSoundSmall.Play(position, 1f, 1f, 1f, 1f);
		}
	}
	public class PlayerShield : MonoBehaviour, IPunObservable
	{
		private PhotonView photonView;

		public int shieldValue;

		public int shieldMax;

		public float regenerationTimer;

		private PlayerHealth playerHealth => ((Component)this).GetComponentInParent<PlayerHealth>();

		public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
		{
			throw new NotImplementedException();
		}

		private void Awake()
		{
			photonView = ((Component)this).GetComponentInParent<PhotonView>();
		}

		private void Update()
		{
			if (SemiFunc.IsMasterClientOrSingleplayer() && !(regenerationTimer <= 0f))
			{
				regenerationTimer -= Time.deltaTime;
				while (regenerationTimer <= 0f && shieldValue < shieldMax)
				{
					regenerationTimer += 1.2f;
					shieldValue++;
				}
				if (GameManager.Multiplayer())
				{
					photonView.RPC("UpdateShieldRPC", (RpcTarget)1, new object[3] { shieldValue, shieldMax, false });
				}
			}
		}

		public int DamageShield(PlayerHealth playerHealth, int damage)
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Invalid comparison between Unknown and I4
			float @float = Fields.GetFloat(Fields.PH_invincibleTimer, playerHealth);
			PlayerAvatar val = Fields.Get<PlayerAvatar>(Fields.PH_playerAvatar, playerHealth);
			bool @bool = Fields.GetBool(Fields.PH_godMode, playerHealth);
			bool flag = (Object)(object)val != (Object)null && Fields.GetBool(Fields.PA_deadSet, val);
			if (@float > 0f || damage <= 0 || (GameManager.Multiplayer() && !photonView.IsMine) || flag || @bool || (int)GameDirector.instance.currentState != 2)
			{
				return damage;
			}
			regenerationTimer = 15f;
			int num = shieldValue - damage;
			if (num < 0)
			{
				shieldValue = 0;
				if (GameManager.Multiplayer())
				{
					photonView.RPC("UpdateShieldRPC", (RpcTarget)1, new object[3] { shieldValue, shieldMax, false });
				}
				return -num;
			}
			if (damage >= 25)
			{
				CameraGlitchHelper.PlayLongHurt();
			}
			else
			{
				CameraGlitchHelper.PlayShortHurt();
			}
			shieldValue = num;
			if (GameManager.Multiplayer())
			{
				photonView.RPC("UpdateShieldRPC", (RpcTarget)1, new object[3] { shieldValue, shieldMax, true });
			}
			return 0;
		}

		[PunRPC]
		public void UpdateShieldRPC(int shieldValue, int shieldMax, bool effect, PhotonMessageInfo _info = default(PhotonMessageInfo))
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: 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)
			//IL_0157: Expected O, but got Unknown
			//IL_0157: Expected O, but got Unknown
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Expected O, but got Unknown
			//IL_016b: Expected O, but got Unknown
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.MasterAndOwnerOnlyRPC(_info, photonView))
			{
				return;
			}
			if (effect)
			{
				Fields.Set(Fields.PH_materialEffect, playerHealth, true);
				PlayerAvatar val = Fields.Get<PlayerAvatar>(Fields.PH_playerAvatar, playerHealth);
				if (!((Object)(object)val != (Object)null) || !Fields.GetBool(Fields.PA_deadSet, val))
				{
					Fields.Set(Fields.PH_materialEffectLerp, playerHealth, 0f);
				}
				if (shieldValue < this.shieldValue)
				{
					if (shieldValue > 0)
					{
						playerHealth.hurtOther.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
					}
					Fields.Set(Fields.PH_hurtFreeze, playerHealth, true);
					List<Material> list = Fields.PH_instancedMaterials?.GetValue(playerHealth) as List<Material>;
					object? obj = Fields.PH_eyeMaterial?.GetValue(playerHealth);
					Material val2 = (Material)((obj is Material) ? obj : null);
					object? obj2 = Fields.PH_pupilMaterial?.GetValue(playerHealth);
					Material val3 = (Material)((obj2 is Material) ? obj2 : null);
					int @int = Fields.GetInt(Fields.PH_materialHurtColor, playerHealth);
					if (list != null)
					{
						foreach (Material item in list)
						{
							if ((Object)item != (Object)val2 && (Object)item != (Object)val3)
							{
								item.SetColor(@int, new Color(0.25f, 0.5f, 1f));
							}
						}
					}
				}
			}
			if (shieldValue < this.shieldValue)
			{
				regenerationTimer = 15f;
			}
			this.shieldValue = shieldValue;
			this.shieldMax = shieldMax;
		}
	}
	public class ShieldUI : SemiUI
	{
		public static ShieldUI instance;

		private Component _shieldMaxTMP;

		public Vector3 maxEnergyBasePosition;

		public float maxEnergyPrevOffset;

		public int shieldValue;

		public int shieldPrev;

		protected override void Start()
		{
			//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)
			try
			{
				((SemiUI)this).Start();
			}
			catch
			{
			}
			instance = this;
			Transform val = ((Component)this).transform.Find("ShieldMax");
			if (!((Object)(object)val != (Object)null))
			{
				return;
			}
			Component[] components = ((Component)val).GetComponents<Component>();
			foreach (Component val2 in components)
			{
				if ((Object)(object)val2 != (Object)null && ((object)val2).GetType().Name == "TextMeshProUGUI")
				{
					_shieldMaxTMP = val2;
					object? obj2 = ((object)val2).GetType().GetProperty("transform")?.GetValue(val2);
					Transform val3 = (Transform)((obj2 is Transform) ? obj2 : null);
					if ((Object)(object)val3 != (Object)null)
					{
						maxEnergyBasePosition = val3.localPosition;
					}
					break;
				}
			}
		}

		protected override void Update()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected O, but got Unknown
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: 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_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)PlayerAvatar.instance == (Object)null)
			{
				((SemiUI)this).Hide();
				return;
			}
			try
			{
				((SemiUI)this).Update();
			}
			catch
			{
			}
			if (!(Fields.PA_isDisabled != null) || !Fields.GetBool(Fields.PA_isDisabled, PlayerAvatar.instance))
			{
				if (GoopUpgradesPlugin.instance.upgradeShield == null || SemiFunc.PlayerGetSteamID(PlayerAvatar.instance) == null || GoopUpgradesPlugin.instance.upgradeShield.GetLevel(SemiFunc.PlayerGetSteamID(PlayerAvatar.instance)) == 0)
				{
					((SemiUI)this).Hide();
				}
			}
			else
			{
				((SemiUI)this).Hide();
			}
			if (base.isHidden)
			{
				return;
			}
			try
			{
				if ((Object)PlayerAvatar.instance.playerHealth == (Object)null)
				{
					return;
				}
				PlayerShield component = ((Component)PlayerAvatar.instance.playerHealth).GetComponent<PlayerShield>();
				if (!((Object)(object)component == (Object)null))
				{
					shieldValue = component.shieldValue;
					if (shieldValue != shieldPrev)
					{
						((SemiUI)this).SemiUISpringShakeY(4f, 5f, 0.25f);
						Color val = ((shieldValue < shieldPrev) ? Color.red : Color.white);
						((SemiUI)this).SemiUITextFlashColor(val, 0.2f);
						((SemiUI)this).SemiUISpringScale(0.3f, 5f, 0.125f);
						shieldPrev = shieldValue;
					}
					object? tmpTextObj = Fields.SemiUI_uiText?.GetValue(this);
					string text = component.shieldValue.ToString();
					Fields.SetTMPText(tmpTextObj, text);
					float num = ((text.Length > 3) ? ((float)(text.Length - 3) * 20f) : 0f);
					if ((Object)(object)_shieldMaxTMP != (Object)null)
					{
						_shieldMaxTMP.transform.localPosition = maxEnergyBasePosition + new Vector3(num, 0f, 0f);
						Fields.SetTMPText(_shieldMaxTMP, "<b><color=blue>/</color></b>" + component.shieldMax);
					}
				}
			}
			catch
			{
			}
		}
	}
}