Decompiled source of Bridge Launcher v1.0.0

tony.and.Snoszs-Bridge Launcher.dll

Decompiled 5 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using PhotonCustomPropsUtils;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Bridge Shooter")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Bridge Shooter")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7f474d59-c7ff-487d-b9fc-484952726918")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[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 Bridge_Launcher
{
	public static class BridgeLauncherDataEntryKey
	{
		public static readonly DataEntryKey LauncherType;
	}
	[BepInPlugin("tony4twentys.Bridge_Launcher", "Bridge Launcher", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class BridgeLauncherPlugin : BaseUnityPlugin, IConnectionCallbacks
	{
		[HarmonyPatch(typeof(JungleVine), "Awake")]
		private static class JungleVine_Awake_Patch
		{
			private static void Prefix(JungleVine __instance)
			{
				ChainBridgeTag component = ((Component)__instance).gameObject.GetComponent<ChainBridgeTag>();
				if ((Object)(object)component == (Object)null)
				{
					component = ((Component)__instance).gameObject.AddComponent<ChainBridgeTag>();
				}
			}
		}

		public const string PluginGuid = "tony4twentys.Bridge_Launcher";

		public const string PluginName = "Bridge Launcher";

		public const string PluginVersion = "1.0.0";

		internal static ConfigEntry<float> BridgeLauncherChanceConfig;

		private Harmony _harmony;

		public static BridgeLauncherPlugin Instance;

		private PhotonScopedManager photonManager;

		public bool IsHost = false;

		public bool allowBridgeLauncherModification = false;

		private void Awake()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			Instance = this;
			BridgeLauncherChanceConfig = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Bridge Launcher Chance", 0.5f, "Chance (0.0 to 1.0) for a chain launcher to become a Chain Bridge Launcher. 0.5 = 50% chance.");
			_harmony = new Harmony("tony4twentys.Bridge_Launcher");
			_harmony.PatchAll(typeof(VineShooter_OnPrimaryFinishedCast_Patch));
			_harmony.PatchAll(typeof(JungleVine_Awake_Patch));
			_harmony.PatchAll(typeof(Item_GetItemName_Patch));
			_harmony.PatchAll(typeof(Item_Start_Patch));
			InitializePhotonManager();
			PhotonNetwork.AddCallbackTarget((object)this);
		}

		private void OnDestroy()
		{
			if (_harmony != null)
			{
				_harmony.UnpatchSelf();
			}
			PhotonNetwork.RemoveCallbackTarget((object)this);
		}

		private void InitializePhotonManager()
		{
			if (PhotonCustomPropsUtilsPlugin.IsReady)
			{
				SetupPhotonManager();
			}
			else
			{
				PhotonCustomPropsUtilsPlugin.OnReady += SetupPhotonManager;
			}
		}

		private void SetupPhotonManager()
		{
			photonManager = PhotonCustomPropsUtilsPlugin.GetManager("tony4twentys.Bridge_Launcher");
			photonManager.RegisterOnJoinedRoom((Action<Player>)delegate
			{
				CheckHostStatus();
			});
			photonManager.RegisterRoomProperty<string>("bridgeLauncherConfig", (RoomEventType)2, (Action<string>)delegate(string configData)
			{
				if (!PhotonNetwork.IsMasterClient && !string.IsNullOrEmpty(configData))
				{
					UnpackConfigData(configData);
					allowBridgeLauncherModification = true;
				}
			});
		}

		private void CheckHostStatus()
		{
			if (PhotonNetwork.InRoom)
			{
				if (PhotonNetwork.IsMasterClient)
				{
					IsHost = true;
					allowBridgeLauncherModification = true;
					PublishHostConfig();
				}
				else
				{
					IsHost = false;
					allowBridgeLauncherModification = false;
				}
			}
		}

		private void PublishHostConfig()
		{
			if (PhotonNetwork.IsMasterClient && photonManager != null)
			{
				string text = PackConfigData();
				photonManager.SetRoomProperty("bridgeLauncherConfig", (object)text);
			}
		}

		private string PackConfigData()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine($"CHANCE_BridgeLauncher={BridgeLauncherChanceConfig.Value}");
			return Convert.ToBase64String(Encoding.UTF8.GetBytes(stringBuilder.ToString()));
		}

		private void UnpackConfigData(string configData)
		{
			try
			{
				string @string = Encoding.UTF8.GetString(Convert.FromBase64String(configData));
				string[] array = @string.Split(new char[1] { '\n' });
				string[] array2 = array;
				foreach (string text in array2)
				{
					if (string.IsNullOrWhiteSpace(text))
					{
						continue;
					}
					string[] array3 = text.Split(new char[1] { '=' }, 2);
					if (array3.Length == 2)
					{
						string text2 = array3[0];
						string s = array3[1];
						if (text2 == "CHANCE_BridgeLauncher" && float.TryParse(s, out var result))
						{
							BridgeLauncherChanceConfig.Value = result;
						}
					}
				}
			}
			catch (Exception)
			{
			}
		}

		public void OnJoinedRoom()
		{
			CheckHostStatus();
		}

		public void OnLeftRoom()
		{
			IsHost = false;
			allowBridgeLauncherModification = false;
		}

		public void OnMasterClientSwitched(Player _)
		{
			CheckHostStatus();
		}

		public void OnPlayerEnteredRoom(Player _)
		{
			if (PhotonNetwork.IsMasterClient && photonManager != null)
			{
				PublishHostConfig();
			}
		}

		public static void AdjustColliderPositions(GameObject vineObject)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			Transform val = vineObject.transform.Find("ColliderRoot");
			if (!((Object)(object)val == (Object)null))
			{
				val.localPosition = new Vector3(-0.5f, -0.5f, -0.5f);
			}
		}

		public static void ZeroOutCollisionModifierDamage(GameObject root)
		{
			Transform val = root.transform.Find("ColliderRoot");
			if ((Object)(object)val == (Object)null)
			{
				CollisionModifier[] componentsInChildren = root.GetComponentsInChildren<CollisionModifier>(true);
				foreach (CollisionModifier val2 in componentsInChildren)
				{
					val2.damage = 0f;
				}
				return;
			}
			for (int j = 0; j < val.childCount; j++)
			{
				Transform child = val.GetChild(j);
				CollisionModifier component = ((Component)child).GetComponent<CollisionModifier>();
				if ((Object)(object)component != (Object)null)
				{
					component.damage = 0f;
				}
			}
		}

		public void OnPlayerLeftRoom(Player _)
		{
		}

		public void OnRoomPropertiesUpdate(Hashtable _)
		{
		}

		public void OnPlayerPropertiesUpdate(Player _, Hashtable _1)
		{
		}

		public void OnConnected()
		{
		}

		public void OnConnectedToMaster()
		{
		}

		public void OnDisconnected(DisconnectCause _)
		{
		}

		public void OnRegionListReceived(RegionHandler _)
		{
		}

		public void OnCustomAuthenticationResponse(Dictionary<string, object> _)
		{
		}

		public void OnCustomAuthenticationFailed(string _)
		{
		}

		public void OnFriendListUpdate(List<FriendInfo> _)
		{
		}

		public void OnCreatedRoom()
		{
		}

		public void OnCreateRoomFailed(short _, string _1)
		{
		}

		public void OnJoinRoomFailed(short _, string _1)
		{
		}

		public void OnJoinRandomFailed(short _, string _1)
		{
		}
	}
	public class ChainBridgeTag : MonoBehaviour
	{
		[PunRPC]
		public void MarkAsChainBridge(Vector3 from, Vector3 to, float hang, Vector3 mid)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			BreakableBridge[] array = Resources.FindObjectsOfTypeAll<BreakableBridge>();
			if (array.Length != 0)
			{
				BreakableBridge val = array[0];
				JungleVine component = Object.Instantiate<GameObject>(((Component)val).gameObject, from, Quaternion.identity).GetComponent<JungleVine>();
				Object.Destroy((Object)(object)((Component)component).GetComponent<BreakableBridge>());
				Collider[] componentsInChildren = ((Component)component).GetComponentsInChildren<Collider>();
				Collider[] array2 = componentsInChildren;
				foreach (Collider val2 in array2)
				{
					Object.DestroyImmediate((Object)(object)val2);
				}
				component.ForceBuildVine(from, to, hang, mid);
				AddChainAnchors(((Component)component).gameObject, from, to);
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		private void AddChainAnchors(GameObject bridgeObject, Vector3 from, Vector3 to)
		{
			//IL_0042: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_00c5: 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)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: 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)
			try
			{
				GameObject[] array = (from go in Resources.FindObjectsOfTypeAll<GameObject>()
					where ((Object)go).name.Contains("Chain Anchor") || ((Object)go).name.Contains("ChainAnchor")
					select go).ToArray();
				if (array.Length != 0)
				{
					GameObject val = array[0];
					Vector3 val2 = to - from;
					Vector3 normalized = ((Vector3)(ref val2)).normalized;
					val2 = Vector3.Cross(Vector3.up, normalized);
					Vector3 val3 = ((Vector3)(ref val2)).normalized;
					if (((Vector3)(ref val3)).sqrMagnitude < 0.0001f)
					{
						val3 = Vector3.right;
					}
					float num = 0.5f;
					Vector3 val4 = from + val3 * num;
					Vector3 val5 = from - val3 * num;
					GameObject val6 = Object.Instantiate<GameObject>(val, val4, Quaternion.identity, bridgeObject.transform);
					GameObject val7 = Object.Instantiate<GameObject>(val, val5, Quaternion.identity, bridgeObject.transform);
					Debug.Log((object)$"Bridge Launcher: Added 2 Chain Anchors to bridge at positions {val4} and {val5}");
				}
				else
				{
					Debug.LogWarning((object)"Bridge Launcher: Could not find Chain Anchor prefab in resources");
				}
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"Bridge Launcher: Error adding chain anchors: {arg}");
			}
		}
	}
	[HarmonyPatch]
	internal static class VineShooter_OnPrimaryFinishedCast_Patch
	{
		private static MethodBase TargetMethod()
		{
			Type type = AccessTools.TypeByName("VineShooter");
			return AccessTools.Method(type, "OnPrimaryFinishedCast", (Type[])null, (Type[])null);
		}

		private static bool Prefix(object __instance, ref bool __runOriginal)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: 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)
			object obj = ((__instance is Component) ? __instance : null);
			Item val = ((obj != null) ? ((Component)obj).GetComponent<Item>() : null);
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogError((object)"Bridge Launcher: Could not get Item component from VineShooter");
				return true;
			}
			bool flag = val.HasData(BridgeLauncherDataEntryKey.LauncherType) && val.GetData<BoolItemData>(BridgeLauncherDataEntryKey.LauncherType).Value;
			Debug.Log((object)$"Bridge Launcher: Item {((Object)val).name} - Is Bridge Launcher: {flag}");
			if (!flag)
			{
				return true;
			}
			if (!Character.localCharacter.data.isGrounded)
			{
				Debug.Log((object)"Bridge Launcher: Player must be grounded to fire bridge launcher");
				return false;
			}
			__runOriginal = false;
			try
			{
				VineShooter val2 = (VineShooter)((__instance is VineShooter) ? __instance : null);
				RaycastHit val3 = default(RaycastHit);
				if (!val2.WillAttach(ref val3))
				{
					return false;
				}
				GameObject disableOnFire = val2.disableOnFire;
				if (disableOnFire != null)
				{
					disableOnFire.SetActive(false);
				}
				GameObject vinePrefab = val2.vinePrefab;
				if ((Object)(object)vinePrefab == (Object)null)
				{
					Debug.LogError((object)"Bridge Launcher: vinePrefab was null.");
					return false;
				}
				JungleVine component = vinePrefab.GetComponent<JungleVine>();
				Vector2 val4 = default(Vector2);
				((Vector2)(ref val4))..ctor(component.minDown, component.maxDown);
				int num = 10;
				RaycastHit val8 = default(RaycastHit);
				Vector3 mid = default(Vector3);
				for (int i = 0; i < num; i++)
				{
					float num2 = (float)i / ((float)num - 1f);
					Vector2 val5 = Vector2.Lerp(val4, Vector2.zero, num2);
					float num3 = 0f - Random.Range(val5.x, val5.y);
					Camera main = Camera.main;
					Vector3 val6 = ((Component)main).transform.position + ((Component)main).transform.forward * 1f;
					Vector3 val7 = ((Component)main).transform.position - Vector3.up * 0.2f;
					int num4 = 2;
					if (Physics.Raycast(val6, Vector3.down, ref val8, 4f, num4, (QueryTriggerInteraction)0))
					{
						val7 = ((RaycastHit)(ref val8)).point + Vector3.up * 1.5f;
					}
					if (JungleVine.CheckVinePath(val7, ((RaycastHit)(ref val3)).point, num3, ref mid))
					{
						GameObject prefabToUse = vinePrefab;
						Vector3 val9 = ((RaycastHit)(ref val3)).point - val7;
						Vector3 normalized = ((Vector3)(ref val9)).normalized;
						val9 = Vector3.Cross(Vector3.up, normalized);
						Vector3 val10 = ((Vector3)(ref val9)).normalized;
						if (((Vector3)(ref val10)).sqrMagnitude < 0.0001f)
						{
							val10 = ((Component)Camera.main).transform.right;
						}
						SpawnBridge(prefabToUse, val7, ((RaycastHit)(ref val3)).point, num3, mid, Vector3.zero, attachBridge: true);
						Action_ReduceUses actionReduceUses = val2.actionReduceUses;
						if (actionReduceUses != null)
						{
							((ItemActionBase)actionReduceUses).RunAction();
						}
						component.SetRendererBounds();
						try
						{
							GameUtils.instance.IncrementPermanentItemsPlaced();
						}
						catch
						{
						}
						return false;
					}
					Debug.DrawLine(val7, ((RaycastHit)(ref val3)).point, Color.red, 5f);
				}
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"Bridge Launcher error: {arg}");
			}
			return false;
		}

		private static void SpawnBridge(GameObject prefabToUse, Vector3 start, Vector3 end, float hang, Vector3 mid, Vector3 offset, bool attachBridge)
		{
			//IL_0023: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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)
			BreakableBridge[] array = Resources.FindObjectsOfTypeAll<BreakableBridge>();
			if (array.Length != 0)
			{
				PlayBridgeBreakSound();
				PlayGunshotVFX();
				JungleVine component = PhotonNetwork.Instantiate(((Object)prefabToUse).name, start, Quaternion.identity, (byte)0, (object[])null).GetComponent<JungleVine>();
				component.photonView.RPC("MarkAsChainBridge", (RpcTarget)3, new object[4] { start, end, hang, mid });
			}
		}

		private static void PlayBridgeBreakSound()
		{
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				BreakableBridge[] array = Resources.FindObjectsOfTypeAll<BreakableBridge>();
				if (array.Length != 0)
				{
					BreakableBridge val = array[0];
					Debug.Log((object)$"Bridge Launcher: Found {array.Length} BreakableBridge instances");
					if (val.breakSfx != null && val.breakSfx.Length != 0)
					{
						Debug.Log((object)$"Bridge Launcher: Found {val.breakSfx.Length} break sounds");
						for (int i = 0; i < val.breakSfx.Length; i++)
						{
							if ((Object)(object)val.breakSfx[i] != (Object)null)
							{
								val.breakSfx[i].Play(((Component)Camera.main).transform.position);
								Debug.Log((object)$"Bridge Launcher: Played break sound {i + 1} at position {((Component)Camera.main).transform.position}");
							}
						}
					}
					else
					{
						Debug.LogError((object)"Bridge Launcher: breakSfx array is null or empty");
					}
				}
				else
				{
					Debug.LogError((object)"Bridge Launcher: No BreakableBridge instances found");
				}
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"Bridge Launcher: Error playing bridge break sound: {arg}");
			}
		}

		private static void PlayGunshotVFX()
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				RopeShooter[] array = Resources.FindObjectsOfTypeAll<RopeShooter>();
				if (array.Length != 0)
				{
					RopeShooter val = array[0];
					Debug.Log((object)$"Bridge Launcher: Found {array.Length} RopeShooter instances");
					if ((Object)(object)val.gunshotVFX != (Object)null)
					{
						val.gunshotVFX.Play();
						Debug.Log((object)"Bridge Launcher: Played gunshot VFX");
						try
						{
							GamefeelHandler.instance.AddPerlinShakeProximity(((Component)val.gunshotVFX).transform.position, 30f, 0.3f, 15f, 10f);
							Debug.Log((object)"Bridge Launcher: Added screen shake");
							return;
						}
						catch (Exception arg)
						{
							Debug.LogError((object)$"Bridge Launcher: Error adding screen shake: {arg}");
							return;
						}
					}
					Debug.LogError((object)"Bridge Launcher: gunshotVFX is null");
				}
				else
				{
					Debug.LogError((object)"Bridge Launcher: No RopeShooter instances found");
				}
			}
			catch (Exception arg2)
			{
				Debug.LogError((object)$"Bridge Launcher: Error playing gunshot VFX: {arg2}");
			}
		}

		private static bool IsChainLauncher(Item item)
		{
			if ((Object)(object)item == (Object)null)
			{
				return false;
			}
			VineShooter component = ((Component)item).GetComponent<VineShooter>();
			return (Object)(object)component != (Object)null;
		}
	}
	[HarmonyPatch(typeof(Item), "GetItemName")]
	internal static class Item_GetItemName_Patch
	{
		private static void Postfix(Item __instance, ItemInstanceData data, ref string __result)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			if (!IsChainLauncher(__instance))
			{
				return;
			}
			bool flag = false;
			if (data != null && data.HasData(BridgeLauncherDataEntryKey.LauncherType))
			{
				BoolItemData val = default(BoolItemData);
				if (data.TryGetDataEntry<BoolItemData>(BridgeLauncherDataEntryKey.LauncherType, ref val))
				{
					flag = val.Value;
				}
			}
			else if (__instance.HasData(BridgeLauncherDataEntryKey.LauncherType))
			{
				flag = __instance.GetData<BoolItemData>(BridgeLauncherDataEntryKey.LauncherType).Value;
			}
			if (flag)
			{
				__result = "Bridge Launcher";
			}
		}

		private static bool IsChainLauncher(Item item)
		{
			if ((Object)(object)item == (Object)null)
			{
				return false;
			}
			VineShooter component = ((Component)item).GetComponent<VineShooter>();
			return (Object)(object)component != (Object)null;
		}
	}
	[HarmonyPatch(typeof(Item), "Start")]
	internal static class Item_Start_Patch
	{
		private static void Postfix(Item __instance)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			if (IsChainLauncher(__instance) && BridgeLauncherPlugin.Instance.allowBridgeLauncherModification && !__instance.HasData(BridgeLauncherDataEntryKey.LauncherType))
			{
				float num = Random.Range(0f, 1f);
				bool flag = num < BridgeLauncherPlugin.BridgeLauncherChanceConfig.Value;
				BoolItemData data = __instance.GetData<BoolItemData>(BridgeLauncherDataEntryKey.LauncherType);
				data.Value = flag;
				Debug.Log((object)$"Item_Start: Chain launcher {((Object)__instance).name} - Random: {num:F3}, Is Bridge Launcher: {flag} (chance: {BridgeLauncherPlugin.BridgeLauncherChanceConfig.Value})");
			}
		}

		private static bool IsChainLauncher(Item item)
		{
			if ((Object)(object)item == (Object)null)
			{
				return false;
			}
			VineShooter component = ((Component)item).GetComponent<VineShooter>();
			return (Object)(object)component != (Object)null;
		}
	}
}