Decompiled source of GoopUpgrades v1.2.1

GoopUpgrades.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
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 TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("GoopUpgrades")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GoopUpgrades")]
[assembly: AssemblyCopyright("Copyright © GoopSwagger 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("809fa50d-9398-446b-86a3-eaa45523ae0b")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[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.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;
		}
	}
	[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 GoopUpgrades
{
	[BepInPlugin("GoopSwagger.GoopUpgrades", "GoopUpgrades", "1.2.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class GoopUpgradesPlugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(PlayerTumble))]
		public static class Patch_PlayerTumble
		{
			[HarmonyPatch("HitEnemy")]
			[HarmonyPostfix]
			private static void HitEnemyPostfix(PlayerTumble __instance)
			{
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				//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)
				if (!SemiFunc.IsMasterClientOrSingleplayer() || instance.upgradeTumbleBlast == null)
				{
					return;
				}
				int level = instance.upgradeTumbleBlast.GetLevel(SemiFunc.PlayerGetSteamID(__instance.playerAvatar));
				if (level > 0)
				{
					TumbleBlastExplosion(level, ((Component)__instance.playerAvatar).transform.position);
					if (GameManager.Multiplayer())
					{
						tumbleBlastExplosionEvent.RaiseEvent((object)new object[2]
						{
							level,
							((Component)__instance.playerAvatar).transform.position
						}, NetworkingEvents.RaiseOthers, SendOptions.SendReliable);
					}
				}
			}
		}

		[HarmonyPatch(typeof(PlayerController))]
		public static class Patch_PlayerController
		{
			private static bool wasSliding;

			[HarmonyPatch("FixedUpdate")]
			[HarmonyPrefix]
			private static void FixedUpdatePrefix(PlayerController __instance)
			{
				if (!((Object)(object)__instance.playerAvatarScript == (Object)null) && instance.upgradeSlide != null)
				{
					float num = instance.upgradeSlide.GetLevel(SemiFunc.PlayerGetSteamID(__instance.playerAvatarScript));
					float num2 = 3f * num;
					if (num > 0f)
					{
						double num3 = Math.Cbrt((double)(num - 1f) / 5.0) * 0.45;
						__instance.SlideTime = 1f + (0.25f + (float)num3) * Math.Min(1f, __instance.EnergyCurrent / num2);
						__instance.SlideDecay = 0.0945f;
					}
					else
					{
						__instance.SlideTime = 1f;
					}
					wasSliding = __instance.Sliding;
				}
			}

			[HarmonyPatch("FixedUpdate")]
			[HarmonyPostfix]
			private static void FixedUpdatePostfix(PlayerController __instance)
			{
				//IL_0049: Unknown result type (might be due to invalid IL or missing references)
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_005f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_006e: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)__instance.playerAvatarScript == (Object)null || instance.upgradeSlide == null)
				{
					return;
				}
				int level = instance.upgradeSlide.GetLevel(SemiFunc.PlayerGetSteamID(__instance.playerAvatarScript));
				if (level > 0)
				{
					if (__instance.SlideTimer > 0f)
					{
						__instance.SlideDirectionCurrent = Vector3.Lerp(__instance.SlideDirectionCurrent, __instance.InputDirection * ((Vector3)(ref __instance.SlideDirectionCurrent)).magnitude, 0.15f);
					}
					if (wasSliding != __instance.Sliding && __instance.Sliding)
					{
						__instance.EnergyCurrent -= 3f * (float)level;
						__instance.EnergyCurrent = Mathf.Max(0f, __instance.EnergyCurrent);
					}
				}
			}
		}

		[HarmonyPatch(typeof(SemiFunc))]
		public static class Patch_SemiFunc
		{
			[HarmonyPatch("UIHideHealth")]
			[HarmonyPostfix]
			private static void UIHideHealthPostfix()
			{
				if ((Object)(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)
			{
				if ((Object)(object)((Component)__instance).GetComponent<PlayerShield>() == (Object)null)
				{
					((Component)__instance).gameObject.AddComponent<PlayerShield>();
				}
			}

			[HarmonyPatch("Start")]
			[HarmonyPostfix]
			public static void StartPostfix(PlayerHealth __instance)
			{
				PlayerShield component = ((Component)__instance).GetComponent<PlayerShield>();
				try
				{
					if ((Object)(object)component != (Object)null && instance.upgradeShield != null && (Object)(object)__instance.playerAvatar != (Object)null)
					{
						int num = (component.shieldMax = (component.shieldValue = 10 * instance.upgradeShield.GetLevel(SemiFunc.PlayerGetSteamID(__instance.playerAvatar))));
						if (GameManager.Multiplayer())
						{
							__instance.photonView.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)
			{
				if (damage > 0)
				{
					PlayerShield component = ((Component)__instance).GetComponent<PlayerShield>();
					component.regenerationTimer = 15f;
					if (savingGrace && component.shieldValue > 0 && __instance.health > 0)
					{
						damage = component.DamageShield(__instance, damage);
					}
				}
			}

			[HarmonyPatch("HurtOther")]
			[HarmonyPrefix]
			private static void HurtOtherPrefix(PlayerHealth __instance, ref int damage, bool savingGrace, int enemyIndex = -1)
			{
				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)
			{
				PlayerShield component = ((Component)((Component)__instance).GetComponent<PlayerHealth>()).GetComponent<PlayerShield>();
				if (instance.upgradeShield != null && (Object)(object)__instance != (Object)null)
				{
					component.regenerationTimer = 15f;
					component.shieldValue = 0;
				}
			}
		}

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

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

			[HarmonyPatch("Update")]
			[HarmonyPostfix]
			private static void UpdatePostfix(EnergyUI __instance)
			{
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_005c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0061: Unknown result type (might be due to invalid IL or missing references)
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_007c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0081: Unknown result type (might be due to invalid IL or missing references)
				//IL_0086: Unknown result type (might be due to invalid IL or missing references)
				//IL_009f: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)PlayerController.instance == (Object)null) && PlayerController.instance.playerSteamID != null && instance.upgradeShield != null)
				{
					int level = instance.upgradeShield.GetLevel(PlayerController.instance.playerSteamID);
					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_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_005c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0061: Unknown result type (might be due to invalid IL or missing references)
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_007c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0081: Unknown result type (might be due to invalid IL or missing references)
				//IL_0086: Unknown result type (might be due to invalid IL or missing references)
				//IL_009f: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)PlayerController.instance == (Object)null) && PlayerController.instance.playerSteamID != null && instance.upgradeShield != null)
				{
					int level = instance.upgradeShield.GetLevel(PlayerController.instance.playerSteamID);
					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 PluginName = "GoopUpgrades";

		public const string PluginAuthor = "GoopSwagger";

		public const string PluginVersion = "1.2.1";

		public const float SHIELD_CHARGE_DELAY = 15f;

		public const int SHIELD_PER_UPGRADE = 10;

		public static bool ignoreShield;

		public PlayerUpgrade upgradeTumbleBlast;

		public PlayerUpgrade upgradeShield;

		public PlayerUpgrade upgradeSlide;

		private AssetBundle assetBundle;

		public static NetworkedEvent tumbleBlastExplosionEvent;

		private void Awake()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"You've got yourself a winner here...");
			new Harmony("GoopSwagger.GoopUpgrades").PatchAll();
			BundleLoader.LoadBundle(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "goopupgrades"), (Action<AssetBundle>)delegate(AssetBundle assetBundle)
			{
				instance.assetBundle = assetBundle;
				upgradeTumbleBlast = Upgrade("Item Upgrade Player Tumble Blast", "Tumble Blast", "TumbleBlast", 2, 2250f, 3000f, null);
				upgradeShield = Upgrade("Item Upgrade Player Shield", "Shield", "Shield", 1, 2250f, 3000f, delegate(PlayerAvatar player, int value)
				{
					((SemiUI)EnergyUI.instance).Update();
					if (SemiFunc.IsMasterClientOrSingleplayer())
					{
						PlayerShield component = ((Component)player.playerHealth).GetComponent<PlayerShield>();
						if ((Object)(object)component != (Object)null)
						{
							component.shieldValue += 10;
							component.shieldMax += 10;
							if (GameManager.Multiplayer())
							{
								player.playerHealth.photonView.RPC("UpdateShieldRPC", (RpcTarget)1, new object[3] { component.shieldValue, component.shieldMax, false });
							}
						}
					}
				});
				upgradeSlide = Upgrade("Item Upgrade Player Slide", "Slide", "Slide", 2, 1200f, 2000f, null);
			}, false);
			SceneManager.sceneLoaded += OnSceneLoaded;
			tumbleBlastExplosionEvent = new NetworkedEvent("Tumble Blast Explosion", (Action<EventData>)HandleTumbleBlastExplosionEvent);
		}

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

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

		private void InitializeShieldUI()
		{
			if ((Object)(object)instance.assetBundle != (Object)null)
			{
				GameObject val = GameObject.Find("Game Hud");
				if ((Object)(object)val != (Object)null && (Object)(object)val.transform.Find("Shield") == (Object)null)
				{
					Object.Instantiate<GameObject>(instance.assetBundle.LoadAsset<GameObject>("Shield")).transform.SetParent(val.transform, false);
				}
			}
		}

		private static PlayerUpgrade Upgrade(string upgradeObject, string upgradeName, string upgradeId, int maxAmountInShop, float valueMin, float valueMax, Action<PlayerAvatar, int> upgradeAction)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Expected O, but got Unknown
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Expected O, but got Unknown
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Expected O, but got Unknown
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Expected O, but got Unknown
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Expected O, but got Unknown
			if (((BaseUnityPlugin)instance).Config.Bind<bool>(new ConfigDefinition(upgradeName, "Enable " + upgradeName), true, (ConfigDescription)null).Value)
			{
				Item val = ScriptableObject.CreateInstance<Item>();
				val.itemType = (itemType)3;
				val.emojiIcon = (emojiIcon)11;
				val.itemVolume = (itemVolume)6;
				string text2 = (((Object)val).name = "Item Upgrade Player " + upgradeName);
				string name = text2;
				val.itemName = upgradeName + " Upgrade";
				val.maxAmount = ((BaseUnityPlugin)instance).Config.Bind<int>(new ConfigDefinition(upgradeName, "Max Amount"), 10, (ConfigDescription)null).Value;
				val.maxAmountInShop = ((BaseUnityPlugin)instance).Config.Bind<int>(new ConfigDefinition(upgradeName, "Max Amount In Shop"), maxAmountInShop, (ConfigDescription)null).Value;
				val.maxPurchaseAmount = ((BaseUnityPlugin)instance).Config.Bind<int>(new ConfigDefinition(upgradeName, "Max Purchase Amount"), 0, (ConfigDescription)null).Value;
				val.maxPurchase = val.maxPurchaseAmount > 0;
				Value val2 = ScriptableObject.CreateInstance<Value>();
				val2.valueMin = ((BaseUnityPlugin)instance).Config.Bind<float>(new ConfigDefinition(upgradeName, "Minimum Price"), valueMin, (ConfigDescription)null).Value;
				val2.valueMax = ((BaseUnityPlugin)instance).Config.Bind<float>(new ConfigDefinition(upgradeName, "Maximum Price"), valueMax, (ConfigDescription)null).Value;
				val.value = val2;
				GameObject obj = instance.assetBundle.LoadAsset<GameObject>(upgradeObject);
				((Object)obj).name = name;
				ItemAttributes component = obj.GetComponent<ItemAttributes>();
				component.item = val;
				REPOLibItemUpgrade component2 = obj.GetComponent<REPOLibItemUpgrade>();
				AccessTools.Field(typeof(REPOLibItemUpgrade), "_upgradeId").SetValue(component2, upgradeId);
				Items.RegisterItem(component);
				UpgradeInfo val3 = new UpgradeInfo();
				val3.displayName = upgradeName;
				StatsManager.instance.upgradesInfo.Add("playerUpgrade" + upgradeId, val3);
				return Upgrades.RegisterUpgrade(upgradeId, val, (Action<PlayerAvatar, int>)null, upgradeAction);
			}
			return null;
		}

		private static void TumbleBlastExplosion(int level, Vector3 position)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Expected O, but got Unknown
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			ExplosionPreset obj = instance.assetBundle.LoadAsset<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;
			component.explosionSize = ((num > 1.8f) ? 1.8f : num);
			component.explosionDamage = 20 + (level - 1) * 15;
			component.explosionDamageEnemy = 40 + (level - 1) * 15;
			component.lightColorOverTime = new Gradient();
			_ = component.particleFire.colorOverLifetime;
			_ = component.particleSmoke.colorOverLifetime;
			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 => NestedComponentUtilities.GetParentComponent<PlayerHealth>(((Component)this).transform);

		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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Invalid comparison between Unknown and I4
			if (playerHealth.invincibleTimer > 0f || damage <= 0 || (GameManager.Multiplayer() && !photonView.IsMine) || playerHealth.playerAvatar.deadSet || playerHealth.godMode || (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)
			{
				CameraGlitch.Instance.PlayLongHurt(false);
			}
			else
			{
				CameraGlitch.Instance.PlayShortHurt(false);
			}
			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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.MasterAndOwnerOnlyRPC(_info, photonView))
			{
				return;
			}
			if (effect)
			{
				playerHealth.materialEffect = true;
				if (!playerHealth.playerAvatar.deadSet)
				{
					playerHealth.materialEffectLerp = 0f;
				}
				if (shieldValue < this.shieldValue)
				{
					if (shieldValue > 0)
					{
						playerHealth.hurtOther.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
					}
					playerHealth.hurtFreeze = true;
					foreach (Material instancedMaterial in playerHealth.instancedMaterials)
					{
						if ((Object)(object)instancedMaterial != (Object)(object)playerHealth.eyeMaterial && (Object)(object)instancedMaterial != (Object)(object)playerHealth.pupilMaterial)
						{
							instancedMaterial.SetColor(playerHealth.materialHurtColor, new Color(0.25f, 0.5f, 1f));
						}
					}
				}
			}
			if (shieldValue < this.shieldValue)
			{
				regenerationTimer = 15f;
			}
			this.shieldValue = shieldValue;
			this.shieldMax = shieldMax;
		}
	}
	public class ShieldUI : SemiUI
	{
		public TextMeshProUGUI Text;

		public static ShieldUI instance;

		public TextMeshProUGUI textEnergyMax;

		public Vector3 maxEnergyBasePosition;

		public float maxEnergyPrevOffset;

		public int shieldValue;

		public int shieldPrev;

		public override void Start()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			((SemiUI)this).Start();
			Text = ((Component)this).GetComponent<TextMeshProUGUI>();
			instance = this;
			textEnergyMax = ((Component)((Component)this).transform.Find("ShieldMax")).GetComponent<TextMeshProUGUI>();
			maxEnergyBasePosition = ((TMP_Text)textEnergyMax).transform.localPosition;
		}

		public override void Update()
		{
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			((SemiUI)this).Update();
			if (!PlayerAvatar.instance.isDisabled)
			{
				if (GoopUpgradesPlugin.instance.upgradeShield == null || GoopUpgradesPlugin.instance.upgradeShield.GetLevel(SemiFunc.PlayerGetSteamID(PlayerAvatar.instance)) == 0)
				{
					((SemiUI)this).Hide();
				}
			}
			else
			{
				((SemiUI)this).Hide();
			}
			if (base.isHidden || !((Object)(object)PlayerAvatar.instance.playerHealth != (Object)null))
			{
				return;
			}
			PlayerShield component = ((Component)PlayerAvatar.instance.playerHealth).GetComponent<PlayerShield>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return;
			}
			shieldValue = component.shieldValue;
			if (shieldValue != shieldPrev)
			{
				((SemiUI)this).SemiUISpringShakeY(4f, 5f, 0.25f);
				Color val = Color.white;
				if (shieldValue < shieldPrev)
				{
					val = Color.red;
				}
				((SemiUI)this).SemiUITextFlashColor(val, 0.2f);
				((SemiUI)this).SemiUISpringScale(0.3f, 5f, 0.125f);
				shieldPrev = shieldValue;
			}
			((TMP_Text)Text).text = component.shieldValue.ToString();
			float num = ((((TMP_Text)Text).text.Length > 3) ? ((float)(((TMP_Text)Text).text.Length - 3) * 20f) : 0f);
			((TMP_Text)textEnergyMax).transform.localPosition = maxEnergyBasePosition + new Vector3(num, 0f, 0f);
			((TMP_Text)textEnergyMax).text = "<b><color=blue>/</color></b>" + component.shieldMax;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}