Decompiled source of HoldMyBingBong v1.1.2

plugins/com.lstrings.peak.holdmybingbong.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.lstrings.peak.holdmybingbong")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.2.0")]
[assembly: AssemblyInformationalVersion("1.1.2")]
[assembly: AssemblyProduct("com.lstrings.peak.holdmybingbong")]
[assembly: AssemblyTitle("HoldMyBingBong")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.2.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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace HoldMyBingBong
{
	[HarmonyPatch(typeof(CharacterAfflictions), "UpdateWeight")]
	internal class CharacterAfflictions_UpdateWeight_Patch
	{
		[HarmonyPrefix]
		private static bool Prefix(CharacterAfflictions __instance)
		{
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			float currentStatus = __instance.GetCurrentStatus((STATUSTYPE)9);
			for (int i = 0; i < __instance.character.player.itemSlots.Length; i++)
			{
				ItemSlot val = __instance.character.player.itemSlots[i];
				if ((Object)(object)val.prefab != (Object)null)
				{
					num += val.prefab.CarryWeight;
					if (Plugin.IsNormalBingBong(val.prefab))
					{
						num3 += Plugin.BingBongWeight.Value;
					}
					else if (Plugin.IsGoldenBingBong(val.prefab))
					{
						num3 += Plugin.AncientIdolWeight.Value;
					}
				}
			}
			BackpackSlot backpackSlot = __instance.character.player.backpackSlot;
			BackpackData val2 = default(BackpackData);
			if (!((ItemSlot)backpackSlot).IsEmpty() && ((ItemSlot)backpackSlot).data.TryGetDataEntry<BackpackData>((DataEntryKey)7, ref val2))
			{
				for (int j = 0; j < val2.itemSlots.Length; j++)
				{
					ItemSlot val3 = val2.itemSlots[j];
					if (!val3.IsEmpty())
					{
						num += val3.prefab.CarryWeight;
						if (Plugin.IsNormalBingBong(val3.prefab))
						{
							num3 += Plugin.BingBongWeight.Value;
						}
						else if (Plugin.IsGoldenBingBong(val3.prefab))
						{
							num3 += Plugin.AncientIdolWeight.Value;
						}
					}
				}
			}
			ItemSlot itemSlot = __instance.character.player.GetItemSlot((byte)250);
			if (!itemSlot.IsEmpty())
			{
				num += itemSlot.prefab.CarryWeight;
				if (Plugin.IsNormalBingBong(itemSlot.prefab))
				{
					num3 += Plugin.BingBongWeight.Value;
				}
				else if (Plugin.IsGoldenBingBong(itemSlot.prefab))
				{
					num3 += Plugin.AncientIdolWeight.Value;
				}
			}
			if ((Object)(object)__instance.character.data.carriedPlayer != (Object)null)
			{
				num += 8;
			}
			foreach (StickyItemComponent aLL_STUCK_ITEM in StickyItemComponent.ALL_STUCK_ITEMS)
			{
				if ((Object)(object)aLL_STUCK_ITEM.stuckToCharacter == (Object)(object)__instance.character)
				{
					num += aLL_STUCK_ITEM.addWeightToStuckPlayer;
					num2 += aLL_STUCK_ITEM.addThornsToStuckPlayer;
				}
			}
			if (Object.op_Implicit((Object)(object)__instance.character.data.currentStickyItem))
			{
				num2 += __instance.character.data.currentStickyItem.addThornsToStuckPlayer;
			}
			num2 += __instance.GetTotalThornStatusIncrements();
			if (__instance.character.data.isSkeleton)
			{
				num2 = 0;
			}
			float num4 = 0.025f * (float)num2;
			if (num4 > currentStatus)
			{
				__instance.StatusSFX((STATUSTYPE)9, num4 - currentStatus);
				if (__instance.character.IsLocal && (Object)(object)__instance.character == (Object)(object)Character.observedCharacter)
				{
					GUIManager.instance.AddStatusFX((STATUSTYPE)9, num4 - currentStatus);
				}
				__instance.PlayParticle((STATUSTYPE)9);
			}
			__instance.SetStatus((STATUSTYPE)7, 0.025f * (float)num + 0.01f * (float)num3, true);
			__instance.SetStatus((STATUSTYPE)9, 0.025f * (float)num2, true);
			return false;
		}
	}
	public static class SimpleSerializer
	{
		public static byte[] ToBytes(this object obj)
		{
			using MemoryStream memoryStream = new MemoryStream();
			new BinaryFormatter().Serialize(memoryStream, obj);
			return memoryStream.ToArray();
		}

		public static T FromBytes<T>(this byte[] bytes)
		{
			using MemoryStream serializationStream = new MemoryStream(bytes);
			return (T)new BinaryFormatter().Deserialize(serializationStream);
		}
	}
	[BepInPlugin("com.lstrings.peak.holdmybingbong", "HoldMyBingBong", "1.1.2")]
	public class Plugin : BaseUnityPlugin
	{
		[Serializable]
		public class HoldMyBingBongConfig
		{
			public float penaltyInjuryAmount;

			public float penaltyCurseAmount;

			public float penaltyPoisonAmount;

			public float penaltySporesAmount;

			public float penaltyDrowsyAmount;

			public float penaltySkeletonInjuryAmount;

			public float penaltySkeletonCurseAmount;

			public bool bingBongAreaEffectEnabled;

			public float bingBongAreaEffectRadius;

			public int bingBongWeight;

			public float bingBongScale;

			public bool ancientIdolAreaEffectEnabled;

			public float ancientIdolAreaEffectRadius;

			public int ancientIdolWeight;

			public float ancientIdolScale;

			public bool ancientIdolHealEnabled;
		}

		[HarmonyPatch(typeof(Item), "Start")]
		public static class Item_Start_Postfix
		{
			[HarmonyPostfix]
			public static void Postfix(Item __instance)
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				if (IsNormalBingBong(__instance))
				{
					Transform transform = ((Component)__instance).transform;
					transform.localScale *= BingBongScale.Value;
					FixColliders(__instance);
				}
				else if (IsGoldenBingBong(__instance))
				{
					Transform transform2 = ((Component)__instance).transform;
					transform2.localScale *= AncientIdolScale.Value;
					FixColliders(__instance);
				}
			}

			private static void FixColliders(Item item)
			{
				Collider[] componentsInChildren = ((Component)item).GetComponentsInChildren<Collider>();
				foreach (Collider val in componentsInChildren)
				{
					val.enabled = false;
					val.enabled = true;
				}
			}
		}

		private static GameObject go;

		private static float penaltyInjuryAmount;

		private static float penaltyCurseAmount;

		private static float penaltyPoisonAmount;

		private static float penaltySporesAmount;

		private static float penaltyDrowsyAmount;

		private static float penaltySkeletonInjuryAmount;

		private static float penaltySkeletonCurseAmount;

		private static bool bingBongAreaEffectEnabled;

		private static float bingBongAreaEffectRadius;

		private static int bingBongWeight;

		private static float bingBongScale;

		private static bool ancientIdolAreaEffectEnabled;

		private static float ancientIdolAreaEffectRadius;

		private static int ancientIdolWeight;

		private static float ancientIdolScale;

		private static bool ancientIdolHealEnabled;

		public static ConfigEntry<bool> ModEnabled;

		public static ConfigEntry<float> UpdateInterval;

		public static ConfigEntry<float> PenaltyInjuryAmount;

		public static ConfigEntry<float> PenaltyCurseAmount;

		public static ConfigEntry<float> PenaltyPoisonAmount;

		public static ConfigEntry<float> PenaltySporesAmount;

		public static ConfigEntry<float> PenaltyDrowsyAmount;

		public static ConfigEntry<float> PenaltySkeletonInjuryAmount;

		public static ConfigEntry<float> PenaltySkeletonCurseAmount;

		public static ConfigEntry<bool> BingBongAreaEffectEnabled;

		public static ConfigEntry<float> BingBongAreaEffectRadius;

		public static ConfigEntry<int> BingBongWeight;

		public static ConfigEntry<float> BingBongScale;

		public static ConfigEntry<bool> AncientIdolAreaEffectEnabled;

		public static ConfigEntry<float> AncientIdolAreaEffectRadius;

		public static ConfigEntry<int> AncientIdolWeight;

		public static ConfigEntry<float> AncientIdolScale;

		public static ConfigEntry<bool> AncientIdolHealEnabled;

		private static bool suppressEvents;

		private float accumulatedDeltaTime;

		public const string Id = "com.lstrings.peak.holdmybingbong";

		internal static ManualLogSource Log { get; private set; }

		public static string Name => "HoldMyBingBong";

		public static string Version => "1.1.2";

		private HoldMyBingBongConfig MakeSyncData()
		{
			return new HoldMyBingBongConfig
			{
				penaltyInjuryAmount = penaltyInjuryAmount,
				penaltyCurseAmount = penaltyCurseAmount,
				penaltyPoisonAmount = penaltyPoisonAmount,
				penaltySporesAmount = penaltySporesAmount,
				penaltyDrowsyAmount = penaltyDrowsyAmount,
				penaltySkeletonInjuryAmount = penaltySkeletonInjuryAmount,
				penaltySkeletonCurseAmount = penaltySkeletonCurseAmount,
				bingBongAreaEffectEnabled = bingBongAreaEffectEnabled,
				bingBongAreaEffectRadius = bingBongAreaEffectRadius,
				bingBongWeight = bingBongWeight,
				bingBongScale = bingBongScale,
				ancientIdolAreaEffectEnabled = ancientIdolAreaEffectEnabled,
				ancientIdolAreaEffectRadius = ancientIdolAreaEffectRadius,
				ancientIdolWeight = ancientIdolWeight,
				ancientIdolScale = ancientIdolScale,
				ancientIdolHealEnabled = ancientIdolHealEnabled
			};
		}

		private void Awake()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			ConfigInit();
			go = new GameObject("HoldMyBingBongPlugin");
			((Object)go).hideFlags = (HideFlags)61;
			go.AddComponent<SyncManager>();
			Harmony val = new Harmony("com.lstrings.peak.holdmybingbong");
			val.PatchAll(Assembly.GetExecutingAssembly());
			SceneManager.sceneLoaded += OnSceneLoaded;
			Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			if (((Scene)(ref scene)).name != null)
			{
				((Scene)(ref scene)).name.Contains("Level_");
			}
		}

		private void ConfigInit()
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Expected O, but got Unknown
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Expected O, but got Unknown
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Expected O, but got Unknown
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Expected O, but got Unknown
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Expected O, but got Unknown
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Expected O, but got Unknown
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Expected O, but got Unknown
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Expected O, but got Unknown
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Expected O, but got Unknown
			ModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Mod", true, "");
			UpdateInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Penalty", "Set Mod Update Interval", 0.2f, "Default Value: 0.2");
			PenaltyInjuryAmount = ((BaseUnityPlugin)this).Config.Bind<float>("Penalty", "Host: Injury Amount", 0f, new ConfigDescription("Default Value: 0", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			PenaltyCurseAmount = ((BaseUnityPlugin)this).Config.Bind<float>("Penalty", "Host: Curse Amount", 0f, new ConfigDescription("Default Value: 0", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			PenaltyPoisonAmount = ((BaseUnityPlugin)this).Config.Bind<float>("Penalty", "Host: Poison Amount", 0.005f, new ConfigDescription("Default Value: 0.005", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			PenaltySporesAmount = ((BaseUnityPlugin)this).Config.Bind<float>("Penalty", "Host: Spores Amount", 0.005f, new ConfigDescription("Default Value: 0.005", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			PenaltyDrowsyAmount = ((BaseUnityPlugin)this).Config.Bind<float>("Penalty", "Host: Drowsy Amount", 0.01f, new ConfigDescription("Default Value: 0.01", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			PenaltySkeletonInjuryAmount = ((BaseUnityPlugin)this).Config.Bind<float>("Penalty", "Host: Skeleton Injury Amount", 0.02f, new ConfigDescription("Default Value: 0.02", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			PenaltySkeletonCurseAmount = ((BaseUnityPlugin)this).Config.Bind<float>("Penalty", "Host: Skeleton Curse Amount", 0f, new ConfigDescription("Default Value: 0", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			BingBongAreaEffectEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Bing Bong", "Host: Enable Area Effect", false, "");
			BingBongAreaEffectRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Bing Bong", "Host: Area Effect Radius", 20f, new ConfigDescription("Default Value: 20", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
			BingBongWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Bing Bong", "Host: Set Aditional Weight", 25, new ConfigDescription("Default Value: 25, No Aditional Weight: 0", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-5, 99), Array.Empty<object>()));
			BingBongScale = ((BaseUnityPlugin)this).Config.Bind<float>("Bing Bong", "Host: Set Scale", 2.5f, "Vanilla Value: 2.5");
			AncientIdolAreaEffectEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Golden Bing Bong", "Host: Enable Area Effect", true, "");
			AncientIdolAreaEffectRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Golden Bing Bong", "Host: Area Effect Radius", 20f, new ConfigDescription("Default Value: 20", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
			AncientIdolWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Golden Bing Bong", "Host: Set Aditional Weight", 35, new ConfigDescription("Default Value: 35, No Aditional Weight: 0", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-40, 59), Array.Empty<object>()));
			AncientIdolScale = ((BaseUnityPlugin)this).Config.Bind<float>("Golden Bing Bong", "Host: Set Scale", 1.6f, "Default Value: 1.6, Vanilla Value: 1");
			AncientIdolHealEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Golden Bing Bong", "Host: Enable Super Heal", true, "");
			CopyConfigToLocal();
			PenaltyInjuryAmount.SettingChanged += OnConfigChanged;
			PenaltyCurseAmount.SettingChanged += OnConfigChanged;
			PenaltyPoisonAmount.SettingChanged += OnConfigChanged;
			PenaltySporesAmount.SettingChanged += OnConfigChanged;
			PenaltyDrowsyAmount.SettingChanged += OnConfigChanged;
			PenaltySkeletonInjuryAmount.SettingChanged += OnConfigChanged;
			PenaltySkeletonCurseAmount.SettingChanged += OnConfigChanged;
			BingBongAreaEffectEnabled.SettingChanged += OnConfigChanged;
			BingBongAreaEffectRadius.SettingChanged += OnConfigChanged;
			BingBongWeight.SettingChanged += OnConfigChanged;
			BingBongScale.SettingChanged += OnConfigChanged;
			AncientIdolAreaEffectEnabled.SettingChanged += OnConfigChanged;
			AncientIdolAreaEffectRadius.SettingChanged += OnConfigChanged;
			AncientIdolWeight.SettingChanged += OnConfigChanged;
			AncientIdolScale.SettingChanged += OnConfigChanged;
			AncientIdolHealEnabled.SettingChanged += OnConfigChanged;
		}

		private void OnConfigChanged(object sender, EventArgs e)
		{
			if (!suppressEvents)
			{
				if (PhotonNetwork.IsMasterClient)
				{
					CopyConfigToLocal();
					SyncManager.instance?.SendConfig(MakeSyncData());
				}
				else
				{
					CopyLocalToConfig();
				}
			}
		}

		public static void CopyConfigToLocal()
		{
			penaltyInjuryAmount = PenaltyInjuryAmount.Value;
			penaltyCurseAmount = PenaltyCurseAmount.Value;
			penaltyPoisonAmount = PenaltyPoisonAmount.Value;
			penaltySporesAmount = PenaltySporesAmount.Value;
			penaltyDrowsyAmount = PenaltyDrowsyAmount.Value;
			penaltySkeletonInjuryAmount = PenaltySkeletonInjuryAmount.Value;
			penaltySkeletonCurseAmount = PenaltySkeletonCurseAmount.Value;
			bingBongAreaEffectEnabled = BingBongAreaEffectEnabled.Value;
			bingBongAreaEffectRadius = BingBongAreaEffectRadius.Value;
			bingBongWeight = BingBongWeight.Value;
			bingBongScale = BingBongScale.Value;
			ancientIdolAreaEffectEnabled = AncientIdolAreaEffectEnabled.Value;
			ancientIdolAreaEffectRadius = AncientIdolAreaEffectRadius.Value;
			ancientIdolWeight = AncientIdolWeight.Value;
			ancientIdolScale = AncientIdolScale.Value;
			ancientIdolHealEnabled = AncientIdolHealEnabled.Value;
		}

		public static void CopyLocalToConfig()
		{
			suppressEvents = true;
			PenaltyInjuryAmount.Value = penaltyInjuryAmount;
			PenaltyCurseAmount.Value = penaltyCurseAmount;
			PenaltyPoisonAmount.Value = penaltyPoisonAmount;
			PenaltySporesAmount.Value = penaltySporesAmount;
			PenaltyDrowsyAmount.Value = penaltyDrowsyAmount;
			PenaltySkeletonInjuryAmount.Value = penaltySkeletonInjuryAmount;
			PenaltySkeletonCurseAmount.Value = penaltySkeletonCurseAmount;
			BingBongAreaEffectEnabled.Value = bingBongAreaEffectEnabled;
			BingBongAreaEffectRadius.Value = bingBongAreaEffectRadius;
			BingBongWeight.Value = bingBongWeight;
			BingBongScale.Value = bingBongScale;
			AncientIdolAreaEffectEnabled.Value = ancientIdolAreaEffectEnabled;
			AncientIdolAreaEffectRadius.Value = ancientIdolAreaEffectRadius;
			AncientIdolWeight.Value = ancientIdolWeight;
			AncientIdolScale.Value = ancientIdolScale;
			AncientIdolHealEnabled.Value = ancientIdolHealEnabled;
			suppressEvents = false;
		}

		public static void CopyConfigDataToLocal(HoldMyBingBongConfig data)
		{
			penaltyInjuryAmount = data.penaltyInjuryAmount;
			penaltyCurseAmount = data.penaltyCurseAmount;
			penaltyPoisonAmount = data.penaltyPoisonAmount;
			penaltySporesAmount = data.penaltySporesAmount;
			penaltyDrowsyAmount = data.penaltyDrowsyAmount;
			penaltySkeletonInjuryAmount = data.penaltySkeletonInjuryAmount;
			penaltySkeletonCurseAmount = data.penaltySkeletonCurseAmount;
			bingBongAreaEffectEnabled = data.bingBongAreaEffectEnabled;
			bingBongAreaEffectRadius = data.bingBongAreaEffectRadius;
			bingBongWeight = data.bingBongWeight;
			bingBongScale = data.bingBongScale;
			ancientIdolAreaEffectEnabled = data.ancientIdolAreaEffectEnabled;
			ancientIdolAreaEffectRadius = data.ancientIdolAreaEffectRadius;
			ancientIdolWeight = data.ancientIdolWeight;
			ancientIdolScale = data.ancientIdolScale;
			ancientIdolHealEnabled = data.ancientIdolHealEnabled;
		}

		private void Update()
		{
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0361: Unknown result type (might be due to invalid IL or missing references)
			if (!ModEnabled.Value)
			{
				return;
			}
			accumulatedDeltaTime += Time.deltaTime;
			if (accumulatedDeltaTime < UpdateInterval.Value)
			{
				return;
			}
			float num = accumulatedDeltaTime;
			accumulatedDeltaTime = 0f;
			Character localCharacter = Character.localCharacter;
			if (localCharacter.data.dead || !localCharacter.data.fullyConscious || ContainsNormalBingBong(localCharacter.player.itemSlots))
			{
				return;
			}
			if (ContainsGoldenBingBong(localCharacter.player.itemSlots))
			{
				if (ancientIdolHealEnabled)
				{
					localCharacter.refs.afflictions.SubtractStatus((STATUSTYPE)0, 0.01f * num, false, false);
					localCharacter.refs.afflictions.SubtractStatus((STATUSTYPE)1, 0.01f * num, false, false);
					localCharacter.refs.afflictions.SubtractStatus((STATUSTYPE)2, 0.01f * num, false, false);
					localCharacter.refs.afflictions.SubtractStatus((STATUSTYPE)3, 0.01f * num, false, false);
					localCharacter.refs.afflictions.SubtractStatus((STATUSTYPE)5, 0.01f * num, false, false);
					localCharacter.refs.afflictions.SubtractStatus((STATUSTYPE)6, 0.01f * num, false, false);
					localCharacter.refs.afflictions.SubtractStatus((STATUSTYPE)8, 0.01f * num, false, false);
					localCharacter.refs.afflictions.SubtractStatus((STATUSTYPE)9, 0.01f * num, false, false);
					localCharacter.refs.afflictions.SubtractStatus((STATUSTYPE)10, 0.01f * num, false, false);
					localCharacter.refs.afflictions.SubtractStatus((STATUSTYPE)11, 0.01f * num, false, false);
				}
				return;
			}
			BackpackSlot backpackSlot = localCharacter.player.backpackSlot;
			BackpackData val = default(BackpackData);
			if (backpackSlot != null && backpackSlot.hasBackpack && ((ItemSlot)backpackSlot).data.TryGetDataEntry<BackpackData>((DataEntryKey)7, ref val) && ContainsBingBong(val.itemSlots))
			{
				return;
			}
			if (bingBongAreaEffectEnabled)
			{
				foreach (Item aLL_ITEM in Item.ALL_ITEMS)
				{
					if (IsNormalBingBong(aLL_ITEM) && Vector3.Distance(localCharacter.Center, aLL_ITEM.Center()) <= bingBongAreaEffectRadius)
					{
						return;
					}
				}
				foreach (Character allCharacter in Character.AllCharacters)
				{
					if (((allCharacter == null) ? null : allCharacter.player?.itemSlots) != null && ContainsNormalBingBong(allCharacter.player.itemSlots) && Vector3.Distance(localCharacter.Center, allCharacter.Center) <= bingBongAreaEffectRadius)
					{
						return;
					}
				}
			}
			if (ancientIdolAreaEffectEnabled)
			{
				foreach (Item aLL_ITEM2 in Item.ALL_ITEMS)
				{
					if (IsGoldenBingBong(aLL_ITEM2) && Vector3.Distance(localCharacter.Center, aLL_ITEM2.Center()) <= ancientIdolAreaEffectRadius)
					{
						return;
					}
				}
				foreach (Character allCharacter2 in Character.AllCharacters)
				{
					if (((allCharacter2 == null) ? null : allCharacter2.player?.itemSlots) != null && ContainsGoldenBingBong(allCharacter2.player.itemSlots) && Vector3.Distance(localCharacter.Center, allCharacter2.Center) <= ancientIdolAreaEffectRadius)
					{
						return;
					}
				}
			}
			if (localCharacter.data.isSkeleton)
			{
				localCharacter.refs.afflictions.AddStatus((STATUSTYPE)0, penaltySkeletonInjuryAmount * num * 0.125f, false, true);
				localCharacter.refs.afflictions.AddStatus((STATUSTYPE)5, penaltySkeletonCurseAmount * num, false, true);
				return;
			}
			localCharacter.refs.afflictions.AddStatus((STATUSTYPE)0, penaltyInjuryAmount * num, false, true);
			localCharacter.refs.afflictions.AddStatus((STATUSTYPE)5, penaltyCurseAmount * num, false, true);
			localCharacter.refs.afflictions.AddStatus((STATUSTYPE)3, penaltyPoisonAmount * num, false, true);
			localCharacter.refs.afflictions.AddStatus((STATUSTYPE)10, penaltySporesAmount * num, false, true);
			localCharacter.refs.afflictions.AddStatus((STATUSTYPE)6, penaltyDrowsyAmount * num, false, true);
		}

		private static bool ContainsBingBong(ItemSlot[] slots)
		{
			if (slots == null)
			{
				return false;
			}
			foreach (ItemSlot val in slots)
			{
				if (!((Object)(object)val?.prefab == (Object)null) && IsBingBong(val.prefab))
				{
					return true;
				}
			}
			return false;
		}

		private static bool ContainsNormalBingBong(ItemSlot[] slots)
		{
			if (slots == null)
			{
				return false;
			}
			foreach (ItemSlot val in slots)
			{
				if (!((Object)(object)val?.prefab == (Object)null) && IsNormalBingBong(val.prefab))
				{
					return true;
				}
			}
			return false;
		}

		private static bool ContainsGoldenBingBong(ItemSlot[] slots)
		{
			if (slots == null)
			{
				return false;
			}
			foreach (ItemSlot val in slots)
			{
				if (!((Object)(object)val?.prefab == (Object)null) && IsGoldenBingBong(val.prefab))
				{
					return true;
				}
			}
			return false;
		}

		private static bool IsBingBong(Item item)
		{
			//IL_0001: 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)
			if (!((Enum)item.itemTags).HasFlag((Enum)(object)(ItemTags)16))
			{
				return ((Enum)item.itemTags).HasFlag((Enum)(object)(ItemTags)64);
			}
			return true;
		}

		public static bool IsNormalBingBong(Item item)
		{
			//IL_0001: 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)
			if (((Enum)item.itemTags).HasFlag((Enum)(object)(ItemTags)16))
			{
				return !((Enum)item.itemTags).HasFlag((Enum)(object)(ItemTags)64);
			}
			return false;
		}

		public static bool IsGoldenBingBong(Item item)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return ((Enum)item.itemTags).HasFlag((Enum)(object)(ItemTags)64);
		}
	}
	public class SyncManager : MonoBehaviour
	{
		private readonly byte eventCode = 13;

		public static SyncManager instance;

		private void Awake()
		{
			instance = this;
		}

		private void OnEnable()
		{
			PhotonNetwork.NetworkingClient.EventReceived += OnEventReceived;
		}

		private void OnDisable()
		{
			PhotonNetwork.NetworkingClient.EventReceived -= OnEventReceived;
		}

		public void SendConfig(Plugin.HoldMyBingBongConfig data)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_0016: 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)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			byte[] array = data.ToBytes();
			RaiseEventOptions val = new RaiseEventOptions
			{
				Receivers = (ReceiverGroup)1
			};
			SendOptions val2 = default(SendOptions);
			((SendOptions)(ref val2)).Reliability = true;
			SendOptions val3 = val2;
			PhotonNetwork.RaiseEvent(eventCode, (object)array, val, val3);
		}

		public void ReceiveConfig(Plugin.HoldMyBingBongConfig data)
		{
			Plugin.CopyConfigDataToLocal(data);
			Plugin.CopyLocalToConfig();
		}

		private void OnEventReceived(EventData photonEvent)
		{
			if (photonEvent.Code == eventCode)
			{
				byte[] bytes = (byte[])photonEvent.CustomData;
				Plugin.HoldMyBingBongConfig data = bytes.FromBytes<Plugin.HoldMyBingBongConfig>();
				ReceiveConfig(data);
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}