using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
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 BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
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: 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.1.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.1.0")]
[module: UnverifiableCode]
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}
namespace Bridge_Launcher
{
public static class BridgeLauncherDataEntryKey
{
public static readonly DataEntryKey LauncherType = (DataEntryKey)76;
internal static readonly DataEntryKey HandCannonBridgeFrame = (DataEntryKey)75;
}
internal static class HandCannonAmmoCompat
{
private static readonly DataEntryKey LoadedAmmoType = (DataEntryKey)74;
public static bool ShouldYieldToHandCannons(Item item)
{
if (TryGetLoadedAmmo(item, out var ammo) && ammo >= 1)
{
return ammo <= 3;
}
return false;
}
public static bool IsEmptyHandCannon(Item item)
{
if (TryGetLoadedAmmo(item, out var ammo))
{
return ammo switch
{
4 => false,
0 => !HasRemainingUses(item),
_ => false,
};
}
if (!HasRemainingUses(item) && (Object)(object)item != (Object)null)
{
return item.HasData((DataEntryKey)2);
}
return false;
}
public static void SetChainIfEmpty(Item item)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)item == (Object)null) && HasRemainingUses(item) && (!TryGetLoadedAmmo(item, out var ammo) || ammo < 1 || ammo > 3) && (!TryGetLoadedAmmo(item, out ammo) || ammo != 0))
{
item.GetData<IntItemData>(LoadedAmmoType).Value = 4;
}
}
private static bool HasRemainingUses(Item item)
{
if ((Object)(object)item == (Object)null)
{
return false;
}
if (item.HasData((DataEntryKey)2))
{
OptionableIntItemData data = item.GetData<OptionableIntItemData>((DataEntryKey)2);
if (data != null && data.HasData)
{
return data.Value > 0;
}
}
VineShooter component = ((Component)item).GetComponent<VineShooter>();
if ((Object)(object)component != (Object)null && (Object)(object)component.disableOnFire != (Object)null)
{
return component.disableOnFire.activeSelf;
}
return false;
}
private static bool TryGetLoadedAmmo(Item item, out int ammo)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
ammo = 0;
if ((Object)(object)item == (Object)null || !item.HasData(LoadedAmmoType))
{
return false;
}
IntItemData data = item.GetData<IntItemData>(LoadedAmmoType);
if (data == null)
{
return false;
}
ammo = data.Value;
return true;
}
}
[BepInPlugin("tony4twentys.Bridge_Launcher", "Bridge Launcher", "1.1.1")]
public class BridgeLauncherPlugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(JungleVine), "Awake")]
private static class JungleVine_Awake_Patch
{
private static void Prefix(JungleVine __instance)
{
if ((Object)(object)((Component)__instance).gameObject.GetComponent<ChainBridgeTag>() == (Object)null)
{
((Component)__instance).gameObject.AddComponent<ChainBridgeTag>();
}
}
}
public const string PluginGuid = "tony4twentys.Bridge_Launcher";
public const string PluginName = "Bridge Launcher";
public const string PluginVersion = "1.1.1";
internal static ConfigEntry<float> BridgeLauncherChanceConfig;
private Harmony _harmony;
public static BridgeLauncherPlugin Instance;
internal static ManualLogSource Log { get; private set; }
internal static bool CanTagItems()
{
if (PhotonNetwork.InRoom)
{
return PhotonNetwork.IsMasterClient;
}
return true;
}
private void Awake()
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Expected O, but got Unknown
Instance = this;
Log = ((BaseUnityPlugin)this).Logger;
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. Host-only; the tag is stored on the item.");
_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));
BridgeNet.Ensure();
}
private void OnDestroy()
{
if (_harmony != null)
{
_harmony.UnpatchSelf();
}
}
public static void AdjustColliderPositions(GameObject vineObject)
{
//IL_002b: 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);
for (int i = 0; i < componentsInChildren.Length; i++)
{
componentsInChildren[i].damage = 0f;
}
return;
}
for (int j = 0; j < val.childCount; j++)
{
CollisionModifier component = ((Component)val.GetChild(j)).GetComponent<CollisionModifier>();
if ((Object)(object)component != (Object)null)
{
component.damage = 0f;
}
}
}
}
public class ChainBridgeTag : MonoBehaviour
{
[PunRPC]
public void MarkAsChainBridge(Vector3 from, Vector3 to, float hang, Vector3 mid)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
BridgeBuild.Build(from, to, hang, mid);
Object.Destroy((Object)(object)((Component)this).gameObject);
}
}
[HarmonyPatch]
internal static class VineShooter_OnPrimaryFinishedCast_Patch
{
private static MethodBase TargetMethod()
{
return AccessTools.Method(AccessTools.TypeByName("VineShooter"), "OnPrimaryFinishedCast", (Type[])null, (Type[])null);
}
private static bool Prefix(object __instance, ref bool __runOriginal)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
//IL_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: 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_0282: Unknown result type (might be due to invalid IL or missing references)
//IL_0286: Unknown result type (might be due to invalid IL or missing references)
//IL_028b: 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_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0201: 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_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
//IL_020f: Unknown result type (might be due to invalid IL or missing references)
//IL_0214: Unknown result type (might be due to invalid IL or missing references)
//IL_0218: Unknown result type (might be due to invalid IL or missing references)
//IL_021d: Unknown result type (might be due to invalid IL or missing references)
//IL_023e: Unknown result type (might be due to invalid IL or missing references)
//IL_0242: Unknown result type (might be due to invalid IL or missing references)
//IL_0249: Unknown result type (might be due to invalid IL or missing references)
//IL_024b: Unknown result type (might be due to invalid IL or missing references)
//IL_0237: Unknown result type (might be due to invalid IL or missing references)
//IL_023c: 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 (HandCannonAmmoCompat.ShouldYieldToHandCannons(val))
{
return true;
}
if (HandCannonAmmoCompat.IsEmptyHandCannon(val))
{
return false;
}
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, 0f))
{
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(vinePrefab, 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_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
PlayBridgeBreakSound();
PlayGunshotVFX();
BridgeNet.PlaceAndBroadcast(start, end, hang, mid);
}
private static void PlayBridgeBreakSound()
{
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: 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_005b: 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;
}
return (Object)(object)((Component)item).GetComponent<VineShooter>() != (Object)null;
}
}
[HarmonyPatch(typeof(Item), "GetItemName")]
internal static class Item_GetItemName_Patch
{
private static void Postfix(Item __instance, ItemInstanceData data, ref string __result)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: 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 && !HandCannonAmmoCompat.IsEmptyHandCannon(__instance) && !HandCannonAmmoCompat.ShouldYieldToHandCannons(__instance))
{
__result = "Bridge Launcher";
}
}
private static bool IsChainLauncher(Item item)
{
if ((Object)(object)item == (Object)null)
{
return false;
}
return (Object)(object)((Component)item).GetComponent<VineShooter>() != (Object)null;
}
}
[HarmonyPatch(typeof(Item), "Start")]
internal static class Item_Start_Patch
{
private static void Postfix(Item __instance)
{
if (IsChainLauncher(__instance) && BridgeLauncherPlugin.CanTagItems())
{
BridgeNet.ScheduleHostTag(__instance);
}
}
private static bool IsChainLauncher(Item item)
{
if ((Object)(object)item == (Object)null)
{
return false;
}
return (Object)(object)((Component)item).GetComponent<VineShooter>() != (Object)null;
}
}
internal struct BridgePlacement
{
public Vector3 Start;
public Vector3 End;
public float Hang;
public Vector3 Mid;
}
internal sealed class BridgeNet : MonoBehaviourPunCallbacks, IOnEventCallback
{
public const byte EventCode = 150;
public const string EventMagic = "tony4twentys.Bridge_Launcher";
public const int ProtocolVersion = 1;
private const byte SubPlace = 0;
private const byte SubRequest = 1;
private static BridgeNet _instance;
private static readonly List<BridgePlacement> Placements = new List<BridgePlacement>();
private static readonly HashSet<string> BuiltKeys = new HashSet<string>();
private static readonly HashSet<int> TagInFlight = new HashSet<int>();
public static void Ensure()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
if (!((Object)(object)_instance != (Object)null))
{
GameObject val = new GameObject("BridgeLauncherNet");
Object.DontDestroyOnLoad((Object)val);
_instance = val.AddComponent<BridgeNet>();
}
}
public override void OnEnable()
{
((MonoBehaviourPunCallbacks)this).OnEnable();
PhotonNetwork.AddCallbackTarget((object)this);
}
public override void OnDisable()
{
PhotonNetwork.RemoveCallbackTarget((object)this);
((MonoBehaviourPunCallbacks)this).OnDisable();
}
public override void OnJoinedRoom()
{
if (!PhotonNetwork.IsMasterClient)
{
RequestSnapshot();
}
}
public override void OnLeftRoom()
{
Placements.Clear();
BuiltKeys.Clear();
}
public override void OnPlayerEnteredRoom(Player _)
{
if (PhotonNetwork.IsMasterClient)
{
((MonoBehaviour)this).StartCoroutine(BroadcastAfterJoin());
}
}
public void OnEvent(EventData photonEvent)
{
HandleEvent(photonEvent);
}
public static void ScheduleHostTag(Item item)
{
Ensure();
if ((Object)(object)item == (Object)null || (Object)(object)_instance == (Object)null || !BridgeLauncherPlugin.CanTagItems())
{
return;
}
int instanceID = ((Object)item).GetInstanceID();
if (TagInFlight.Add(instanceID))
{
if (BridgeLauncherPlugin.Log != null)
{
BridgeLauncherPlugin.Log.LogInfo((object)("Queued host tag for " + ((Object)item).name + "."));
}
((MonoBehaviour)_instance).StartCoroutine(HostTagRoutine(item, instanceID));
}
}
private static IEnumerator HostTagRoutine(Item item, int id)
{
yield return (object)new WaitForSeconds(0.35f);
try
{
ApplyHostTag(item);
}
finally
{
TagInFlight.Remove(id);
}
}
private static void ApplyHostTag(Item item)
{
//IL_0019: 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_0026: 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)
if ((Object)(object)item == (Object)null || (Object)(object)((Component)item).GetComponent<VineShooter>() == (Object)null)
{
return;
}
if (item.HasData(BridgeLauncherDataEntryKey.LauncherType))
{
BoolItemData data = item.GetData<BoolItemData>(BridgeLauncherDataEntryKey.LauncherType);
if (data != null && data.Value)
{
return;
}
}
float num = Random.Range(0f, 1f);
bool flag = num < BridgeLauncherPlugin.BridgeLauncherChanceConfig.Value;
item.GetData<BoolItemData>(BridgeLauncherDataEntryKey.LauncherType).Value = flag;
if (flag)
{
item.GetData<IntItemData>(BridgeLauncherDataEntryKey.HandCannonBridgeFrame).Value = 1;
HandCannonAmmoCompat.SetChainIfEmpty(item);
}
PushItemInstanceData(item);
ManualLogSource log = BridgeLauncherPlugin.Log;
if (log != null)
{
log.LogInfo((object)(((Object)item).name + ": " + (flag ? "Bridge Launcher" : "Chain Launcher") + " (roll " + num.ToString("F2") + ", chance " + BridgeLauncherPlugin.BridgeLauncherChanceConfig.Value.ToString("F2") + ")."));
}
}
private static void PushItemInstanceData(Item item)
{
if ((Object)(object)item == (Object)null || item.data == null || !PhotonNetwork.InRoom)
{
return;
}
PhotonView val = null;
try
{
val = ((MonoBehaviourPun)item).photonView;
}
catch
{
}
if ((Object)(object)val == (Object)null)
{
val = ((Component)item).GetComponent<PhotonView>();
}
if ((Object)(object)val == (Object)null || (!val.IsMine && !PhotonNetwork.IsMasterClient))
{
return;
}
try
{
val.RPC("SetItemInstanceDataRPC", (RpcTarget)1, new object[1] { item.data });
}
catch (Exception ex)
{
if (BridgeLauncherPlugin.Log != null)
{
BridgeLauncherPlugin.Log.LogWarning((object)("SetItemInstanceDataRPC failed: " + ex.Message));
}
}
}
public static void PlaceAndBroadcast(Vector3 start, Vector3 end, float hang, Vector3 mid)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: 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_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected O, but got Unknown
BridgeBuild.Build(start, end, hang, mid);
Remember(start, end, hang, mid);
if (!PhotonNetwork.InRoom)
{
return;
}
try
{
PhotonNetwork.RaiseEvent((byte)150, (object)PackPlace(start, end, hang, mid), new RaiseEventOptions
{
Receivers = (ReceiverGroup)0
}, SendOptions.SendReliable);
}
catch (Exception ex)
{
Debug.LogWarning((object)("Bridge Launcher: RaiseEvent place failed: " + ex.Message));
}
}
public static void BroadcastAll()
{
//IL_0025: 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_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: 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_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Expected O, but got Unknown
if (!PhotonNetwork.InRoom || !PhotonNetwork.IsMasterClient)
{
return;
}
for (int i = 0; i < Placements.Count; i++)
{
BridgePlacement bridgePlacement = Placements[i];
try
{
PhotonNetwork.RaiseEvent((byte)150, (object)PackPlace(bridgePlacement.Start, bridgePlacement.End, bridgePlacement.Hang, bridgePlacement.Mid), new RaiseEventOptions
{
Receivers = (ReceiverGroup)0
}, SendOptions.SendReliable);
}
catch (Exception ex)
{
Debug.LogWarning((object)("Bridge Launcher: RaiseEvent snapshot failed: " + ex.Message));
}
}
}
private static void RequestSnapshot()
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: 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_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Expected O, but got Unknown
if (!PhotonNetwork.InRoom || PhotonNetwork.IsMasterClient)
{
return;
}
try
{
PhotonNetwork.RaiseEvent((byte)150, (object)new object[3]
{
"tony4twentys.Bridge_Launcher",
1,
(byte)1
}, new RaiseEventOptions
{
Receivers = (ReceiverGroup)2
}, SendOptions.SendReliable);
}
catch (Exception ex)
{
Debug.LogWarning((object)("Bridge Launcher: RaiseEvent request failed: " + ex.Message));
}
}
private static void HandleEvent(EventData photonEvent)
{
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: 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)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
if (photonEvent == null || photonEvent.Code != 150 || !(photonEvent.CustomData is object[] array) || array.Length < 3 || array[0] as string != "tony4twentys.Bridge_Launcher" || ToInt(array[1]) != 1)
{
return;
}
switch (ToByte(array[2]))
{
case 1:
if (PhotonNetwork.IsMasterClient)
{
BroadcastAll();
}
break;
case 0:
if (array.Length >= 13)
{
Vector3 start = new Vector3(ToFloat(array[3]), ToFloat(array[4]), ToFloat(array[5]));
Vector3 end = default(Vector3);
((Vector3)(ref end))..ctor(ToFloat(array[6]), ToFloat(array[7]), ToFloat(array[8]));
float hang = ToFloat(array[9]);
Vector3 mid = default(Vector3);
((Vector3)(ref mid))..ctor(ToFloat(array[10]), ToFloat(array[11]), ToFloat(array[12]));
Remember(start, end, hang, mid);
BridgeBuild.Build(start, end, hang, mid);
}
break;
}
}
private static object[] PackPlace(Vector3 start, Vector3 end, float hang, Vector3 mid)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
return new object[13]
{
"tony4twentys.Bridge_Launcher",
1,
(byte)0,
start.x,
start.y,
start.z,
end.x,
end.y,
end.z,
hang,
mid.x,
mid.y,
mid.z
};
}
private static void Remember(Vector3 start, Vector3 end, float hang, Vector3 mid)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: 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_0067: 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)
//IL_006f: 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_007f: Unknown result type (might be due to invalid IL or missing references)
string text = Key(start, end, hang);
for (int i = 0; i < Placements.Count; i++)
{
if (Key(Placements[i].Start, Placements[i].End, Placements[i].Hang) == text)
{
return;
}
}
BridgePlacement item = new BridgePlacement
{
Start = start,
End = end,
Hang = hang,
Mid = mid
};
Placements.Add(item);
}
internal static bool TryMarkBuilt(Vector3 start, Vector3 end, float hang)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return BuiltKeys.Add(Key(start, end, hang));
}
private static string Key(Vector3 start, Vector3 end, float hang)
{
return start.x.ToString("F1") + "," + start.y.ToString("F1") + "," + start.z.ToString("F1") + "|" + end.x.ToString("F1") + "," + end.y.ToString("F1") + "," + end.z.ToString("F1") + "|" + hang.ToString("F2");
}
private IEnumerator BroadcastAfterJoin()
{
yield return (object)new WaitForSeconds(0.5f);
BroadcastAll();
}
private static int ToInt(object value)
{
try
{
return Convert.ToInt32(value);
}
catch
{
return 0;
}
}
private static byte ToByte(object value)
{
try
{
return Convert.ToByte(value);
}
catch
{
return 0;
}
}
private static float ToFloat(object value)
{
try
{
return Convert.ToSingle(value);
}
catch
{
return 0f;
}
}
}
internal static class BridgeBuild
{
public static bool Build(Vector3 start, Vector3 end, float hang, Vector3 mid)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: 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_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: 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)
if (!BridgeNet.TryMarkBuilt(start, end, hang))
{
return false;
}
BreakableBridge val = FindBridgeSource();
if ((Object)(object)val == (Object)null)
{
if (BridgeLauncherPlugin.Log != null)
{
BridgeLauncherPlugin.Log.LogWarning((object)"No BreakableBridge in this scene. Airport/lobby has none; they live in level_* maps.");
}
return false;
}
JungleVine component = Object.Instantiate<GameObject>(((Component)val).gameObject, start, Quaternion.identity).GetComponent<JungleVine>();
if ((Object)(object)component == (Object)null)
{
Debug.LogError((object)"Bridge Launcher: Instantiated bridge had no JungleVine.");
return false;
}
BreakableBridge component2 = ((Component)component).GetComponent<BreakableBridge>();
if ((Object)(object)component2 != (Object)null)
{
Object.Destroy((Object)(object)component2);
}
Collider[] componentsInChildren = ((Component)component).GetComponentsInChildren<Collider>();
for (int i = 0; i < componentsInChildren.Length; i++)
{
Object.DestroyImmediate((Object)(object)componentsInChildren[i]);
}
component.ForceBuildVine(start, end, hang, mid);
AddChainAnchors(((Component)component).gameObject, start, end);
return true;
}
private static BreakableBridge FindBridgeSource()
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
BreakableBridge[] array = Resources.FindObjectsOfTypeAll<BreakableBridge>();
if (array == null || array.Length == 0)
{
return null;
}
foreach (BreakableBridge val in array)
{
if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).gameObject == (Object)null))
{
Scene scene = ((Component)val).gameObject.scene;
if (!((Scene)(ref scene)).IsValid())
{
return val;
}
}
}
return array[0];
}
private static void AddChainAnchors(GameObject bridgeObject, Vector3 from, Vector3 to)
{
//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_0020: 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_0029: 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)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: 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_0043: 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_0060: 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_006c: 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_007f: 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_008b: 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_0057: Unknown result type (might be due to invalid IL or missing references)
try
{
GameObject val = FindChainAnchorPrefab();
if ((Object)(object)val == (Object)null)
{
Debug.LogWarning((object)"Bridge Launcher: Could not find Chain Anchor prefab in resources");
return;
}
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;
Object.Instantiate<GameObject>(val, from + val3 * num, Quaternion.identity, bridgeObject.transform);
Object.Instantiate<GameObject>(val, from - val3 * num, Quaternion.identity, bridgeObject.transform);
}
catch (Exception ex)
{
Debug.LogError((object)("Bridge Launcher: Error adding chain anchors: " + ex));
}
}
private static GameObject FindChainAnchorPrefab()
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>();
foreach (GameObject val in array)
{
if ((Object)(object)val == (Object)null)
{
continue;
}
string name = ((Object)val).name;
if (name.IndexOf("Chain Anchor", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("ChainAnchor", StringComparison.OrdinalIgnoreCase) >= 0)
{
Scene scene = val.scene;
if (!((Scene)(ref scene)).IsValid())
{
return val;
}
}
}
foreach (GameObject val2 in array)
{
if (!((Object)(object)val2 == (Object)null))
{
string name2 = ((Object)val2).name;
if (name2.IndexOf("Chain Anchor", StringComparison.OrdinalIgnoreCase) >= 0 || name2.IndexOf("ChainAnchor", StringComparison.OrdinalIgnoreCase) >= 0)
{
return val2;
}
}
}
return null;
}
}
}