Decompiled source of GrizzCompany Items v1.0.4

GrizzCompany-Items.dll

Decompiled 5 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CSync.Extensions;
using CSync.Lib;
using GameNetcodeStuff;
using GrizzCompany-Items.NetcodePatcher;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("GrizzCompany-Items")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A Lethal Company mod")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f66ac33c25b4c39fbe70f8d26f66b5a68b5ca626")]
[assembly: AssemblyProduct("GrizzCompany-Items")]
[assembly: AssemblyTitle("GrizzCompany-Items")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
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;
		}
	}
}
namespace GrizzCompany.Items
{
	public static class Assets
	{
		public static class ScrapCannon
		{
			public const int price = 300;

			public static Item item { get; internal set; }

			public static void Load()
			{
				item = bundle.LoadAsset<Item>("ScrapCannon");
				NetworkPrefabs.RegisterNetworkPrefab(item.spawnPrefab);
				Items.RegisterShopItem(item, 300);
			}
		}

		public static AssetBundle bundle { get; internal set; }

		public static void Load()
		{
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			bundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "grizzcompany-items.bundle"));
			ScrapCannon.Load();
		}
	}
	public class Config : SyncedConfig2<Config>
	{
		[SyncedEntryField]
		public SyncedEntry<bool> ScrapCannonEnabled;

		[SyncedEntryField]
		public SyncedEntry<int> ScrapCannonPrice;

		[SyncedEntryField]
		public SyncedEntry<bool> ScrapCannonGuideLines;

		[SyncedEntryField]
		public SyncedEntry<bool> ScrapCannonHinderedMovement;

		public Config(ConfigFile cfg)
			: base("SylviBlossom.GrizzCompany-Items")
		{
			ScrapCannonEnabled = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "ScrapCannon", "Enabled", true, "Whether the Scrap cannon is added to the store.");
			ScrapCannonPrice = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, "ScrapCannon", "Price", -1, $"The cost of the Scrap cannon in the store. -1 means default (currently {300}).");
			ScrapCannonGuideLines = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "ScrapCannon", "ShowGuideLines", false, "Displays lines on the screen while holding the Scrap cannon indicating target angles (blue is ship, yellow is main entrance, red is fire exit).");
			ScrapCannonHinderedMovement = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "ScrapCannon", "HinderedMovement", false, "Prevents the player from jumping or sprinting while carrying the Scrap cannon.");
			ScrapCannonEnabled.Changed += delegate
			{
				UpdateScrapCannonShop();
			};
			ScrapCannonPrice.Changed += delegate
			{
				UpdateScrapCannonShop();
			};
			ScrapCannonHinderedMovement.Changed += delegate
			{
				UpdateScrapCannonHinderedMovement();
			};
			base.InitialSyncCompleted += delegate
			{
				UpdateValues();
			};
			ConfigManager.Register<Config>((SyncedConfig2<Config>)this);
		}

		public void UpdateValues()
		{
			UpdateScrapCannonShop();
			UpdateScrapCannonHinderedMovement();
		}

		private void UpdateScrapCannonShop()
		{
			ItemUtility.ToggleShopItem(Assets.ScrapCannon.item, ScrapCannonEnabled.Value);
			ItemUtility.UpdateShopPrice(Assets.ScrapCannon.item, ScrapCannonPrice.Value, 300);
		}

		private void UpdateScrapCannonHinderedMovement()
		{
			if (!((Object)(object)Assets.ScrapCannon.item == (Object)null))
			{
				Assets.ScrapCannon.item.weight = (ScrapCannonHinderedMovement.Value ? 1f : ScrapCannonItem.weight);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Terminal), "Awake")]
		private static void TerminalAwakePatch()
		{
			Plugin.Config.UpdateValues();
		}
	}
	public class ItemUtility
	{
		public static void UpdateShopPrice(Item item, int price, int defaultPrice)
		{
			if ((Object)(object)StartOfRound.Instance != (Object)null)
			{
				Items.UpdateShopItemPrice(item, price);
			}
			ShopItem val = ((IEnumerable<ShopItem>)Items.shopItems).FirstOrDefault((Func<ShopItem, bool>)((ShopItem x) => (Object)(object)x.origItem == (Object)(object)item || (Object)(object)x.item == (Object)(object)item));
			val.price = price;
			val.item.creditsWorth = ((price == -1) ? defaultPrice : price);
		}

		public static void ToggleShopItem(Item item, bool enabled)
		{
			//IL_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_035f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Expected O, but got Unknown
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03db: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Expected O, but got Unknown
			//IL_044c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0451: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Unknown result type (might be due to invalid IL or missing references)
			//IL_0466: Expected O, but got Unknown
			//IL_04fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0501: Unknown result type (might be due to invalid IL or missing references)
			//IL_0509: Unknown result type (might be due to invalid IL or missing references)
			//IL_0516: Expected O, but got Unknown
			//IL_0527: Unknown result type (might be due to invalid IL or missing references)
			//IL_0548: Unknown result type (might be due to invalid IL or missing references)
			//IL_054a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0551: Unknown result type (might be due to invalid IL or missing references)
			ShopItem shopItem = ((IEnumerable<ShopItem>)Items.shopItems).FirstOrDefault((Func<ShopItem, bool>)((ShopItem x) => (Object)(object)x.origItem == (Object)(object)item || (Object)(object)x.item == (Object)(object)item));
			bool wasRemoved = shopItem.wasRemoved;
			if (wasRemoved == !enabled)
			{
				return;
			}
			shopItem.wasRemoved = !enabled;
			if (!enabled)
			{
				Items.RemoveShopItem(item);
				Items.buyableItemAssetInfos.RemoveAll((BuyableItemAssetInfo x) => (Object)(object)x.itemAsset == (Object)(object)shopItem.item);
				return;
			}
			Terminal val = Object.FindObjectOfType<Terminal>();
			if (!((Object)(object)StartOfRound.Instance == (Object)null) && !((Object)(object)val == (Object)null))
			{
				List<Item> list = val.buyableItemsList.ToList();
				TerminalKeyword val2 = val.terminalNodes.allKeywords.First((TerminalKeyword keyword) => keyword.word == "buy");
				TerminalNode result = val2.compatibleNouns[0].result.terminalOptions[1].result;
				TerminalKeyword val3 = val.terminalNodes.allKeywords.First((TerminalKeyword keyword) => keyword.word == "info");
				if (shopItem.price == -1)
				{
					shopItem.price = shopItem.item.creditsWorth;
				}
				else
				{
					shopItem.item.creditsWorth = shopItem.price;
				}
				int num = -1;
				if (!list.Any((Item x) => (Object)(object)x == (Object)(object)shopItem.item))
				{
					list.Add(shopItem.item);
				}
				else
				{
					num = list.IndexOf(shopItem.item);
				}
				int buyItemIndex = ((num == -1) ? (list.Count - 1) : num);
				string itemName = shopItem.item.itemName;
				char c = itemName[itemName.Length - 1];
				string text = itemName;
				TerminalNode val4 = shopItem.buyNode2;
				if ((Object)(object)val4 == (Object)null)
				{
					val4 = ScriptableObject.CreateInstance<TerminalNode>();
					((Object)val4).name = itemName.Replace(" ", "-") + "BuyNode2";
					val4.displayText = "Ordered [variableAmount] " + text + ". Your new balance is [playerCredits].\n\nOur contractors enjoy fast, free shipping while on the job! Any purchased items will arrive hourly at your approximate location.\r\n\r\n";
					val4.clearPreviousText = true;
					val4.maxCharactersToType = 15;
				}
				val4.buyItemIndex = buyItemIndex;
				val4.isConfirmationNode = false;
				val4.itemCost = shopItem.price;
				val4.playSyncedClip = 0;
				TerminalNode val5 = shopItem.buyNode1;
				if ((Object)(object)val5 == (Object)null)
				{
					val5 = ScriptableObject.CreateInstance<TerminalNode>();
					((Object)val5).name = itemName.Replace(" ", "-") + "BuyNode1";
					val5.displayText = "You have requested to order " + text + ". Amount: [variableAmount].\nTotal cost of items: [totalCost].\n\nPlease CONFIRM or DENY.\r\n\r\n";
					val5.clearPreviousText = true;
					val5.maxCharactersToType = 35;
				}
				val5.buyItemIndex = buyItemIndex;
				val5.isConfirmationNode = true;
				val5.overrideOptions = true;
				val5.itemCost = shopItem.price;
				val5.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[2]
				{
					new CompatibleNoun
					{
						noun = val.terminalNodes.allKeywords.First((TerminalKeyword keyword2) => keyword2.word == "confirm"),
						result = val4
					},
					new CompatibleNoun
					{
						noun = val.terminalNodes.allKeywords.First((TerminalKeyword keyword2) => keyword2.word == "deny"),
						result = result
					}
				};
				TerminalKeyword val6 = TerminalUtils.CreateTerminalKeyword(itemName.ToLowerInvariant().Replace(" ", "-"), false, (CompatibleNoun[])null, (TerminalNode)null, val2, false);
				List<TerminalKeyword> list2 = val.terminalNodes.allKeywords.ToList();
				list2.Add(val6);
				val.terminalNodes.allKeywords = list2.ToArray();
				List<CompatibleNoun> list3 = val2.compatibleNouns.ToList();
				list3.Add(new CompatibleNoun
				{
					noun = val6,
					result = val5
				});
				val2.compatibleNouns = list3.ToArray();
				TerminalNode val7 = shopItem.itemInfo;
				if ((Object)(object)val7 == (Object)null)
				{
					val7 = ScriptableObject.CreateInstance<TerminalNode>();
					((Object)val7).name = itemName.Replace(" ", "-") + "InfoNode";
					val7.displayText = "[No information about this object was found.]\n\n";
					val7.clearPreviousText = true;
					val7.maxCharactersToType = 25;
				}
				val.terminalNodes.allKeywords = list2.ToArray();
				List<CompatibleNoun> list4 = val3.compatibleNouns.ToList();
				list4.Add(new CompatibleNoun
				{
					noun = val6,
					result = val7
				});
				val3.compatibleNouns = list4.ToArray();
				BuyableItemAssetInfo val8 = default(BuyableItemAssetInfo);
				val8.itemAsset = shopItem.item;
				val8.keyword = val6;
				BuyableItemAssetInfo item2 = val8;
				Items.buyableItemAssetInfos.Add(item2);
				val.buyableItemsList = list.ToArray();
			}
		}
	}
	[BepInPlugin("SylviBlossom.GrizzCompany-Items", "GrizzCompany-Items", "1.0.4")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string GUID = "SylviBlossom.GrizzCompany-Items";

		public const string NAME = "GrizzCompany-Items";

		public const string VERSION = "1.0.4";

		public static Plugin Instance { get; private set; }

		public static Config Config { get; private set; }

		public static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			Instance = this;
			Config = new Config(((BaseUnityPlugin)this).Config);
			Logger = ((BaseUnityPlugin)this).Logger;
			Harmony val = new Harmony("SylviBlossom.GrizzCompany-Items");
			val.PatchAll(typeof(Config));
			Assets.Load();
			InitializeModNetworking();
			Logger.LogInfo((object)"Plugin GrizzCompany-Items is loaded!");
		}

		private static void InitializeModNetworking()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	public class ScrapCannonItem : GrabbableObject
	{
		public static bool enableDebugLines = false;

		public static int maxEntranceCount = 4;

		public static float movementHinderance = 0.8f;

		public static float weight = 1.8f;

		public static float arcHeight = 30f;

		public static float launchSpeed = 30f;

		public static float launchDistance = 75f;

		public static float landingRadius = 8f;

		public static float landingRadiusShip = 6f;

		public static float landingRadiusEntrance = 3f;

		public static float landingRaycastUp = 50f;

		public static float landingRaycastUpShip = 5f;

		public static float landingRaycastUpEntrance = 20f;

		public static float landingRaycastDown = 100f;

		public static float navMeshCastDistance = 10f;

		public static float targetAngleSnap = 17.5f;

		public static float targetAngleSnapMinDistance = 20f;

		public InteractTrigger cannonTrigger;

		public Transform shootPoint;

		public AudioClip loadSFX;

		public AudioClip shootSFX;

		public LineRenderer[] debugLines;

		private Random cannonRandom = new Random();

		private bool interactWaiting;

		private bool hadHindered = false;

		public override void OnNetworkSpawn()
		{
			((NetworkBehaviour)this).OnNetworkSpawn();
			Plugin.Logger.LogInfo((object)"Scrap Cannon - Network spawned");
			cannonRandom = new Random(Mathf.Min(StartOfRound.Instance.randomMapSeed + (int)((NetworkBehaviour)this).NetworkObjectId, 99999999));
		}

		public override void GrabItem()
		{
			((GrabbableObject)this).GrabItem();
			cannonTrigger.interactable = false;
			cannonTrigger.disabledHoverTip = "";
			if ((Object)(object)base.playerHeldBy != (Object)null && Plugin.Config.ScrapCannonHinderedMovement.Value)
			{
				PlayerControllerB playerHeldBy = base.playerHeldBy;
				playerHeldBy.isMovementHindered++;
				PlayerControllerB playerHeldBy2 = base.playerHeldBy;
				playerHeldBy2.hinderedMultiplier *= movementHinderance;
				hadHindered = true;
			}
		}

		public override void DiscardItem()
		{
			if ((Object)(object)base.playerHeldBy != (Object)null && hadHindered)
			{
				base.playerHeldBy.isMovementHindered = Mathf.Clamp(base.playerHeldBy.isMovementHindered - 1, 0, 100);
				base.playerHeldBy.hinderedMultiplier = Mathf.Clamp(base.playerHeldBy.hinderedMultiplier / movementHinderance, 1f, 100f);
			}
			hadHindered = false;
			((GrabbableObject)this).DiscardItem();
		}

		public override void Update()
		{
			((GrabbableObject)this).Update();
			if ((Object)(object)GameNetworkManager.Instance == (Object)null || (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null)
			{
				return;
			}
			if ((Object)(object)base.playerHeldBy != (Object)null && ((NetworkBehaviour)this).IsOwner && Plugin.Config.ScrapCannonGuideLines.Value)
			{
				DrawDebugLines();
			}
			else
			{
				LineRenderer[] array = debugLines;
				foreach (LineRenderer val in array)
				{
					((Renderer)val).enabled = false;
				}
			}
			if (!((Object)(object)base.playerHeldBy != (Object)null))
			{
				if (base.isInShipRoom || base.isInFactory || StartOfRound.Instance.inShipPhase)
				{
					cannonTrigger.disabledHoverTip = "Cannot use indoors";
					cannonTrigger.interactable = false;
				}
				else
				{
					cannonTrigger.hoverTip = "Launch item : [" + (StartOfRound.Instance.localPlayerUsingController ? "R-trigger" : "LMB") + "]";
					cannonTrigger.disabledHoverTip = "Hold item to launch";
					cannonTrigger.interactable = !interactWaiting && (Object)(object)GameNetworkManager.Instance.localPlayerController.currentlyHeldObjectServer != (Object)null;
				}
			}
		}

		private void DrawDebugLines()
		{
			if (base.isInShipRoom || base.isInFactory || StartOfRound.Instance.inShipPhase)
			{
				LineRenderer[] array = debugLines;
				foreach (LineRenderer val in array)
				{
					((Renderer)val).enabled = false;
				}
				return;
			}
			Transform elevatorTransform = StartOfRound.Instance.elevatorTransform;
			Transform targetPos = elevatorTransform.Find("PositionNodes/DoorPos");
			DrawDebugLine(debugLines[0], targetPos);
			EntranceTeleport[] entranceTeleports = GetEntranceTeleports();
			for (int j = 0; j < entranceTeleports.Length; j++)
			{
				if ((Object)(object)entranceTeleports[j] == (Object)null)
				{
					((Renderer)debugLines[j + 1]).enabled = false;
				}
				else
				{
					DrawDebugLine(debugLines[j + 1], entranceTeleports[j].entrancePoint);
				}
			}
		}

		private void DrawDebugLine(LineRenderer debugLine, Transform targetPos)
		{
			//IL_0009: 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_0030: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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_0098: 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)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: 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_00b1: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(shootPoint.position.x, 0f, shootPoint.position.z);
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(targetPos.position.x, 0f, targetPos.position.z);
			float num = Vector3.Distance(val, val2);
			if (num < targetAngleSnapMinDistance)
			{
				((Renderer)debugLine).enabled = false;
				return;
			}
			((Renderer)debugLine).enabled = true;
			Vector3 val3 = new Vector3(shootPoint.forward.x, 0f, shootPoint.forward.z);
			Vector3 normalized = ((Vector3)(ref val3)).normalized;
			Quaternion val4 = Quaternion.FromToRotation(normalized, val2 - val);
			float y = ((Quaternion)(ref val4)).eulerAngles.y;
			debugLine.SetPosition(0, new Vector3(Mathf.Sin((y - targetAngleSnap) * (MathF.PI / 180f)) * 3f, 0f, Mathf.Cos((y - targetAngleSnap) * (MathF.PI / 180f)) * 3f));
			debugLine.SetPosition(1, new Vector3(Mathf.Sin((y + targetAngleSnap) * (MathF.PI / 180f)) * 3f, 0f, Mathf.Cos((y + targetAngleSnap) * (MathF.PI / 180f)) * 3f));
		}

		private EntranceTeleport[] GetEntranceTeleports()
		{
			EntranceTeleport[] array = (EntranceTeleport[])(object)new EntranceTeleport[maxEntranceCount];
			EntranceTeleport[] array2 = Object.FindObjectsOfType<EntranceTeleport>();
			foreach (EntranceTeleport val in array2)
			{
				if (val.isEntranceToBuilding && val.entranceId < array.Length)
				{
					array[val.entranceId] = val;
				}
			}
			return array;
		}

		public void CannonInteract(PlayerControllerB player)
		{
			//IL_003d: 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)
			if (interactWaiting || (Object)(object)player.currentlyHeldObjectServer == (Object)null)
			{
				return;
			}
			Transform elevatorTransform = StartOfRound.Instance.elevatorTransform;
			Transform val = elevatorTransform.Find("PositionNodes/DoorPos");
			if (CanSnap(val.position, out var accuracy, "Ship"))
			{
				ShootItemToShip(player, val, accuracy);
				return;
			}
			EntranceTeleport[] entranceTeleports = GetEntranceTeleports();
			foreach (EntranceTeleport val2 in entranceTeleports)
			{
				if ((Object)(object)val2 != (Object)null && CanSnap(val2.entrancePoint.position, out var _, $"Entrance {val2.entranceId}"))
				{
					ShootItemToEntrance(player, val2);
					return;
				}
			}
			ShootItemForwards(player, val);
		}

		private bool CanSnap(Vector3 targetPos, out float accuracy, string name = null)
		{
			//IL_0010: 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_0036: 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_004c: 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_0071: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: 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_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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: 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)
			accuracy = 0f;
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(shootPoint.position.x, 0f, shootPoint.position.z);
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(targetPos.x, 0f, targetPos.z);
			float num = Vector3.Distance(val, val2);
			if (num < targetAngleSnapMinDistance)
			{
				return false;
			}
			Vector3 val3 = new Vector3(shootPoint.forward.x, 0f, shootPoint.forward.z);
			Vector3 normalized = ((Vector3)(ref val3)).normalized;
			Quaternion val4 = Quaternion.FromToRotation(normalized, val2 - val);
			float y = ((Quaternion)(ref val4)).eulerAngles.y;
			if (name != null)
			{
				Plugin.Logger.LogInfo((object)$"Scrap Cannon - Angle to {name}: {Mathf.DeltaAngle(0f, y)}");
			}
			float num2 = Mathf.DeltaAngle(0f, y);
			accuracy = num2 / targetAngleSnap;
			return Mathf.Abs(num2) < targetAngleSnap;
		}

		private void ShootItemToEntrance(PlayerControllerB player, EntranceTeleport entrance)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: 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_0087: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: 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_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: 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_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			Plugin.Logger.LogInfo((object)$"Scrap Cannon - Shooting to entrace {entrance.entranceId}");
			GrabbableObject currentlyHeldObjectServer = player.currentlyHeldObjectServer;
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(((Component)entrance).transform.position.x, 0f, ((Component)entrance).transform.position.z);
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(entrance.entrancePoint.position.x, 0f, entrance.entrancePoint.position.z);
			Vector3 val3 = val2 - val;
			Vector3 normalized = ((Vector3)(ref val3)).normalized;
			float num = (float)(cannonRandom.NextDouble() * (double)landingRadiusEntrance);
			float num2 = (float)(cannonRandom.NextDouble() * 6.2831854820251465);
			Vector3 val4 = val2 + normalized * landingRadiusEntrance + new Vector3(Mathf.Sin(num2), 0f, Mathf.Cos(num2)) * num;
			Vector3 val5 = val4 + entrance.entrancePoint.position.y * Vector3.up;
			NavMeshHit val6 = default(NavMeshHit);
			if (NavMesh.SamplePosition(val5, ref val6, navMeshCastDistance, -1))
			{
				Vector3 itemFloorPosition = currentlyHeldObjectServer.GetItemFloorPosition(((NavMeshHit)(ref val6)).position + Vector3.up);
				ShootItem(player, itemFloorPosition);
				return;
			}
			Vector3 val7 = val5 + landingRaycastUpEntrance * Vector3.up;
			RaycastHit val8 = default(RaycastHit);
			if (Physics.Raycast(val7, -Vector3.up, ref val8, landingRaycastUpEntrance + landingRaycastDown, 268437761, (QueryTriggerInteraction)1))
			{
				Vector3 itemFloorPosition2 = currentlyHeldObjectServer.GetItemFloorPosition(((RaycastHit)(ref val8)).point + Vector3.up);
				ShootItem(player, itemFloorPosition2);
			}
			else
			{
				ShootItem(player, val5);
			}
		}

		private void ShootItemToShip(PlayerControllerB player, Transform shipDoorPos, float accuracy)
		{
			//IL_001e: 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_0029: 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_003e: 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_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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: 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_00db: 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)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			Plugin.Logger.LogInfo((object)"Scrap Cannon - Shooting to ship");
			GrabbableObject currentlyHeldObjectServer = player.currentlyHeldObjectServer;
			Vector3 val = ((Component)shipDoorPos).transform.position + -shipDoorPos.right * (1f + landingRadiusShip) - ((Component)shipDoorPos).transform.localPosition.y * Vector3.up + -shipDoorPos.forward * accuracy * 5f;
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(val.x, 0f, val.z);
			float num = (float)(cannonRandom.NextDouble() * (double)landingRadiusShip);
			float num2 = (float)(cannonRandom.NextDouble() * 6.2831854820251465);
			Vector3 val3 = val2 + new Vector3(Mathf.Sin(num2), 0f, Mathf.Cos(num2)) * num;
			Vector3 val4 = val3 + (val.y + landingRaycastUpShip) * Vector3.up;
			RaycastHit val5 = default(RaycastHit);
			if (Physics.Raycast(val4, -Vector3.up, ref val5, landingRaycastUpShip + landingRaycastDown, 268437761, (QueryTriggerInteraction)1))
			{
				Vector3 itemFloorPosition = currentlyHeldObjectServer.GetItemFloorPosition(((RaycastHit)(ref val5)).point + Vector3.up);
				ShootItem(player, itemFloorPosition);
			}
			else
			{
				Vector3 landingPosition = val3 + val.y * Vector3.up;
				ShootItem(player, landingPosition);
			}
		}

		private void ShootItemForwards(PlayerControllerB player, Transform shipDoorPos = null)
		{
			//IL_0020: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: 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_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: 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_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: 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_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: 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_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			Plugin.Logger.LogInfo((object)"Scrap Cannon - Shooting forwards (untargeted)");
			GrabbableObject currentlyHeldObjectServer = player.currentlyHeldObjectServer;
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(shootPoint.position.x, 0f, shootPoint.position.z);
			Vector3 val2 = new Vector3(shootPoint.forward.x, 0f, shootPoint.forward.z);
			Vector3 normalized = ((Vector3)(ref val2)).normalized;
			float num = (float)(cannonRandom.NextDouble() * (double)landingRadius);
			float num2 = (float)(cannonRandom.NextDouble() * 6.2831854820251465);
			float num3 = launchDistance;
			if ((Object)(object)shipDoorPos != (Object)null)
			{
				Vector3 val3 = default(Vector3);
				((Vector3)(ref val3))..ctor(shipDoorPos.position.x, 0f, shipDoorPos.position.y);
				Quaternion val4 = Quaternion.FromToRotation(normalized, val3 - val);
				float y = ((Quaternion)(ref val4)).eulerAngles.y;
				if (Mathf.DeltaAngle(0f, y) < 90f)
				{
					num3 = Mathf.Max(num3, Vector3.Distance(val3, val));
				}
			}
			Vector3 val5 = val + normalized * num3 + new Vector3(Mathf.Sin(num2), 0f, Mathf.Cos(num2)) * num;
			Vector3 val6 = val5 + (((Component)this).transform.position.y + landingRaycastUp) * Vector3.up;
			RaycastHit val7 = default(RaycastHit);
			if (Physics.Raycast(val6, -Vector3.up, ref val7, landingRaycastUp + landingRaycastDown, 268437761, (QueryTriggerInteraction)1))
			{
				Vector3 itemFloorPosition = currentlyHeldObjectServer.GetItemFloorPosition(((RaycastHit)(ref val7)).point + Vector3.up);
				ShootItem(player, itemFloorPosition);
			}
			else
			{
				Vector3 landingPosition = val5 + ((Component)this).transform.position.y * Vector3.up;
				ShootItem(player, landingPosition);
			}
		}

		public void ShootItem(PlayerControllerB player, Vector3 landingPosition)
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			GrabbableObject currentlyHeldObjectServer = player.currentlyHeldObjectServer;
			player.SetSpecialGrabAnimationBool(false, currentlyHeldObjectServer);
			player.playerBodyAnimator.SetBool("cancelHolding", true);
			player.playerBodyAnimator.SetTrigger("Throw");
			((Behaviour)HUDManager.Instance.itemSlotIcons[player.currentItemSlot]).enabled = false;
			((Behaviour)HUDManager.Instance.holdingTwoHandedItem).enabled = false;
			Vector3 val = StartOfRound.Instance.propsContainer.InverseTransformPoint(((Component)this).transform.position + 0.75f * Vector3.up);
			player.PlaceGrabbableObject(StartOfRound.Instance.propsContainer, val, false, currentlyHeldObjectServer);
			currentlyHeldObjectServer.DiscardItemOnClient();
			currentlyHeldObjectServer.fallTime = 1.1f;
			currentlyHeldObjectServer.hasHitGround = true;
			currentlyHeldObjectServer.EnablePhysics(false);
			currentlyHeldObjectServer.EnableItemMeshes(false);
			cannonTrigger.interactable = false;
			interactWaiting = true;
			if ((Object)(object)loadSFX != (Object)null)
			{
				((Component)this).gameObject.GetComponent<AudioSource>().PlayOneShot(loadSFX);
			}
			ShootItemServerRPC((int)player.playerClientId, NetworkObjectReference.op_Implicit(((Component)currentlyHeldObjectServer).gameObject.GetComponent<NetworkObject>()), landingPosition);
		}

		[ServerRpc(RequireOwnership = false)]
		public void ShootItemServerRPC(int playerId, NetworkObjectReference heldObjectRef, Vector3 landingPosition)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3084094767u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerId);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref heldObjectRef, default(ForNetworkSerializable));
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref landingPosition);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3084094767u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				NetworkObject val3 = default(NetworkObject);
				if (!((NetworkObjectReference)(ref heldObjectRef)).TryGet(ref val3, (NetworkManager)null))
				{
					Plugin.Logger.LogError((object)$"Scrap Cannon - ShootItemServerRPC - Held object could not be found: {((NetworkObjectReference)(ref heldObjectRef)).NetworkObjectId}");
				}
				else
				{
					ShootItemClientRPC(playerId, heldObjectRef, landingPosition);
				}
			}
		}

		[ClientRpc]
		public void ShootItemClientRPC(int playerId, NetworkObjectReference heldObjectRef, Vector3 landingPosition)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1515908471u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerId);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref heldObjectRef, default(ForNetworkSerializable));
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref landingPosition);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1515908471u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			PlayerControllerB val3 = StartOfRound.Instance.allPlayerScripts[playerId];
			if ((Object)(object)val3 == (Object)null)
			{
				Plugin.Logger.LogError((object)$"Scrap Cannon - ShootItemClientRPC - Player could not be found: {playerId}");
				return;
			}
			NetworkObject val4 = default(NetworkObject);
			if (!((NetworkObjectReference)(ref heldObjectRef)).TryGet(ref val4, (NetworkManager)null))
			{
				Plugin.Logger.LogError((object)$"Scrap Cannon - ShootItemClientRPC - Held object could not be found: {((NetworkObjectReference)(ref heldObjectRef)).NetworkObjectId}");
				return;
			}
			GrabbableObject component = ((Component)val4).GetComponent<GrabbableObject>();
			if (!((NetworkBehaviour)val3).IsOwner)
			{
				Vector3 val5 = StartOfRound.Instance.propsContainer.InverseTransformPoint(((Component)this).transform.position + 0.75f * Vector3.up);
				val3.PlaceGrabbableObject(StartOfRound.Instance.propsContainer, val5, false, component);
				component.fallTime = 1.1f;
				component.hasHitGround = true;
				component.EnablePhysics(false);
				component.EnableItemMeshes(false);
				if ((Object)(object)loadSFX != (Object)null)
				{
					((Component)this).gameObject.GetComponent<AudioSource>().PlayOneShot(loadSFX);
				}
				cannonRandom.NextDouble();
				cannonRandom.NextDouble();
			}
			if (!component.itemProperties.syncDiscardFunction)
			{
				component.playerHeldBy = null;
			}
			if ((Object)(object)val3.currentlyHeldObjectServer == (Object)(object)component)
			{
				val3.currentlyHeldObjectServer = null;
			}
			else
			{
				ManualLogSource logger = Plugin.Logger;
				GrabbableObject currentlyHeldObjectServer = val3.currentlyHeldObjectServer;
				logger.LogError((object)string.Format("Scrap Cannon - ShootItemClientRPC - Held object mismatch (found {0}) on player {1}", ((currentlyHeldObjectServer != null) ? ((Object)((Component)currentlyHeldObjectServer).gameObject).name : null) ?? "null", playerId));
			}
			if (((NetworkBehaviour)val3).IsOwner)
			{
				val3.throwingObject = false;
				((Behaviour)HUDManager.Instance.itemSlotIcons[val3.currentItemSlot]).enabled = false;
			}
			interactWaiting = false;
			((MonoBehaviour)this).StartCoroutine(ShootItemRoutine(component, landingPosition));
		}

		private IEnumerator ShootItemRoutine(GrabbableObject heldObject, Vector3 landingPosition)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			Plugin.Logger.LogInfo((object)$"Scrap Cannon - Scrap landing at {landingPosition}");
			yield return (object)new WaitForSeconds(0.5f);
			if ((Object)(object)shootSFX != (Object)null)
			{
				((Component)this).gameObject.GetComponent<AudioSource>().PlayOneShot(shootSFX);
			}
			heldObject.EnableItemMeshes(true);
			float launchTotalDistance = Vector3.Distance(shootPoint.position, landingPosition);
			float launchProgress = 0f;
			while (launchProgress < launchTotalDistance)
			{
				Vector3 currentPosition = SampleParabola(shootPoint.position, landingPosition, arcHeight, launchProgress / launchTotalDistance);
				Vector3 localPosition = (heldObject.targetFloorPosition = (heldObject.startFallingPosition = StartOfRound.Instance.propsContainer.InverseTransformPoint(currentPosition)));
				((Component)heldObject).transform.localPosition = localPosition;
				launchProgress += launchSpeed * Time.deltaTime;
				yield return null;
			}
			Vector3 finalLocalPosition = StartOfRound.Instance.propsContainer.InverseTransformPoint(landingPosition);
			heldObject.EnablePhysics(true);
			heldObject.startFallingPosition = finalLocalPosition;
			heldObject.targetFloorPosition = finalLocalPosition;
			((Component)heldObject).transform.localPosition = finalLocalPosition;
			heldObject.hasHitGround = false;
			heldObject.fallTime = 0f;
			yield return (object)new WaitForSeconds(1f);
			RagdollGrabbableObject ragdollObject = (RagdollGrabbableObject)(object)((heldObject is RagdollGrabbableObject) ? heldObject : null);
			if (ragdollObject != null)
			{
				ragdollObject.hasBeenPlaced = false;
			}
		}

		private Vector3 SampleParabola(Vector3 start, Vector3 end, float height, float t)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_006c: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_009a: 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_00a1: 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_00a9: 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_0030: 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_0036: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: 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)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			float num = t * 2f - 1f;
			if (Mathf.Abs(start.y - end.y) < 0.1f)
			{
				Vector3 val = end - start;
				Vector3 result = start + t * val;
				result.y += ((0f - num) * num + 1f) * height;
				return result;
			}
			Vector3 val2 = end - start;
			Vector3 val3 = end - new Vector3(start.x, end.y, start.z);
			Vector3 val4 = Vector3.Cross(val2, val3);
			Vector3 val5 = Vector3.Cross(val4, val2);
			if (end.y > start.y)
			{
				val5 = -val5;
			}
			Vector3 val6 = start + t * val2;
			return val6 + ((0f - num) * num + 1f) * height * ((Vector3)(ref val5)).normalized;
		}

		protected override void __initializeVariables()
		{
			((GrabbableObject)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_ScrapCannonItem()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(3084094767u, new RpcReceiveHandler(__rpc_handler_3084094767));
			NetworkManager.__rpc_func_table.Add(1515908471u, new RpcReceiveHandler(__rpc_handler_1515908471));
		}

		private static void __rpc_handler_3084094767(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0042: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int playerId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
				NetworkObjectReference heldObjectRef = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref heldObjectRef, default(ForNetworkSerializable));
				Vector3 landingPosition = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref landingPosition);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ScrapCannonItem)(object)target).ShootItemServerRPC(playerId, heldObjectRef, landingPosition);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1515908471(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0042: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int playerId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
				NetworkObjectReference heldObjectRef = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref heldObjectRef, default(ForNetworkSerializable));
				Vector3 landingPosition = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref landingPosition);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ScrapCannonItem)(object)target).ShootItemClientRPC(playerId, heldObjectRef, landingPosition);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "ScrapCannonItem";
		}
	}
}
namespace GrizzCompany-Items.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}