Decompiled source of MoreScrapItems v0.1.0

BepInEx/plugins/MoreScrapItems/MoreScrapItems.dll

Decompiled 20 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using On;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("danielsitek")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+06bd600794e47aa5eab95f27689ddc85a1e5fe49")]
[assembly: AssemblyProduct("MoreScrapItems")]
[assembly: AssemblyTitle("MoreScrapItems")]
[assembly: AssemblyVersion("0.1.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Dan.MoreScrapItems
{
	public sealed class FramePresentation : MonoBehaviour
	{
		[SerializeField]
		private PhysicsProp prop;

		[SerializeField]
		private MeshFilter filter;

		[SerializeField]
		private Mesh heldMesh;

		[SerializeField]
		private Mesh placedMesh;

		[SerializeField]
		private BoxCollider bodyCollider;

		[SerializeField]
		private BoxCollider scanCollider;

		[SerializeField]
		private Bounds heldBounds;

		[SerializeField]
		private Bounds placedBounds;

		private bool initialized;

		private bool showingHeld;

		public bool ShowingHeld => showingHeld;

		public void Configure(PhysicsProp owner, MeshFilter visual, GameObject held, GameObject placed, BoxCollider collider, BoxCollider scanner)
		{
			//IL_0052: 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_0062: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			prop = owner;
			filter = visual;
			heldMesh = held.GetComponentInChildren<MeshFilter>().sharedMesh;
			placedMesh = placed.GetComponentInChildren<MeshFilter>().sharedMesh;
			bodyCollider = collider;
			scanCollider = scanner;
			BoxCollider component = held.GetComponent<BoxCollider>();
			BoxCollider component2 = placed.GetComponent<BoxCollider>();
			heldBounds = new Bounds(component.center, component.size);
			placedBounds = new Bounds(component2.center, component2.size);
			Refresh();
		}

		private void LateUpdate()
		{
			Refresh();
		}

		private void Refresh()
		{
			//IL_008e: 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_0093: 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_00ae: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)prop == (Object)null) && !((Object)(object)filter == (Object)null))
			{
				bool flag = ((GrabbableObject)prop).isHeld || ((GrabbableObject)prop).isPocketed || ((GrabbableObject)prop).isHeldByEnemy;
				if (!initialized || flag != showingHeld)
				{
					initialized = true;
					showingHeld = flag;
					filter.sharedMesh = (flag ? heldMesh : placedMesh);
					Bounds val = (flag ? heldBounds : placedBounds);
					bodyCollider.center = ((Bounds)(ref val)).center;
					bodyCollider.size = ((Bounds)(ref val)).size;
					((Component)scanCollider).transform.localPosition = ((Bounds)(ref val)).center;
					scanCollider.size = ((Bounds)(ref val)).size;
				}
			}
		}
	}
	[BepInPlugin("danielsitek.more-scrap-items", "More Scrap Items", "0.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string Guid = "danielsitek.more-scrap-items";

		public const string Name = "More Scrap Items";

		public const string Version = "0.1.0";

		private AssetBundle? assets;

		private readonly List<Item> registered = new List<Item>();

		private ConfigEntry<bool>? testSpawn;

		private ConfigEntry<bool>? testHolding;

		private ConfigEntry<string>? holdingTestItem;

		private readonly Dictionary<string, (ConfigEntry<Vector3> position, ConfigEntry<Vector3> rotation)> poses = new Dictionary<string, (ConfigEntry<Vector3>, ConfigEntry<Vector3>)>();

		private bool testSpawnDone;

		private void Awake()
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Expected O, but got Unknown
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Expected O, but got Unknown
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Expected O, but got Unknown
			testSpawn = ((BaseUnityPlugin)this).Config.Bind<bool>("Development", "SpawnInShipForTesting", false, "Host only: spawn one of each item near the player once per game launch, for local testing.");
			testHolding = ((BaseUnityPlugin)this).Config.Bind<bool>("Development", "RunHoldingTest", false, "Local development only: use the game's normal grab and discard routines to inspect all items. Requires SpawnInShipForTesting.");
			holdingTestItem = ((BaseUnityPlugin)this).Config.Bind<string>("Development", "HoldingTestItem", "", "Optional item ID to limit the holding test to one item.");
			ConfigEntry<int> val = ((BaseUnityPlugin)this).Config.Bind<int>("Spawn", "QuotaMugRarity", 25, new ConfigDescription("Relative spawn weight on all moons. Set 0 to disable.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), Array.Empty<object>()));
			ConfigEntry<int> val2 = ((BaseUnityPlugin)this).Config.Bind<int>("Spawn", "MoonFrameRarity", 18, new ConfigDescription("Relative spawn weight on all moons. Set 0 to disable.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), Array.Empty<object>()));
			ConfigEntry<int> val3 = ((BaseUnityPlugin)this).Config.Bind<int>("Spawn", "Ringhoffer240Rarity", 12, new ConfigDescription("Relative spawn weight on all moons. Set 0 to disable.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), Array.Empty<object>()));
			string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "morescrapassets");
			assets = AssetBundle.LoadFromFile(text);
			if ((Object)(object)assets == (Object)null)
			{
				throw new InvalidOperationException("Cannot load More Scrap Items asset bundle: " + text);
			}
			Register("QuotaMug", "Quota mug", 71001, 50, 110, 1.03f, val.Value);
			Register("MoonFrame", "Sírius frame", 71002, 90, 180, 1.06f, val2.Value);
			Register("Ringhoffer240", "Ringhoffer 240 tram", 71003, 110, 220, 1.08f, val3.Value);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"More Scrap Items 0.1.0: Quota mug, Sírius frame and Ringhoffer 240 tram registered.");
			if (testSpawn.Value)
			{
				StartOfRound.Start += new hook_Start(StartRoundForTesting);
			}
		}

		private void Register(string id, string title, int itemId, int min, int max, float weight, int rarity)
		{
			//IL_00d6: 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_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_0443: Unknown result type (might be due to invalid IL or missing references)
			//IL_0448: Unknown result type (might be due to invalid IL or missing references)
			//IL_045a: Unknown result type (might be due to invalid IL or missing references)
			//IL_046a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0472: Unknown result type (might be due to invalid IL or missing references)
			//IL_047c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0488: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0506: Unknown result type (might be due to invalid IL or missing references)
			//IL_0518: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = assets.LoadAsset<GameObject>("Assets/MoreScrapItems/Prefabs/" + id + ".prefab");
			if ((Object)(object)val == (Object)null)
			{
				throw new InvalidOperationException("Missing model: " + id);
			}
			GameObject val2 = NetworkPrefabs.CreateNetworkPrefab("danielsitek.more-scrap-items." + id);
			Object.DontDestroyOnLoad((Object)(object)((Component)val2.transform.root).gameObject);
			val2.tag = "PhysicsProp";
			val2.layer = LayerMask.NameToLayer("Props");
			GameObject val3 = Object.Instantiate<GameObject>(val, val2.transform);
			((Object)val3).name = "Model";
			MeshRenderer[] componentsInChildren = val3.GetComponentsInChildren<MeshRenderer>(true);
			MeshRenderer[] array = componentsInChildren;
			for (int i = 0; i < array.Length; i++)
			{
				((Component)array[i]).gameObject.layer = val2.layer;
			}
			BoxCollider component = val3.GetComponent<BoxCollider>();
			BoxCollider val4 = val2.AddComponent<BoxCollider>();
			val4.center = component.center;
			val4.size = component.size;
			Object.DestroyImmediate((Object)(object)component);
			Rigidbody val5 = val2.AddComponent<Rigidbody>();
			val5.isKinematic = true;
			val5.useGravity = false;
			AudioSource obj = val2.AddComponent<AudioSource>();
			obj.playOnAwake = false;
			obj.spatialBlend = 1f;
			obj.volume = 0.35f;
			obj.minDistance = 1f;
			obj.maxDistance = 12f;
			Item val6 = ScriptableObject.CreateInstance<Item>();
			((Object)val6).name = id;
			val6.itemName = title;
			val6.itemId = itemId;
			val6.isScrap = true;
			val6.minValue = min;
			val6.maxValue = max;
			val6.weight = weight;
			val6.requiresBattery = false;
			val6.canBeGrabbedBeforeGameStart = true;
			val6.isConductiveMetal = id == "QuotaMug";
			val6.spawnPositionTypes = new List<ItemGroup>();
			val6.toolTips = Array.Empty<string>();
			val6.meshVariants = Array.Empty<Mesh>();
			val6.materialVariants = Array.Empty<Material>();
			val6.clinkAudios = Array.Empty<AudioClip>();
			val6.pocketSFX = (val6.dropSFX = (val6.grabSFX = MakeSound(id, (id == "QuotaMug") ? 1700f : 650f)));
			val6.restingRotation = Vector3.zero;
			val6.verticalOffset = val4.size.y / 2f;
			Item val7 = val6;
			Vector3 positionOffset = ((id == "QuotaMug") ? new Vector3(0.015f, 0.22f, -0.02f) : ((!(id == "Ringhoffer240")) ? new Vector3(0.18f, 0.24f, 0f) : new Vector3(-0.05f, 0.2f, -0.1f)));
			val7.positionOffset = positionOffset;
			val6.rotationOffset = new Vector3(0f, 180f, 90f);
			ConfigEntry<Vector3> val8 = ((BaseUnityPlugin)this).Config.Bind<Vector3>("Holding", id + "Position", val6.positionOffset, "Position relative to the game's hand anchor, in metres.");
			ConfigEntry<Vector3> val9 = ((BaseUnityPlugin)this).Config.Bind<Vector3>("Holding", id + "Rotation", val6.rotationOffset, "Rotation relative to the game's hand anchor, in degrees.");
			poses[id] = (val8, val9);
			val6.positionOffset = val8.Value;
			val6.rotationOffset = val9.Value;
			val6.itemIcon = assets.LoadAsset<Sprite>("Assets/MoreScrapItems/Models/" + id + "Icon.png");
			if (id == "Ringhoffer240")
			{
				AudioClip val10 = assets.LoadAsset<AudioClip>("Assets/MoreScrapItems/Audio/Ringhoffer240Bell.wav");
				if ((Object)(object)val10 == (Object)null)
				{
					throw new InvalidOperationException("Missing Ringhoffer240 bell; update DLL and asset bundle together.");
				}
				val6.dropSFX = val10;
				val6.clinkAudios = (AudioClip[])(object)new AudioClip[1] { val10 };
				val6.verticalOffset = val4.size.y / 2f - val4.center.y - 0.04f;
			}
			val6.spawnPrefab = val2;
			PhysicsProp val11 = val2.AddComponent<PhysicsProp>();
			((GrabbableObject)val11).itemProperties = val6;
			((GrabbableObject)val11).grabbable = true;
			((GrabbableObject)val11).grabbableToEnemies = true;
			((GrabbableObject)val11).propBody = val5;
			((GrabbableObject)val11).propColliders = (Collider[])(object)new Collider[1] { (Collider)val4 };
			((GrabbableObject)val11).mainObjectRenderer = componentsInChildren[0];
			GameObject val12 = new GameObject("ScanNode");
			val12.transform.SetParent(val2.transform, false);
			val12.layer = LayerMask.NameToLayer("ScanNode");
			val12.transform.localPosition = val4.center;
			BoxCollider val13 = val12.AddComponent<BoxCollider>();
			val13.size = val4.size;
			ScanNodeProperties obj2 = val12.AddComponent<ScanNodeProperties>();
			obj2.headerText = title;
			obj2.subText = "Value: $0";
			obj2.nodeType = 2;
			obj2.maxRange = 13;
			obj2.minRange = 1;
			obj2.requiresLineOfSight = true;
			if (id == "MoonFrame")
			{
				GameObject val14 = assets.LoadAsset<GameObject>("Assets/MoreScrapItems/Prefabs/MoonFramePlaced.prefab");
				if ((Object)(object)val14 == (Object)null)
				{
					throw new InvalidOperationException("Missing placed frame model; update DLL and asset bundle together.");
				}
				BoxCollider component2 = val14.GetComponent<BoxCollider>();
				val6.verticalOffset = component2.size.y / 2f - component2.center.y - 0.04f;
				val2.AddComponent<FramePresentation>().Configure(val11, val3.GetComponentInChildren<MeshFilter>(), val, val14, val4, val13);
			}
			Utilities.FixMixerGroups(val2);
			Items.RegisterScrap(val6, rarity, (LevelTypes)(-1));
			registered.Add(val6);
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"Registered {val6.itemName}; value {val6.minValue}-{val6.maxValue}; rarity {rarity}.");
		}

		private void StartRoundForTesting(orig_Start original, StartOfRound round)
		{
			original.Invoke(round);
			if (!testSpawnDone)
			{
				((MonoBehaviour)round).StartCoroutine(SpawnForTesting());
			}
		}

		private IEnumerator SpawnForTesting()
		{
			yield return (object)new WaitForSeconds(3f);
			PlayerControllerB playerController = GameNetworkManager.Instance?.localPlayerController;
			if ((Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsHost || (Object)(object)playerController == (Object)null)
			{
				yield break;
			}
			testSpawnDone = true;
			List<PhysicsProp> spawned = new List<PhysicsProp>();
			for (int i = 0; i < registered.Count; i++)
			{
				Transform transform = ((Component)playerController).transform;
				GameObject val = Object.Instantiate<GameObject>(registered[i].spawnPrefab, transform.position + transform.forward * 1.5f + transform.right * ((float)i * 0.6f - 0.3f) + Vector3.up, Quaternion.identity);
				val.GetComponent<NetworkObject>().Spawn(false);
				((GrabbableObject)val.GetComponent<PhysicsProp>()).SetScrapValue((registered[i].minValue + registered[i].maxValue) / 2);
				spawned.Add(val.GetComponent<PhysicsProp>());
				((BaseUnityPlugin)this).Logger.LogInfo((object)("TEST_SPAWN_COMPLETE " + registered[i].itemName));
			}
			if (!testHolding.Value)
			{
				yield break;
			}
			yield return (object)new WaitForSeconds(6f);
			MethodInfo beginGrab = ((object)playerController).GetType().GetMethod("BeginGrabObject", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			RaycastHit val2 = default(RaycastHit);
			foreach (PhysicsProp prop in spawned)
			{
				if (!string.IsNullOrEmpty(holdingTestItem.Value) && ((Object)((GrabbableObject)prop).itemProperties).name != holdingTestItem.Value)
				{
					continue;
				}
				Transform camera = ((Component)playerController.gameplayCamera).transform;
				bool flag = false;
				for (int attempt = 0; attempt < 5; attempt++)
				{
					if (flag)
					{
						break;
					}
					((Component)prop).transform.position = camera.position + camera.forward * (1f + (float)attempt * 0.1f) - ((Component)prop).GetComponent<BoxCollider>().center;
					((GrabbableObject)prop).fallTime = 1f;
					((GrabbableObject)prop).hasHitGround = true;
					Physics.SyncTransforms();
					beginGrab.Invoke(playerController, null);
					yield return (object)new WaitForSeconds(2f);
					flag = (Object)(object)playerController.currentlyHeldObjectServer == (Object)(object)prop && ((GrabbableObject)prop).isHeld && (Object)(object)((GrabbableObject)prop).parentObject == (Object)(object)playerController.localItemHolder;
					((BaseUnityPlugin)this).Logger.LogInfo((object)$"GRAB_ATTEMPT {((GrabbableObject)prop).itemProperties.itemName}: attempt={attempt + 1}; held={flag}");
				}
				ManualLogSource logger = ((BaseUnityPlugin)this).Logger;
				object[] obj = new object[4]
				{
					((GrabbableObject)prop).itemProperties.itemName,
					flag,
					null,
					null
				};
				Transform parentObject = ((GrabbableObject)prop).parentObject;
				obj[2] = ((parentObject != null) ? new Vector3?(parentObject.eulerAngles) : ((Vector3?)null));
				obj[3] = ((Component)prop).transform.eulerAngles;
				logger.LogInfo((object)string.Format("HOLD_TEST {0}: held={1}; hand={2}; model={3}", obj));
				LogFrameState(prop, "held");
				if (!flag)
				{
					((BaseUnityPlugin)this).Logger.LogError((object)"Normal grab failed in holding test.");
					yield break;
				}
				for (int attempt = 0; attempt < 45; attempt++)
				{
					((BaseUnityPlugin)this).Config.Reload();
					(ConfigEntry<Vector3>, ConfigEntry<Vector3>) tuple = poses[((Object)((GrabbableObject)prop).itemProperties).name];
					((GrabbableObject)prop).itemProperties.positionOffset = tuple.Item1.Value;
					((GrabbableObject)prop).itemProperties.rotationOffset = tuple.Item2.Value;
					yield return (object)new WaitForSeconds(1f);
				}
				playerController.DiscardHeldObject(false, (NetworkObject)null, default(Vector3), true);
				yield return (object)new WaitForSeconds(0.7f);
				if (((Object)((GrabbableObject)prop).itemProperties).name == "Ringhoffer240")
				{
					ManualLogSource logger2 = ((BaseUnityPlugin)this).Logger;
					AudioClip dropSFX = ((GrabbableObject)prop).itemProperties.dropSFX;
					logger2.LogInfo((object)$"TRAM_DROP_AUDIO clip={((dropSFX != null) ? ((Object)dropSFX).name : null)}; playing={((Component)prop).GetComponent<AudioSource>().isPlaying}");
				}
				yield return (object)new WaitForSeconds(1.3f);
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"DROP_TEST {((GrabbableObject)prop).itemProperties.itemName}: released={!((GrabbableObject)prop).isHeld && (Object)(object)((GrabbableObject)prop).parentObject == (Object)null}");
				LogFrameState(prop, "placed");
				if (((Object)((GrabbableObject)prop).itemProperties).name == "Ringhoffer240")
				{
					Bounds bounds = ((Renderer)((GrabbableObject)prop).mainObjectRenderer).bounds;
					if (Physics.Raycast(((Bounds)(ref bounds)).center + Vector3.up * 0.5f, Vector3.down, ref val2, 2f, LayerMask.GetMask(new string[2] { "Room", "Colliders" }), (QueryTriggerInteraction)1))
					{
						((BaseUnityPlugin)this).Logger.LogInfo((object)$"TRAM_FLOOR gap={((Bounds)(ref bounds)).min.y - ((RaycastHit)(ref val2)).point.y:F4}; bounds={((Bounds)(ref bounds)).size}");
					}
					else
					{
						((BaseUnityPlugin)this).Logger.LogWarning((object)"TRAM_FLOOR no floor raycast hit.");
					}
				}
				if ((Object)(object)((Component)prop).GetComponent<FramePresentation>() != (Object)null)
				{
					yield return (object)new WaitForSeconds(8f);
					((Component)prop).transform.position = camera.position + camera.forward * 1.3f;
					((GrabbableObject)prop).fallTime = 1f;
					((GrabbableObject)prop).hasHitGround = true;
					Physics.SyncTransforms();
					beginGrab.Invoke(playerController, null);
					yield return (object)new WaitForSeconds(2f);
					((BaseUnityPlugin)this).Logger.LogInfo((object)$"REGRAB_TEST Moon frame: held={((GrabbableObject)prop).isHeld && (Object)(object)playerController.currentlyHeldObjectServer == (Object)(object)prop}");
					LogFrameState(prop, "held");
					yield return (object)new WaitForSeconds(8f);
					playerController.DiscardHeldObject(false, (NetworkObject)null, default(Vector3), true);
					yield return (object)new WaitForSeconds(2f);
					LogFrameState(prop, "placed");
				}
			}
		}

		private void LogFrameState(PhysicsProp prop, string expected)
		{
			//IL_0073: 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_00b6: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: 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_011a: Unknown result type (might be due to invalid IL or missing references)
			FramePresentation component = ((Component)prop).GetComponent<FramePresentation>();
			if ((Object)(object)component == (Object)null)
			{
				return;
			}
			Mesh sharedMesh = ((Component)prop).GetComponentInChildren<MeshFilter>().sharedMesh;
			bool flag = component.ShowingHeld == (expected == "held");
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"FRAME_STATE expected={expected}; valid={flag}; mesh={((Object)sharedMesh).name}; floorOffset={((GrabbableObject)prop).itemProperties.verticalOffset:F4}; localBounds={((Component)prop).GetComponent<BoxCollider>().size}");
			if (!flag)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Frame presentation did not match the grab state.");
			}
			if (expected == "placed")
			{
				Bounds bounds = ((Renderer)((GrabbableObject)prop).mainObjectRenderer).bounds;
				RaycastHit val = default(RaycastHit);
				if (Physics.Raycast(((Bounds)(ref bounds)).center + Vector3.up * 0.5f, Vector3.down, ref val, 2f, LayerMask.GetMask(new string[2] { "Room", "Colliders" }), (QueryTriggerInteraction)1))
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)$"FRAME_FLOOR gap={((Bounds)(ref bounds)).min.y - ((RaycastHit)(ref val)).point.y:F4}; rendererCount={((Component)prop).GetComponentsInChildren<MeshRenderer>().Length}");
				}
			}
		}

		private static AudioClip MakeSound(string name, float frequency)
		{
			float[] array = new float[2205];
			for (int i = 0; i < array.Length; i++)
			{
				float num = (float)i / 22050f;
				array[i] = 0.2f * (float)(Math.Sin(Math.PI * 2.0 * (double)frequency * (double)num) * Math.Exp((0f - num) * 65f));
			}
			AudioClip obj = AudioClip.Create(name + "Clink", array.Length, 1, 22050, false);
			obj.SetData(array, 0);
			return obj;
		}
	}
}