Decompiled source of TailScrap v1.0.0

myscraps.dll

Decompiled 2 years ago
using System;
using System.Diagnostics;
using System.IO;
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 LethalLib.Modules;
using LethalThings.MonoBehaviours;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;

[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: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("LethalThings")]
[assembly: AssemblyCompany("myscraps")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("myscraps")]
[assembly: AssemblyTitle("myscraps")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace myscraps
{
	[RequireComponent(typeof(Rigidbody))]
	public class GrabbableRigidbody : GrabbableObject
	{
		public float gravity = 9.8f;

		internal Rigidbody rb;

		public override void Start()
		{
			rb = ((Component)this).GetComponent<Rigidbody>();
			rb.useGravity = false;
			base.itemProperties.itemSpawnsOnGround = false;
			((GrabbableObject)this).Start();
			EnablePhysics(enable: true);
		}

		public void EnablePhysics(bool enable)
		{
			for (int i = 0; i < base.propColliders.Length; i++)
			{
				if (!((Object)(object)base.propColliders[i] == (Object)null) && !((Component)base.propColliders[i]).gameObject.CompareTag("InteractTrigger") && !((Component)base.propColliders[i]).gameObject.CompareTag("DoNotSet"))
				{
					base.propColliders[i].enabled = enable;
				}
			}
			rb.isKinematic = !enable;
		}

		public override void Update()
		{
			base.fallTime = 1f;
			base.reachedFloorTarget = true;
			bool isHeld = base.isHeld;
			base.isHeld = true;
			((GrabbableObject)this).Update();
			base.isHeld = isHeld;
		}

		public void FixedUpdate()
		{
			//IL_008f: 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_004b: 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)
			if (((NetworkBehaviour)this).IsHost)
			{
				if (!rb.isKinematic && !base.isHeld)
				{
					rb.useGravity = false;
					rb.AddForce(Vector3.down * gravity, (ForceMode)5);
					ManualLogSource logger = Plugin.logger;
					Vector3 velocity = rb.velocity;
					logger.LogMessage((object)("Velocity: " + ((object)(Vector3)(ref velocity)).ToString()));
				}
				else
				{
					rb.AddForce(Vector3.zero, (ForceMode)2);
				}
			}
		}

		public override void LateUpdate()
		{
			//IL_0029: 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_0057: 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_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)
			//IL_007a: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)base.parentObject != (Object)null && base.isHeld)
			{
				((Component)this).transform.rotation = base.parentObject.rotation;
				((Component)this).transform.Rotate(base.itemProperties.rotationOffset);
				((Component)this).transform.position = base.parentObject.position;
				Vector3 positionOffset = base.itemProperties.positionOffset;
				positionOffset = base.parentObject.rotation * positionOffset;
				Transform transform = ((Component)this).transform;
				transform.position += positionOffset;
			}
			if ((Object)(object)base.radarIcon != (Object)null)
			{
				base.radarIcon.position = ((Component)this).transform.position;
			}
		}

		public override void FallWithCurve()
		{
		}

		public void FallToGround(bool randomizePosition = false)
		{
		}

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
			((Component)this).transform.SetParent((Transform)null, true);
		}
	}
	public class MyDart : MonoBehaviour
	{
		public Dart dart;

		public void Start()
		{
			Plugin.logger.LogWarning((object)dart.audioSource);
		}
	}
	[BepInPlugin("myscraps", "myscraps", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public static ManualLogSource logger;

		public static AssetBundle MyCustomAssets;

		private ConfigEntry<int> configRarity;

		private void Awake()
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			logger = ((BaseUnityPlugin)this).Logger;
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			MyCustomAssets = AssetBundle.LoadFromFile(Path.Combine(directoryName, "myscraps"));
			if ((Object)(object)MyCustomAssets == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load custom assets.");
				return;
			}
			configRarity = ((BaseUnityPlugin)this).Config.Bind<int>("General", "FoxTailPlug Rarity", 30, new ConfigDescription("FoxTailPlug spawn rate.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			int value = configRarity.Value;
			Item val = MyCustomAssets.LoadAsset<Item>("Assets/Scraps/FoxTailPlug.asset");
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			Utilities.FixMixerGroups(val.spawnPrefab);
			Items.RegisterScrap(val, value, (LevelTypes)(-1));
			logger.LogInfo((object)"Plugin myscraps is loaded!");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "myscraps";

		public const string PLUGIN_NAME = "myscraps";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}